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
|
GeoIPCode string
|
||||||
ProcessInfo *process.Info
|
ProcessInfo *process.Info
|
||||||
FakeIP bool
|
FakeIP bool
|
||||||
|
IsFromDnsOutbound bool
|
||||||
|
|
||||||
// dns cache
|
// dns cache
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ func (d *DNS) handleConnection(ctx context.Context, conn net.Conn, metadata adap
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
metadataInQuery := metadata
|
metadataInQuery := metadata
|
||||||
|
metadataInQuery.IsFromDnsOutbound = true
|
||||||
go func() error {
|
go func() error {
|
||||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -157,6 +158,7 @@ func (d *DNS) NewPacketConnection(ctx context.Context, conn N.PacketConn, metada
|
|||||||
timeout.Update()
|
timeout.Update()
|
||||||
}
|
}
|
||||||
metadataInQuery := metadata
|
metadataInQuery := metadata
|
||||||
|
metadataInQuery.IsFromDnsOutbound = true
|
||||||
go func() error {
|
go func() error {
|
||||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -235,6 +237,7 @@ func (d *DNS) newPacketConnection(ctx context.Context, conn N.PacketConn, readWa
|
|||||||
timeout.Update()
|
timeout.Update()
|
||||||
}
|
}
|
||||||
metadataInQuery := metadata
|
metadataInQuery := metadata
|
||||||
|
metadataInQuery.IsFromDnsOutbound = true
|
||||||
go func() error {
|
go func() error {
|
||||||
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
response, err := d.router.Exchange(adapter.WithContext(ctx, &metadataInQuery), &message)
|
||||||
if err != nil {
|
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)
|
r.dnsLogger.ErrorContext(ctx, "transport not found: ", detour)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, isFakeIP := transport.(adapter.FakeIPTransport); isFakeIP && metadata.FakeIP {
|
if _, isFakeIP := transport.(adapter.FakeIPTransport); isFakeIP && !metadata.IsFromDnsOutbound {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
r.dnsLogger.DebugContext(ctx, "match[", i, "] ", rule.String(), " => ", detour)
|
r.dnsLogger.DebugContext(ctx, "match[", i, "] ", rule.String(), " => ", detour)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user