mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
Refactor dialer
This commit is contained in:
parent
719a27fc42
commit
e85528b42f
3 changed files with 16 additions and 18 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue