Skip to content

Commit e29eff1

Browse files
authored
Fix socks udp behavior
1 parent 1fa58a8 commit e29eff1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

protocol/socks/handshake.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ func HandleConnection0(ctx context.Context, conn net.Conn, version byte, authent
206206
metadata.Destination = request.Destination
207207
var innerError error
208208
done := make(chan struct{})
209+
associatePacketConn := NewAssociatePacketConn(udpConn, request.Destination, conn)
209210
go func() {
210-
defer conn.Close()
211-
innerError = handler.NewPacketConnection(ctx, NewAssociatePacketConn(udpConn, request.Destination, conn), metadata)
211+
innerError = handler.NewPacketConnection(ctx, associatePacketConn, metadata)
212212
close(done)
213213
}()
214214
err = common.Error(io.Copy(io.Discard, conn))
215+
associatePacketConn.Close()
215216
<-done
216217
return E.Errors(innerError, err)
217218
default:

0 commit comments

Comments
 (0)