|
@@ -11,6 +11,7 @@ import (
|
|
|
C "github.com/sagernet/sing-box/constant"
|
|
|
"github.com/sagernet/sing-box/log"
|
|
|
"github.com/sagernet/sing-box/option"
|
|
|
+ "github.com/sagernet/sing-dns"
|
|
|
"github.com/sagernet/sing/common"
|
|
|
"github.com/sagernet/sing/common/buf"
|
|
|
"github.com/sagernet/sing/common/bufio"
|
|
@@ -74,7 +75,7 @@ func NewConnection(ctx context.Context, this N.Dialer, conn net.Conn, metadata a
|
|
|
return CopyEarlyConn(ctx, conn, outConn)
|
|
|
}
|
|
|
|
|
|
-func NewDirectConnection(ctx context.Context, router adapter.Router, this N.Dialer, conn net.Conn, metadata adapter.InboundContext) error {
|
|
|
+func NewDirectConnection(ctx context.Context, router adapter.Router, this N.Dialer, conn net.Conn, metadata adapter.InboundContext, domainStrategy dns.DomainStrategy) error {
|
|
|
ctx = adapter.WithContext(ctx, &metadata)
|
|
|
var outConn net.Conn
|
|
|
var err error
|
|
@@ -82,7 +83,7 @@ func NewDirectConnection(ctx context.Context, router adapter.Router, this N.Dial
|
|
|
outConn, err = N.DialSerial(ctx, this, N.NetworkTCP, metadata.Destination, metadata.DestinationAddresses)
|
|
|
} else if metadata.Destination.IsFqdn() {
|
|
|
var destinationAddresses []netip.Addr
|
|
|
- destinationAddresses, err = router.LookupDefault(ctx, metadata.Destination.Fqdn)
|
|
|
+ destinationAddresses, err = router.Lookup(ctx, metadata.Destination.Fqdn, domainStrategy)
|
|
|
if err != nil {
|
|
|
return N.ReportHandshakeFailure(conn, err)
|
|
|
}
|
|
@@ -133,7 +134,7 @@ func NewPacketConnection(ctx context.Context, this N.Dialer, conn N.PacketConn,
|
|
|
return bufio.CopyPacketConn(ctx, conn, bufio.NewPacketConn(outConn))
|
|
|
}
|
|
|
|
|
|
-func NewDirectPacketConnection(ctx context.Context, router adapter.Router, this N.Dialer, conn N.PacketConn, metadata adapter.InboundContext) error {
|
|
|
+func NewDirectPacketConnection(ctx context.Context, router adapter.Router, this N.Dialer, conn N.PacketConn, metadata adapter.InboundContext, domainStrategy dns.DomainStrategy) error {
|
|
|
ctx = adapter.WithContext(ctx, &metadata)
|
|
|
var outConn net.PacketConn
|
|
|
var destinationAddress netip.Addr
|
|
@@ -142,7 +143,7 @@ func NewDirectPacketConnection(ctx context.Context, router adapter.Router, this
|
|
|
outConn, destinationAddress, err = N.ListenSerial(ctx, this, metadata.Destination, metadata.DestinationAddresses)
|
|
|
} else if metadata.Destination.IsFqdn() {
|
|
|
var destinationAddresses []netip.Addr
|
|
|
- destinationAddresses, err = router.LookupDefault(ctx, metadata.Destination.Fqdn)
|
|
|
+ destinationAddresses, err = router.Lookup(ctx, metadata.Destination.Fqdn, domainStrategy)
|
|
|
if err != nil {
|
|
|
return N.ReportHandshakeFailure(conn, err)
|
|
|
}
|