mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Fix response fakeip when routing
This commit is contained in:
parent
bc4545f2ef
commit
b29e7e181b
@ -47,6 +47,7 @@ type InboundContext struct {
|
||||
GeoIPCode string
|
||||
ProcessInfo *process.Info
|
||||
FakeIP bool
|
||||
IsFromDnsOutbound bool
|
||||
|
||||
// dns cache
|
||||
|
||||
|
@ -77,6 +77,7 @@ func (d *DNS) handleConnection(ctx context.Context, conn net.Conn, metadata adap
|
||||
return err
|
||||
}
|
||||
metadataInQuery := metadata
|
||||
metadataInQuery.IsFromDnsOutbound = true
|
||||
go func() error {
|
||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||
if err != nil {
|
||||
@ -157,6 +158,7 @@ func (d *DNS) NewPacketConnection(ctx context.Context, conn N.PacketConn, metada
|
||||
timeout.Update()
|
||||
}
|
||||
metadataInQuery := metadata
|
||||
metadataInQuery.IsFromDnsOutbound = true
|
||||
go func() error {
|
||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||
if err != nil {
|
||||
@ -235,6 +237,7 @@ func (d *DNS) newPacketConnection(ctx context.Context, conn N.PacketConn, readWa
|
||||
timeout.Update()
|
||||
}
|
||||
metadataInQuery := metadata
|
||||
metadataInQuery.IsFromDnsOutbound = true
|
||||
go func() error {
|
||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||
if err != nil {
|
||||
|
@ -50,7 +50,7 @@ func (r *Router) matchDNS(ctx context.Context) (context.Context, dns.Transport,
|
||||
r.dnsLogger.ErrorContext(ctx, "transport not found: ", detour)
|
||||
continue
|
||||
}
|
||||
if _, isFakeIP := transport.(adapter.FakeIPTransport); isFakeIP && metadata.FakeIP {
|
||||
if _, isFakeIP := transport.(adapter.FakeIPTransport); isFakeIP && !metadata.IsFromDnsOutbound {
|
||||
continue
|
||||
}
|
||||
r.dnsLogger.DebugContext(ctx, "match[", i, "] ", rule.String(), " => ", detour)
|
||||
|
Loading…
x
Reference in New Issue
Block a user