@@ -76,17 +76,16 @@ func (t *GVisor) Start() error {
7676 return err
7777 }
7878 tcpForwarder := tcp .NewForwarder (ipStack , 0 , 1024 , func (r * tcp.ForwarderRequest ) {
79- var metadata M.Metadata
80- metadata .Source = M .SocksaddrFrom (AddrFromAddress (r .ID ().RemoteAddress ), r .ID ().RemotePort )
81- metadata .Destination = M .SocksaddrFrom (AddrFromAddress (r .ID ().LocalAddress ), r .ID ().LocalPort )
79+ source := M .SocksaddrFrom (AddrFromAddress (r .ID ().RemoteAddress ), r .ID ().RemotePort )
80+ destination := M .SocksaddrFrom (AddrFromAddress (r .ID ().LocalAddress ), r .ID ().LocalPort )
8281 conn := & gLazyConn {
8382 parentCtx : t .ctx ,
8483 stack : t .stack ,
8584 request : r ,
86- localAddr : metadata . Source .TCPAddr (),
87- remoteAddr : metadata . Destination .TCPAddr (),
85+ localAddr : source .TCPAddr (),
86+ remoteAddr : destination .TCPAddr (),
8887 }
89- _ = t .handler .NewConnection (t .ctx , conn , metadata )
88+ go t .handler .NewConnectionEx (t .ctx , conn , source , destination , nil )
9089 })
9190 ipStack .SetTransportProtocolHandler (tcp .ProtocolNumber , tcpForwarder .HandlePacket )
9291 if ! t .endpointIndependentNat {
@@ -104,14 +103,10 @@ func (t *GVisor) Start() error {
104103 return
105104 }
106105 go func () {
107- var metadata M.Metadata
108- metadata .Source = M .SocksaddrFromNet (lAddr )
109- metadata .Destination = M .SocksaddrFromNet (rAddr )
110- ctx , conn := canceler .NewPacketConn (t .ctx , bufio .NewUnbindPacketConnWithAddr (udpConn , metadata .Destination ), time .Duration (t .udpTimeout )* time .Second )
111- hErr := t .handler .NewPacketConnection (ctx , conn , metadata )
112- if hErr != nil {
113- endpoint .Abort ()
114- }
106+ source := M .SocksaddrFromNet (lAddr )
107+ destination := M .SocksaddrFromNet (rAddr )
108+ ctx , conn := canceler .NewPacketConn (t .ctx , bufio .NewUnbindPacketConnWithAddr (udpConn , destination ), time .Duration (t .udpTimeout )* time .Second )
109+ t .handler .NewPacketConnectionEx (ctx , conn , source , destination , nil )
115110 }()
116111 })
117112 ipStack .SetTransportProtocolHandler (udp .ProtocolNumber , udpForwarder .HandlePacket )
0 commit comments