simpleipsvcd

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: 11 Imported by: 0

Documentation

Overview

simpleip implements simple & standard Internet services that were used in the nostalgic era of computing. According to those protocol standard, the services are available via TCP and UDP simultaneously: - sysstat (active system user name on port 11, RFC 866) - daytime (current system time in readable text on port 12+1, RFC 867) - QOTD (short text message as quote of the day on port 17, RFC 865)

Index

Constants

View Source
const (
	IOTimeoutSec         = 30 // IOTimeoutSec is the timeout used in network request/response operations.
	RateLimitIntervalSec = 1  // RateLimitIntervalSec is the interval for rate limit calculation.
)

Variables

This section is empty.

Functions

func TestSimpleIPSvcD

func TestSimpleIPSvcD(daemon *Daemon, t testingstub.T)

Types

type Daemon

type Daemon struct {
	Address         string `json:"Address"`         // Address to listen on, e.g. 0.0.0.0 to listen on all network interfaces.
	ActiveUsersPort int    `json:"ActiveUsersPort"` // ActiveUsersPort is the port number (TCP and UDP) to listen on for the sysstat (active user names) service.
	DayTimePort     int    `json:"DayTimePort"`     // DayTimePort is the port number (TCP and UDP) to listen on for the daytime service.
	QOTDPort        int    `json:"QOTDPort"`        // QOTDPort is the port number (TCP and UDP) to listen on for the QOTD service.
	PerIPLimit      int    `json:"PerIPLimit"`      // PerIPLimit is approximately how many requests are allowed from an IP within a designated interval.
	ActiveUserNames string `json:"ActiveUserNames"` // ActiveUserNames are CRLF-separated list of user names to appear in the response of "sysstat" network service.
	QOTD            string `json:"QOTD"`            // QOTD is the message to appear in the response of "QOTD" network service.
	// contains filtered or unexported fields
}

Daemon implements simple & standard Internet services that were used in the nostalgic era of computing.

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 all TCP and UDP servers to serve network clients. You may call this function only after having called Initialise().

func (*Daemon) Stop

func (daemon *Daemon) Stop()

Stop terminates all TCP and UDP servers.

type TCPService

type TCPService struct {
	// ResponseFun is a function returning a string as the entire response to a simple IP service request.
	ResponseFun func() string
}

TCPService implements common.TCPApp interface for a simple IP service.

func (*TCPService) GetTCPStatsCollector

func (svc *TCPService) GetTCPStatsCollector() *misc.Stats

GetTCPStatsCollector returns the stats collector that counts and times client connections for the TCP application.

func (*TCPService) HandleTCPConnection

func (svc *TCPService) HandleTCPConnection(logger *lalog.Logger, _ string, client *net.TCPConn)

HandleTCPConnection

type UDPService

type UDPService struct {
	// ResponseFun is a function returning a string as the entire response to a simple IP service request.
	ResponseFun func() string
}

UDPService implements common.UDPApp interface for a simple IP service.

func (*UDPService) GetUDPStatsCollector

func (svc *UDPService) GetUDPStatsCollector() *misc.Stats

GetUDPStatsCollector returns the stats collector that counts and times client connections for the TCP application.

func (*UDPService) HandleUDPClient

func (svc *UDPService) HandleUDPClient(logger *lalog.Logger, _ string, client *net.UDPAddr, _ []byte, srv *net.UDPConn)

HandleTCPConnection

Jump to

Keyboard shortcuts

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