After considering several
alternative communication protocols, simple network sockets were chosen for the communication layer, since
- they can be used for local as well as remote sessions, and
- can be tunneled through SSH.
The details of the protocol are described below.
Startup
User requests a new
session from Anthias and specifies if it is a
local session, or a
remote session.
Local session
If
local session, then
- Anthias opens a pseudo-tty,
- sets TERM_EXTENDED=AnthiasLocal
- starts user's login shell in it.
Remote session
If
remote session,
- Anthias prompts user to enter remote hostname/ip.
- Anthias connects to remote host using SSH.
- Anthias sets env-variables:
- TERM_EXTENDED=AnthiasRemote
- ANTHIAS_REMOTE_ADDR=#ip_address
(This is required so that remote application can bind to the same ip-address as the SSH session.)
- Anthias opens a SSH channel and executes the user's shell in it.
Shell startup
At this point, the user is presented with an innocuous xterm-like interface. There are no special widgets, no directory browsing, nothing. But now, if the user (or the login process) starts an Anthias-capable shell, the ball starts rolling. We will call this hypothetical shell, the
AShell.
AShell Registeration
- AShell checks if TERM_EXTENDED is set.
- AShell creates a socket. If TERM_EXTENDED is AnthiasRemote, then it binds the socket to ANTHIAS_REMOTE_ADDR. Otherwise it binds to localhost.
- AShell emits "ANTHIAS_REGISTER_SEQUENCE #my_ip #my_port_num" onto the terminal.
- When Anthias sees the ANTHIAS_REGISTER_SEQUENCE, it creates a socket and connects it to the AShell's socket. If the session is local, then this is
straight forward. If it is remote, then the SSH service is used to port-forward.
- Anthias emits "ANTHIAS_REGISTER_RESPONSE [success|failure]" onto the terminal.
- From now on, communication between AShell and Anthias takes place over the socket.
Communication basics
Communication between AShell and Anthias will be in binary. The advantages of this approach are,
- It will save extraneous string parsing and comparisons.
- It will save bandwidth, memory, and ultimately, processing time.
- Skipping to next message can be efficiently done by skipping a known number of bytes.
Message Types
Here we list the message types used by Anthias to communicate with AShell.
AShell initiated messages
Anthias initiated messages