feat: cleanup remote client on connection closed

This commit is contained in:
wpetit 2020-10-23 13:42:18 +02:00
parent 1fc335418b
commit 7aa977d2fe
2 changed files with 7 additions and 0 deletions

View File

@ -125,6 +125,12 @@ func (c *RemoteClient) Proxy(ctx context.Context, network, address string) (net.
return c.control.Proxy(ctx, network, address)
}
func (c *RemoteClient) Close() {
if c.sess != nil && !c.sess.IsClosed() {
c.sess.Close()
}
}
func NewRemoteClient() *RemoteClient {
return &RemoteClient{}
}

View File

@ -37,6 +37,7 @@ func (s *Server) handleNewConn(ctx context.Context, conn *kcp.UDPSession) {
ctx = logger.With(ctx, logger.F("remoteAddr", conn.RemoteAddr().String()))
remoteClient := NewRemoteClient()
defer remoteClient.Close()
remoteClient.ConfigureHooks(s.conf.Hooks)