From cec45a416c40f3cae844f695ea9b39eeba7ec9f6 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sat, 4 Nov 2017 20:50:17 +0100 Subject: [PATCH] allow fast close on UDP session. fix #682 --- proxy/socks/server.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 3bef8f5c9..8bb2eeda9 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -90,19 +90,17 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa } if request.Command == protocol.RequestCommandUDP { - return s.handleUDP() + return s.handleUDP(conn) } return nil } -func (*Server) handleUDP() error { - // The TCP connection closes after v method returns. We need to wait until +func (*Server) handleUDP(c net.Conn) error { + // The TCP connection closes after this method returns. We need to wait until // the client closes it. - // TODO: get notified from UDP part - time.Sleep(5 * time.Minute) - - return nil + _, err := io.Copy(buf.DiscardBytes, c) + return err } func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writer, dest net.Destination, dispatcher dispatcher.Interface) error {