Browse Source

feat: use goroutines to process connections

AkinoKaede 2 years ago
parent
commit
c439a12d06
2 changed files with 2 additions and 2 deletions
  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