mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-04-04 20:37:43 +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
|
var metadata M.Metadata
|
||||||
metadata.Source = M.SocksaddrFromNet(lAddr)
|
metadata.Source = M.SocksaddrFromNet(lAddr)
|
||||||
metadata.Destination = M.SocksaddrFromNet(rAddr)
|
metadata.Destination = M.SocksaddrFromNet(rAddr)
|
||||||
t.handler.NewConnection(t.ctx, &gTCPConn{tcpConn}, metadata)
|
hErr := t.handler.NewConnection(t.ctx, &gTCPConn{tcpConn}, metadata)
|
||||||
endpoint.Abort()
|
if hErr != nil {
|
||||||
|
endpoint.Abort()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}).HandlePacket)
|
}).HandlePacket)
|
||||||
|
|
||||||
|
@ -150,8 +152,10 @@ func (t *GVisorTun) Start() error {
|
||||||
var metadata M.Metadata
|
var metadata M.Metadata
|
||||||
metadata.Source = M.SocksaddrFromNet(lAddr)
|
metadata.Source = M.SocksaddrFromNet(lAddr)
|
||||||
metadata.Destination = M.SocksaddrFromNet(rAddr)
|
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)
|
hErr := t.handler.NewPacketConnection(ContextWithNeedTimeout(t.ctx, true), bufio.NewPacketConn(&bufio.UnbindPacketConn{ExtendedConn: bufio.NewExtendedConn(&gUDPConn{udpConn}), Addr: M.SocksaddrFromNet(rAddr)}), metadata)
|
||||||
endpoint.Abort()
|
if hErr != nil {
|
||||||
|
endpoint.Abort()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}).HandlePacket)
|
}).HandlePacket)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue