Update network handler usages

This commit is contained in:
世界 2024-10-20 13:42:53 +08:00
parent a8ae222eeb
commit 99eea00432
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
12 changed files with 51 additions and 78 deletions

View file

@ -64,14 +64,10 @@ func (m *Mixed) Start() error {
return
}
go func() {
var metadata M.Metadata
metadata.Source = M.SocksaddrFromNet(lAddr)
metadata.Destination = M.SocksaddrFromNet(rAddr)
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()
}
source := M.SocksaddrFromNet(lAddr)
destination := M.SocksaddrFromNet(rAddr)
ctx, conn := canceler.NewPacketConn(m.ctx, bufio.NewUnbindPacketConnWithAddr(udpConn, destination), time.Duration(m.udpTimeout)*time.Second)
m.handler.NewPacketConnectionEx(ctx, conn, source, destination, nil)
}()
})
ipStack.SetTransportProtocolHandler(udp.ProtocolNumber, udpForwarder.HandlePacket)