Always disable cache for fake-ip servers

This commit is contained in:
dyhkwong 2024-04-28 18:43:27 +08:00 committed by 世界
parent 2ae192305c
commit d918863ac5
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
2 changed files with 1 additions and 3 deletions

View File

@ -69,7 +69,6 @@ type Router struct {
geositeCache map[string]adapter.Rule geositeCache map[string]adapter.Rule
needFindProcess bool needFindProcess bool
dnsClient *dns.Client dnsClient *dns.Client
dnsIndependentCache bool
defaultDomainStrategy dns.DomainStrategy defaultDomainStrategy dns.DomainStrategy
dnsRules []adapter.DNSRule dnsRules []adapter.DNSRule
ruleSets []adapter.RuleSet ruleSets []adapter.RuleSet
@ -123,7 +122,6 @@ func NewRouter(
geositeOptions: common.PtrValueOrDefault(options.Geosite), geositeOptions: common.PtrValueOrDefault(options.Geosite),
geositeCache: make(map[string]adapter.Rule), geositeCache: make(map[string]adapter.Rule),
needFindProcess: hasRule(options.Rules, isProcessRule) || hasDNSRule(dnsOptions.Rules, isProcessDNSRule) || options.FindProcess, needFindProcess: hasRule(options.Rules, isProcessRule) || hasDNSRule(dnsOptions.Rules, isProcessDNSRule) || options.FindProcess,
dnsIndependentCache: dnsOptions.IndependentCache,
defaultDetour: options.Final, defaultDetour: options.Final,
defaultDomainStrategy: dns.DomainStrategy(dnsOptions.Strategy), defaultDomainStrategy: dns.DomainStrategy(dnsOptions.Strategy),
interfaceFinder: control.NewDefaultInterfaceFinder(), interfaceFinder: control.NewDefaultInterfaceFinder(),

View File

@ -65,7 +65,7 @@ func (r *Router) matchDNS(ctx context.Context, allowFakeIP bool, index int) (con
displayRuleIndex += index + 1 displayRuleIndex += index + 1
} }
r.dnsLogger.DebugContext(ctx, "match[", displayRuleIndex, "] ", rule.String(), " => ", detour) r.dnsLogger.DebugContext(ctx, "match[", displayRuleIndex, "] ", rule.String(), " => ", detour)
if (isFakeIP && !r.dnsIndependentCache) || rule.DisableCache() { if isFakeIP || rule.DisableCache() {
ctx = dns.ContextWithDisableCache(ctx, true) ctx = dns.ContextWithDisableCache(ctx, true)
} }
if rewriteTTL := rule.RewriteTTL(); rewriteTTL != nil { if rewriteTTL := rule.RewriteTTL(); rewriteTTL != nil {