Skip to content

Commit a45f0b2

Browse files
authored
Merge pull request #19 from kitknox/timeout
skip close delay when old client already timed out
2 parents cfdef82 + fb145c8 commit a45f0b2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tsshd/server.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,14 @@ func (s *sshUdpServer) activateServer() error {
175175
// from exiting unexpectedly while the old client is still connected.
176176
oldServer.closeActiveStreams()
177177

178-
debug("new client [%x] notifying old client [%x] to quit", s.client.proxyAddr.clientID, oldServer.client.proxyAddr.clientID)
179-
_ = oldServer.sendBusMessage("quit", quitMessage{fmt.Sprintf("another client attached from %s", s.client.remoteAddr())})
180-
time.Sleep(time.Second) // give udp some time
181-
oldServer.Close()
178+
if oldServer.clientChecker.isTimeout() {
179+
oldServer.Close()
180+
} else {
181+
debug("new client [%x] notifying old client [%x] to quit", s.client.proxyAddr.clientID, oldServer.client.proxyAddr.clientID)
182+
_ = oldServer.sendBusMessage("quit", quitMessage{fmt.Sprintf("another client attached from %s", s.client.remoteAddr())})
183+
time.Sleep(time.Second) // give udp some time
184+
oldServer.Close()
185+
}
182186
}()
183187
}
184188

0 commit comments

Comments
 (0)