telnet

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 6 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 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) 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 ServerOption

type ServerOption interface {
	Apply(*Server)
}

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

func WithServerAddress

func WithServerAddress(addr string) ServerOption

WithServerAddress 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.

Jump to

Keyboard shortcuts

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