Add disconnect callback - #263
Conversation
|
Interesting, tests pass on my local machine ( Can this test be re-run? |
|
Thanks a lot for proposing and implementing this, @LukaszMoskala — the We've ported your change to our maintained fork of gliderlabs/ssh here: engity-com/ssh-server-go#5 The original PR and your work are explicitly referenced there so that the origin and credit remain clear. We're maintaining engity-com/ssh-server-go as a continuation of gliderlabs/ssh, since upstream development has unfortunately become rather quiet. Contributions like this are extremely valuable to us, so thank you for putting the work into designing and implementing this. |
Summary
Adds a
DisconnectCallback, invoked when a connection dies after the SSH session was successfully established. This complements the existingConnectionFailedCallback, which only covers connection failures.Motivation
With SSH
ControlMaster, multiple interactive sessions can share a single underlying SSH connection. When those sessions share resources tied to the connection, there needs to be a reliable hook to release them once the connection actually closes.Releasing resources after the last interactive session closes isn't sufficient: with
ControlMaster, the underlying SSH connection may still be alive and can still open new interactive sessions.DisconnectCallbackfires specifically when the SSH connection itself ends, so cleanup only happens when no further sessions can be opened.I have tested this and it works as expected.
Thank you for maintaining this library and have a nice day!