Browse Source

TUN inbound: Close connection when handling is done (#5531)

https://github.com/XTLS/Xray-core/pull/5531#issuecomment-3744446015
Owersun 1 month ago
parent
commit
ef2a967f12
1 changed files with 4 additions and 0 deletions
  1. 4 0
      proxy/tun/handler.go

+ 4 - 0
proxy/tun/handler.go

@@ -102,6 +102,10 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin
 
 
 // HandleConnection pass the connection coming from the ip stack to the routing dispatcher
 // HandleConnection pass the connection coming from the ip stack to the routing dispatcher
 func (t *Handler) HandleConnection(conn net.Conn, destination net.Destination) {
 func (t *Handler) HandleConnection(conn net.Conn, destination net.Destination) {
+	// when handling is done with any outcome, always signal back to the incoming connection
+	// to close, send completion packets back to the network, and cleanup
+	defer conn.Close()
+
 	sid := session.NewID()
 	sid := session.NewID()
 	ctx := c.ContextWithID(t.ctx, sid)
 	ctx := c.ContextWithID(t.ctx, sid)