Add ConnectionFailedCallback to enable reporting of failed connection
Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
fb34512070
commit
98ce6bfebb
@ -48,6 +48,8 @@ type Server struct {
|
|||||||
ServerConfigCallback ServerConfigCallback // callback for configuring detailed SSH options
|
ServerConfigCallback ServerConfigCallback // callback for configuring detailed SSH options
|
||||||
SessionRequestCallback SessionRequestCallback // callback for allowing or denying SSH sessions
|
SessionRequestCallback SessionRequestCallback // callback for allowing or denying SSH sessions
|
||||||
|
|
||||||
|
ConnectionFailedCallback ConnectionFailedCallback // callback to report connection failures
|
||||||
|
|
||||||
IdleTimeout time.Duration // connection timeout when no activity, none if empty
|
IdleTimeout time.Duration // connection timeout when no activity, none if empty
|
||||||
MaxTimeout time.Duration // absolute connection timeout, none if empty
|
MaxTimeout time.Duration // absolute connection timeout, none if empty
|
||||||
|
|
||||||
@ -278,7 +280,9 @@ func (srv *Server) HandleConn(newConn net.Conn) {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
sshConn, chans, reqs, err := gossh.NewServerConn(conn, srv.config(ctx))
|
sshConn, chans, reqs, err := gossh.NewServerConn(conn, srv.config(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: trigger event callback
|
if srv.ConnectionFailedCallback != nil {
|
||||||
|
srv.ConnectionFailedCallback(conn, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
ssh.go
4
ssh.go
@ -64,6 +64,10 @@ type ReversePortForwardingCallback func(ctx Context, bindHost string, bindPort u
|
|||||||
// ServerConfigCallback is a hook for creating custom default server configs
|
// ServerConfigCallback is a hook for creating custom default server configs
|
||||||
type ServerConfigCallback func(ctx Context) *gossh.ServerConfig
|
type ServerConfigCallback func(ctx Context) *gossh.ServerConfig
|
||||||
|
|
||||||
|
// ConnectionFailedCallback is a hook for reporting failed connections
|
||||||
|
// Please note: the net.Conn is likely to be closed at this point
|
||||||
|
type ConnectionFailedCallback func(conn net.Conn, err error)
|
||||||
|
|
||||||
// Window represents the size of a PTY window.
|
// Window represents the size of a PTY window.
|
||||||
type Window struct {
|
type Window struct {
|
||||||
Width int
|
Width int
|
||||||
|
Loading…
Reference in New Issue
Block a user