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