Documentation ¶
Overview ¶
plainsocket implements a Telnet-comaptible network service to provide unencrypted, plain-text access to all toolbox features. Due to the unencrypted nature of this communication, users are strongly advised to utilise this service only as a last resort. The implementation supports UDP as carrier of conversation in addition to TCP.
Index ¶
- Constants
- func TestServer(server *Daemon, t testingstub.T)
- type Daemon
- func (daemon *Daemon) GetTCPStatsCollector() *misc.Stats
- func (daemon *Daemon) GetUDPStatsCollector() *misc.Stats
- func (daemon *Daemon) HandleTCPConnection(logger *lalog.Logger, ip string, conn *net.TCPConn)
- func (daemon *Daemon) HandleUDPClient(logger *lalog.Logger, ip string, client *net.UDPAddr, packet []byte, ...)
- func (daemon *Daemon) Initialise() error
- func (daemon *Daemon) StartAndBlock() error
- func (daemon *Daemon) Stop()
Constants ¶
const ( IOTimeoutSec = 60 // If a conversation goes silent for this many seconds, the connection is terminated. CommandTimeoutSec = IOTimeoutSec - 1 // Command execution times out after this manys econds RateLimitIntervalSec = 1 // Rate limit is calculated at 1 second interval )
Variables ¶
This section is empty.
Functions ¶
func TestServer ¶
func TestServer(server *Daemon, t testingstub.T)
TestServer contains the comprehensive test case for both TCP and UDP servers.
Types ¶
type Daemon ¶
type Daemon struct { Address string `json:"Address"` // Network address for both TCP and UDP to listen to, e.g. 0.0.0.0 for all network interfaces. TCPPort int `json:"TCPPort"` // TCP port to listen on UDPPort int `json:"UDPPort"` // UDP port to listen on PerIPLimit int `json:"PerIPLimit"` // PerIPLimit is approximately how many concurrent users are expected to be using the server from same IP address Processor *toolbox.CommandProcessor `json:"-"` // Feature command processor // contains filtered or unexported fields }
Daemon implements a Telnet-compatible service to provide unencrypted, plain-text access to all toolbox features, via both TCP and UDP.
func (*Daemon) GetTCPStatsCollector ¶
GetTCPStatsCollector returns stats collector for the TCP server of this daemon.
func (*Daemon) GetUDPStatsCollector ¶
GetUDPStatsCollector returns stats collector for the UDP server of this daemon.
func (*Daemon) HandleTCPConnection ¶
HandleConnection converses with a TCP client.
func (*Daemon) HandleUDPClient ¶
func (daemon *Daemon) HandleUDPClient(logger *lalog.Logger, ip string, client *net.UDPAddr, packet []byte, srv *net.UDPConn)
Read a feature command from each input line, then invoke the requested feature and write the execution result back to client.
func (*Daemon) Initialise ¶
Initialise validates configuration and initialises internal states.
func (*Daemon) StartAndBlock ¶
StartAndBLock starts both TCP and UDP listeners. You may call this function only after having called Initialise().