plainsocket

package
v0.0.0-...-2db35d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MPL-2.0 Imports: 15 Imported by: 0

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

View Source
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

func (daemon *Daemon) GetTCPStatsCollector() *misc.Stats

GetTCPStatsCollector returns stats collector for the TCP server of this daemon.

func (*Daemon) GetUDPStatsCollector

func (daemon *Daemon) GetUDPStatsCollector() *misc.Stats

GetUDPStatsCollector returns stats collector for the UDP server of this daemon.

func (*Daemon) HandleTCPConnection

func (daemon *Daemon) HandleTCPConnection(logger *lalog.Logger, ip string, conn *net.TCPConn)

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

func (daemon *Daemon) Initialise() error

Initialise validates configuration and initialises internal states.

func (*Daemon) StartAndBlock

func (daemon *Daemon) StartAndBlock() error

StartAndBLock starts both TCP and UDP listeners. You may call this function only after having called Initialise().

func (*Daemon) Stop

func (daemon *Daemon) Stop()

Close all of open TCP and UDP listeners so that they will cease processing incoming connections.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL