mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-04 10:17:30 +03:00
Fix DNS lookup
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -66,7 +67,17 @@ func (m *ConnectionManager) NewConnection(ctx context.Context, this N.Dialer, co
|
||||
remoteConn, err = this.DialContext(ctx, N.NetworkTCP, metadata.Destination)
|
||||
}
|
||||
if err != nil {
|
||||
err = E.Cause(err, "open outbound connection")
|
||||
var remoteString string
|
||||
if len(metadata.DestinationAddresses) > 0 {
|
||||
remoteString = "[" + strings.Join(common.Map(metadata.DestinationAddresses, netip.Addr.String), ",") + "]"
|
||||
} else {
|
||||
remoteString = metadata.Destination.String()
|
||||
}
|
||||
var dialerString string
|
||||
if outbound, isOutbound := this.(adapter.Outbound); isOutbound {
|
||||
dialerString = " using outbound/" + outbound.Type() + "[" + outbound.Tag() + "]"
|
||||
}
|
||||
err = E.Cause(err, "open connection to ", remoteString, dialerString)
|
||||
N.CloseOnHandshakeFailure(conn, onClose, err)
|
||||
m.logger.ErrorContext(ctx, err)
|
||||
return
|
||||
@@ -133,8 +144,19 @@ func (m *ConnectionManager) NewPacketConnection(ctx context.Context, this N.Dial
|
||||
remoteConn, err = this.DialContext(ctx, N.NetworkUDP, metadata.Destination)
|
||||
}
|
||||
if err != nil {
|
||||
var remoteString string
|
||||
if len(metadata.DestinationAddresses) > 0 {
|
||||
remoteString = "[" + strings.Join(common.Map(metadata.DestinationAddresses, netip.Addr.String), ",") + "]"
|
||||
} else {
|
||||
remoteString = metadata.Destination.String()
|
||||
}
|
||||
var dialerString string
|
||||
if outbound, isOutbound := this.(adapter.Outbound); isOutbound {
|
||||
dialerString = " using outbound/" + outbound.Type() + "[" + outbound.Tag() + "]"
|
||||
}
|
||||
err = E.Cause(err, "open packet connection to ", remoteString, dialerString)
|
||||
N.CloseOnHandshakeFailure(conn, onClose, err)
|
||||
m.logger.ErrorContext(ctx, "open outbound packet connection: ", err)
|
||||
m.logger.ErrorContext(ctx, err)
|
||||
return
|
||||
}
|
||||
remotePacketConn = bufio.NewUnbindPacketConn(remoteConn)
|
||||
@@ -149,8 +171,13 @@ func (m *ConnectionManager) NewPacketConnection(ctx context.Context, this N.Dial
|
||||
remotePacketConn, err = this.ListenPacket(ctx, metadata.Destination)
|
||||
}
|
||||
if err != nil {
|
||||
var dialerString string
|
||||
if outbound, isOutbound := this.(adapter.Outbound); isOutbound {
|
||||
dialerString = " using outbound/" + outbound.Type() + "[" + outbound.Tag() + "]"
|
||||
}
|
||||
err = E.Cause(err, "listen packet connection using ", dialerString)
|
||||
N.CloseOnHandshakeFailure(conn, onClose, err)
|
||||
m.logger.ErrorContext(ctx, "listen outbound packet connection: ", err)
|
||||
m.logger.ErrorContext(ctx, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user