File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ type Server struct {
51
51
ServerConfigCallback ServerConfigCallback // callback for configuring detailed SSH options
52
52
SessionRequestCallback SessionRequestCallback // callback for allowing or denying SSH sessions
53
53
54
- ConnectionFailedCallback ConnectionFailedCallback // callback to report connection failures
54
+ // server calls Failed callback for connections that fail initial handshake, and Complete callback for those that
55
+ // succeed, never both.
56
+ ConnectionFailedCallback ConnectionFailedCallback // callback to report connection failures
57
+ ConnectionCompleteCallback ConnectionCompleteCallback // callback to report connection completion
55
58
56
59
IdleTimeout time.Duration // connection timeout when no activity, none if empty
57
60
MaxTimeout time.Duration // absolute connection timeout, none if empty
@@ -295,6 +298,11 @@ func (srv *Server) HandleConn(newConn net.Conn) {
295
298
}
296
299
return
297
300
}
301
+ if srv .ConnectionCompleteCallback != nil {
302
+ defer func () {
303
+ srv .ConnectionCompleteCallback (sshConn , sshConn .Wait ())
304
+ }()
305
+ }
298
306
299
307
srv .trackConn (sshConn , true )
300
308
defer srv .trackConn (sshConn , false )
Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ type ServerConfigCallback func(ctx Context) *gossh.ServerConfig
71
71
// Please note: the net.Conn is likely to be closed at this point
72
72
type ConnectionFailedCallback func (conn net.Conn , err error )
73
73
74
+ // ConnectionCompleteCallback is a hook for reporting connections that
75
+ // complete. The included error is from the underlying SSH transport
76
+ // protocol mux (golang.org/x/crypto/ssh), and is non-nil, even for
77
+ // normal termination.
78
+ //
79
+ // Please note: the ServerConn is closed at this point
80
+ type ConnectionCompleteCallback func (conn * gossh.ServerConn , err error )
81
+
74
82
// Window represents the size of a PTY window.
75
83
//
76
84
// See https://datatracker.ietf.org/doc/html/rfc4254#section-6.2
You can’t perform that action at this time.
0 commit comments