telnet

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAddr defines the default address of the telnet server when one is
	// not provided via the options. This default to the telnet port on the local
	// host.
	DefaultAddr = ":23"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	ServeTELNET(*Session)
}

A Handler responds to telnet activity.

type HandlerFunc

type HandlerFunc func(*Session)

HandlerFunc is an adapter to allow the use of an ordinary function as a telnet handler.

func (HandlerFunc) ServeTELNET

func (f HandlerFunc) ServeTELNET(s *Session)

ServeTELNET calls f(s).

type MiddlewareFunc

type MiddlewareFunc = func(Handler) Handler

MiddlewareFunc is a function which takes a Handler and returns a Handler. Typically the returned handler is a closure which does something with the Session passed to it, and then calls the handler passed as the parameter to the MiddlewareFunc.

type RecoveryMiddleware added in v0.2.20

type RecoveryMiddleware struct {
	Logger *zerolog.Logger
}

func (RecoveryMiddleware) Recover added in v0.2.20

func (r RecoveryMiddleware) Recover(next Handler) Handler

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represent a telnet server.

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer create a telnet server with the given server options.

func (*Server) Middleware

func (s *Server) Middleware(middleware ...MiddlewareFunc)

Middleware installs the given middleware with the server.

func (*Server) Name added in v0.2.18

func (s *Server) Name() string

Name returns the name of the server.

func (*Server) Register

func (s *Server) Register(service Service)

Register associates the given service with the server.

func (*Server) Serve

func (s *Server) Serve() error

Serve creates the underlying network connection and starts the telnet server.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

Shutdown stops the telnet server.

type ServerConfig added in v0.2.17

type ServerConfig struct {
	// contains filtered or unexported fields
}

ServerConfig holds the configuration information for the telnet server.

func NewServerConfig added in v0.2.17

func NewServerConfig(prefix ...string) (ServerConfig, error)

NewServerConfig returns the configuration of telnet server.

func (ServerConfig) ServerAddr added in v0.2.17

func (c ServerConfig) ServerAddr() string

ServerAddr returns the network address the server will listen on.

func (ServerConfig) ToOptions added in v0.2.17

func (c ServerConfig) ToOptions() []ServerOption

ToOptions converts the configuration to a list of server options.

type ServerOption

type ServerOption interface {
	Apply(*Server)
}

ServerOption provides options for configuring the creation of a telnet server.

func WithServerAddr added in v0.2.17

func WithServerAddr(addr string) ServerOption

WithServerAddr will configure the server with the listen address.

func WithServerLogger

func WithServerLogger(logger *zerolog.Logger) ServerOption

WithServerLogger provides a logger to the server.

type Service

type Service interface {
	// Name returns the name of the service.
	Name() string

	// ServeTELNET provides the telnet handler.
	ServeTELNET(*Session)

	// Shutdown allows the service to stop any long running background processes
	// it may have.
	Shutdown(context.Context)
}

Service defines the methods required by the server to associate the service with the server.

type Session

type Session = telnet.Session

Session is an alias for telnet-go.Session. This allows for this package to be used without importing telnet-go as well.

type SessionMiddleware added in v0.2.20

type SessionMiddleware struct {
	Logger *zerolog.Logger
}

func (SessionMiddleware) Session added in v0.2.20

func (s SessionMiddleware) Session(next Handler) Handler

Jump to

Keyboard shortcuts

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