Documentation ¶
Index ¶
- type Client
- type RedisHost
- func (host *RedisHost) Close()
- func (host *RedisHost) IsListening(hostname string) bool
- func (host *RedisHost) IsOpen() bool
- func (host *RedisHost) SendPublicMessage(recipient string, msg drshproto.PublicMessage)
- func (host *RedisHost) SendSessionMessage(recipient string, msg drshproto.SessionMessage)
- func (host *RedisHost) Start()
- type Server
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Host *RedisHost // contains filtered or unexported fields }
Client represents a host on the network who wishes to do something with a specific server, whether this is a file-transfer operation, an interactive session, or a series of pings.
func NewClient ¶
func NewClient(username string, hostname string, uri string, logger *zap.SugaredLogger) (*Client, error)
NewClient creates a new client and its underlying connection to Redis. It is not actively receiving, sending, or processing messages at this point; that is only enabled upon start.
func (*Client) Close ¶
func (clnt *Client) Close()
Close is called to destroy the client's Redis connection and perform cleanup.
func (*Client) DownloadFile ¶
Downloads a file from the remote server.
func (*Client) LoginInteractively ¶
Creates an interactive session with its server.
func (*Client) Ping ¶
func (clnt *Client) Ping()
Sends an infinite series of pings to the server until it receives an interrupt from the user.
type RedisHost ¶
type RedisHost struct { Hostname string // The name of this host (e.g. what channel this host is listening on) Logger *zap.SugaredLogger // The logger attached to this host Encryption *drshsec.EncryptionModule // Responsible for performing key exchange, symmetric encryption, etc. // contains filtered or unexported fields }
A wrapper around Redis that only uses Redis as a message broker. It tries to hide the full functionality of Redis by only exposing functions related to sending and receiving drsh messages.
func NewChildRedisHost ¶
A niche method that is used by a server session to create a host using the parent server's existing connection. This host shares the parent's connection resources, but doesn't own them. This is mainly used by the server for spawning new sessions.
func NewRedisHost ¶
Creates a new Redis host. The host will connect as `hostname` to the Redis node at `uri` and will subscribe to the channel "drsh:`hostname`". Although the host is connected, it is not actively processing messages at this point.
func (*RedisHost) Close ¶
func (host *RedisHost) Close()
Closes the host. The connection to Redis is dropped and the host can no longer send messages. If the host was created using NewInheritedRedisHost (e.g. a server spawns a session), then the underlying connection is left intact.
func (*RedisHost) IsListening ¶
Returns whether or not a host with this name is listening on the network. A listening host means that the host is subscribed to its channel. It is a necessary but not sufficient condition for host communication, as the other host must be responsive too.
func (*RedisHost) IsOpen ¶
Returns whether or not the host is listening on the network. The host is considered open from creation until Close() is called on it.
func (*RedisHost) SendPublicMessage ¶
func (host *RedisHost) SendPublicMessage(recipient string, msg drshproto.PublicMessage)
A thread-safe way to send public messages to another host on the network.
func (*RedisHost) SendSessionMessage ¶
func (host *RedisHost) SendSessionMessage(recipient string, msg drshproto.SessionMessage)
A thread-safe way to send session messages to another host on the network. The session messages will be encrypted with a mutually derived key.
type Server ¶
Represents a host on the network that accepts connections & pings from any clients that wish to communicate with it. On a successful handshake with a client, a server will spawn a separate "session" through which all communication is encrypted. Because the session handles most of the connection legwork, the actual server class is fairly light.
func NewServer ¶
NewServer creates a new server and its underlying connection to Redis. It is not actively receiving, sending, or processing messages at this point; that is only enabled upon start.
func (*Server) Close ¶
func (serv *Server) Close()
Destroys the server's Redis connection and perform cleanup.
func (*Server) NewSession ¶
Creates a session given that the server has received necessary information like a client's public key and target username. It sets up the Redis host, subscribes to the proper channel, assigns a name to the session, sets up encryption, and initializes the client's interactive pseudoterminal and/or transfer file.
type Session ¶
type Session struct { Host *RedisHost // contains filtered or unexported fields }
Represents the server's view of the connection between it and the client. Every session between a server and a client is considered unique. The session piggybacks off of the server's own Redis connection so that not as much TCP state has to be maintained. In many ways, a session is analogous to an encrypted tunnel in SSH, as the session can only be created after a successful key exchange occurring in a handshake. Every session also maintains its own pseudoterminal that is controlled by the client.