Add lazy conn support for gVisor

This commit is contained in:
世界 2024-10-19 15:02:25 +08:00
parent f8191b7dc0
commit a8ae222eeb
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 242 additions and 160 deletions

View file

@ -63,12 +63,11 @@ func (m *Mixed) Start() error {
endpoint.Abort()
return
}
gConn := &gUDPConn{UDPConn: udpConn}
go func() {
var metadata M.Metadata
metadata.Source = M.SocksaddrFromNet(lAddr)
metadata.Destination = M.SocksaddrFromNet(rAddr)
ctx, conn := canceler.NewPacketConn(m.ctx, bufio.NewUnbindPacketConnWithAddr(gConn, metadata.Destination), time.Duration(m.udpTimeout)*time.Second)
ctx, conn := canceler.NewPacketConn(m.ctx, bufio.NewUnbindPacketConnWithAddr(udpConn, metadata.Destination), time.Duration(m.udpTimeout)*time.Second)
hErr := m.handler.NewPacketConnection(ctx, conn, metadata)
if hErr != nil {
endpoint.Abort()