Documentation
¶
Index ¶
Constants ¶
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 ¶
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
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.
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 ¶
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
func (SessionMiddleware) Session ¶ added in v0.2.20
func (s SessionMiddleware) Session(next Handler) Handler