feat: cleanup remote client on connection closed
This commit is contained in:
parent
1fc335418b
commit
7aa977d2fe
|
@ -125,6 +125,12 @@ func (c *RemoteClient) Proxy(ctx context.Context, network, address string) (net.
|
||||||
return c.control.Proxy(ctx, network, address)
|
return c.control.Proxy(ctx, network, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *RemoteClient) Close() {
|
||||||
|
if c.sess != nil && !c.sess.IsClosed() {
|
||||||
|
c.sess.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewRemoteClient() *RemoteClient {
|
func NewRemoteClient() *RemoteClient {
|
||||||
return &RemoteClient{}
|
return &RemoteClient{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ func (s *Server) handleNewConn(ctx context.Context, conn *kcp.UDPSession) {
|
||||||
ctx = logger.With(ctx, logger.F("remoteAddr", conn.RemoteAddr().String()))
|
ctx = logger.With(ctx, logger.F("remoteAddr", conn.RemoteAddr().String()))
|
||||||
|
|
||||||
remoteClient := NewRemoteClient()
|
remoteClient := NewRemoteClient()
|
||||||
|
defer remoteClient.Close()
|
||||||
|
|
||||||
remoteClient.ConfigureHooks(s.conf.Hooks)
|
remoteClient.ConfigureHooks(s.conf.Hooks)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue