mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-04-03 03:47:39 +03:00
Close endpoint only if err return
This commit is contained in:
parent
2895f49fd2
commit
9b2841f33d
1 changed files with 8 additions and 4 deletions
12
gvisor.go
12
gvisor.go
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue