Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLoggingHooks = &Trace{ Listened: func(address string, e error) { if e != nil { log.Printf("Listen address:%s status:%v\n", address, e) } }, StartAccepting: func() { log.Printf("Start Accepting\n") }, Accepted: func(conn net.Conn, e error) { if e != nil { log.Printf("Accept status:%v\n", e) } }, NewServerConn: func(conn net.Conn, e error) { if e != nil { log.Printf("NewServerConn status:%v\n", e) } }, SSHChannelAccept: func(conn net.Conn, e error) { if e != nil { log.Printf("SSHChannelAccept status:%v\n", e) } }, SubsystemRequestReply: func(e error) { if e != nil { log.Printf("SubsystemRequestReply status:%v\n", e) } }, }
DefaultLoggingHooks provides a default logging hook to report errors.
View Source
var DiagnosticLoggingHooks = &Trace{ Listened: func(address string, e error) { log.Printf("Listen address:%s status:%v\n", address, e) }, StartAccepting: func() { log.Printf("Start Accepting\n") }, Accepted: func(conn net.Conn, e error) { log.Printf("Accept conn:%v status:%v\n", conn, e) }, NewServerConn: func(conn net.Conn, e error) { log.Printf("NewServerConn conn:%v status:%v\n", conn, e) }, SSHChannelAccept: func(conn net.Conn, e error) { log.Printf("NewServerConn conn:%v status:%v\n", conn, e) }, SubsystemRequestReply: func(e error) { log.Printf("SubsystemRequestReply status:%v\n", e) }, }
DiagnosticLoggingHooks provides a set of default diagnostic hooks
View Source
var NoOpLoggingHooks = &Trace{ Listened: func(address string, e error) {}, StartAccepting: func() {}, Accepted: func(conn net.Conn, ze error) {}, NewServerConn: func(conn net.Conn, ze error) {}, SSHChannelAccept: func(conn net.Conn, ze error) {}, SubsystemRequestReply: func(ze error) {}, }
NoOpLoggingHooks provides set of hooks that do nothing.
Functions ¶
func PasswordConfig ¶
func PasswordConfig(uname, password string) (*ssh.ServerConfig, error)
Types ¶
type Handler ¶
type Handler interface { // Handler is a function that handles i/o to/from an SSH channel Handle(ch ssh.Channel) }
Handler is the interface that is implemented to handle an SSH channel.
type HandlerFactory ¶
type HandlerFactory func(conn *ssh.ServerConn) Handler
HandlerFactory is a function that will deliver an Handler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a test SSH Server
func NewServer ¶
func NewServer(ctx context.Context, address string, port int, cfg *ssh.ServerConfig, factory HandlerFactory) (server *Server, err error)
NewServer deflivers a new test SSH Server, with a custom channel handler. The server implements password authentication with the given credentials.
type Trace ¶
type Trace struct { // Listened is called when when an Listen() call completes, with err indicating // whether it was successful. Listened func(adddress string, err error) // StartAccepting is called when starting to accept connections. StartAccepting func() // Accepted is called when an Accept() call completes, with err indicating // whether it was successful. Accepted func(conn net.Conn, err error) // NewServerConn is called when a NewServerConn() call completes, with err indicating // whether it was successful. NewServerConn func(conn net.Conn, err error) // SSHChannelAccept is called when a ssh channel Accept() call completes, with err indicating // whether it was successful. SSHChannelAccept func(conn net.Conn, err error) // SubsystemRequestReply is called when a subsystem request Reply call completes, with err indicating // whether it was successful. SubsystemRequestReply func(err error) }
Trace defines a structure for handling trace events
func ContextSSHTrace ¶ added in v2.5.0
ContextSSHTrace returns the Trace associated with the provided context. If none, it returns nil.
Click to show internal directories.
Click to hide internal directories.