Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ServerContextKey is a context key. It can be used in handlers with // context.WithValue to access the server that started the handler. The // associated value will be of type *Server. ServerContextKey = &contextKey{"http-server"} // LocalAddrContextKey is a context key. It can be used in handlers with // context.WithValue to access the address the local address the connection // arrived on. The associated value will be of type net.Addr. LocalAddrContextKey = &contextKey{"local-addr"} // ErrServerHasNoHostKeys is returned when you try to start a server without adding any host keys ErrServerHasNoHostKeys = errors.New("server has no host keys") )
View Source
var DefaultHandler = HandlerFunc(func(p *Permissions, c Channel, r <-chan *Request) { ssh.DiscardRequests(unwrapRequests(r)) })
Functions ¶
func PublicConfig ¶
func PublicConfig() *ssh.ServerConfig
Types ¶
type ConnState ¶
type ConnState int
A ConnState represents the state of a client connection to a server. It's used by the optional Server.ConnState hook.
const ( // StateNew represents a new connection that has newly connected. Connections // begin at this state and then transition to either StateActive or // StateClosed. StateNew ConnState = iota // StateHandshake represents a connection that is currently performing the // handshake. StateHandshake // StateActive represents a connection that has read 1 or more // bytes of a request. StateActive // StateClosed represents a closed connection. // This is a terminal state. StateClosed )
type Handler ¶
type Handler interface {
ServeSSH(*Permissions, Channel, <-chan *Request) // TODO: Finish filling this in
}
Handler handles ssh connections
type HandlerFunc ¶
type HandlerFunc func(*Permissions, Channel, <-chan *Request)
The HandlerFunc type is an adapter to allow the use of ordinary functions as handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.
func (HandlerFunc) ServeSSH ¶
func (f HandlerFunc) ServeSSH(p *Permissions, c Channel, r <-chan *Request)
ServeSSH calls f(p, c, r).
type Permissions ¶
type Permissions struct {
ssh.Permissions
}
type Server ¶
type Server struct { Addr string // TCP address to listen on, ":ssh" if empty Handler Handler // handler to invoke, DefaultHandler if nil // ConnState specifies an optional callback function that is // called when a client connection changes state. See the // ConnState type and associated constants for details. ConnState func(net.Conn, ConnState) // ErrorLog specifies an optional logger for errors accepting // connections and unexpected behavior from handlers. // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // HostKey count to track the number of added host keys. // // This sucks a bit, but there's no way to get the number of host keys from // the ServerConfig directly. HostKeyCount int *ssh.ServerConfig }
Server is an SSH server
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address srv.Addr and then calls Serve to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives. If srv.Addr is blank, ":ssh" is used. ListenAndServe always returns a non-nil error.
Click to show internal directories.
Click to hide internal directories.