Refactor dialer

This commit is contained in:
世界 2022-07-01 13:30:04 +08:00
parent 719a27fc42
commit e85528b42f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 16 additions and 18 deletions

View file

@ -217,11 +217,14 @@ func HandleConnection0(ctx context.Context, conn net.Conn, version byte, authent
metadata.Protocol = "socks5"
metadata.Destination = request.Destination
var innerError error
done := make(chan struct{})
go func() {
defer conn.Close()
innerError = handler.NewPacketConnection(ctx, NewAssociatePacketConn(udpConn, request.Destination, conn), metadata)
close(done)
}()
return common.AnyError(innerError, common.Error(io.Copy(io.Discard, conn)))
err = common.Error(io.Copy(io.Discard, conn))
return common.AnyError(innerError, err)
default:
err = socks5.WriteResponse(conn, socks5.Response{
ReplyCode: socks5.ReplyCodeUnsupported,