Procházet zdrojové kódy

feat: use goroutines to process connections

AkinoKaede před 2 roky
rodič
revize
c439a12d06
2 změnil soubory, kde provedl 2 přidání a 2 odebrání
  1. 1 1
      app/tun/handler_tcp.go
  2. 1 1
      app/tun/handler_udp.go

+ 1 - 1
app/tun/handler_tcp.go

@@ -67,7 +67,7 @@ func SetTCPHandler(ctx context.Context, dispatcher routing.Dispatcher, policyMan
 				config:        config,
 			}
 
-			handler.Handle(conn)
+			go handler.Handle(conn)
 		})
 
 		s.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket)

+ 1 - 1
app/tun/handler_udp.go

@@ -57,7 +57,7 @@ func SetUDPHandler(ctx context.Context, dispatcher routing.Dispatcher, policyMan
 				policyManager: policyManager,
 				config:        config,
 			}
-			handler.Handle(conn)
+			go handler.Handle(conn)
 		})
 		s.SetTransportProtocolHandler(gvisor_udp.ProtocolNumber, udpForwarder.HandlePacket)
 		return nil