Close endpoint only if err return

This commit is contained in:
世界 2022-08-03 10:24:24 +08:00
parent 2895f49fd2
commit 9b2841f33d
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -127,8 +127,10 @@ func (t *GVisorTun) Start() error {
var metadata M.Metadata
metadata.Source = M.SocksaddrFromNet(lAddr)
metadata.Destination = M.SocksaddrFromNet(rAddr)
t.handler.NewConnection(t.ctx, &gTCPConn{tcpConn}, metadata)
endpoint.Abort()
hErr := t.handler.NewConnection(t.ctx, &gTCPConn{tcpConn}, metadata)
if hErr != nil {
endpoint.Abort()
}
}()
}).HandlePacket)
@ -150,8 +152,10 @@ func (t *GVisorTun) Start() error {
var metadata M.Metadata
metadata.Source = M.SocksaddrFromNet(lAddr)
metadata.Destination = M.SocksaddrFromNet(rAddr)
t.handler.NewPacketConnection(ContextWithNeedTimeout(t.ctx, true), bufio.NewPacketConn(&bufio.UnbindPacketConn{ExtendedConn: bufio.NewExtendedConn(&gUDPConn{udpConn}), Addr: M.SocksaddrFromNet(rAddr)}), metadata)
endpoint.Abort()
hErr := t.handler.NewPacketConnection(ContextWithNeedTimeout(t.ctx, true), bufio.NewPacketConn(&bufio.UnbindPacketConn{ExtendedConn: bufio.NewExtendedConn(&gUDPConn{udpConn}), Addr: M.SocksaddrFromNet(rAddr)}), metadata)
if hErr != nil {
endpoint.Abort()
}
}()
}).HandlePacket)
} else {