fix: 当dns被禁用时,dns将根据general ipv6设置解析dns

This commit is contained in:
Skyxim 2022-05-16 23:34:27 +08:00 committed by Skyxim
parent b831eb178b
commit 891c2fe899

View File

@ -79,7 +79,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
updateSniffer(cfg.Sniffer) updateSniffer(cfg.Sniffer)
updateHosts(cfg.Hosts) updateHosts(cfg.Hosts)
initInnerTcp() initInnerTcp()
updateDNS(cfg.DNS) updateDNS(cfg.DNS, cfg.General.IPv6)
loadProxyProvider(cfg.Providers) loadProxyProvider(cfg.Providers)
updateProfile(cfg) updateProfile(cfg)
loadRuleProvider(cfg.RuleProviders) loadRuleProvider(cfg.RuleProviders)
@ -125,13 +125,16 @@ func GetGeneral() *config.General {
func updateExperimental(c *config.Config) {} func updateExperimental(c *config.Config) {}
func updateDNS(c *config.DNS) { func updateDNS(c *config.DNS, generalIPv6 bool) {
if !c.Enable { if !c.Enable {
resolver.DisableIPv6 = !generalIPv6
resolver.DefaultResolver = nil resolver.DefaultResolver = nil
resolver.DefaultHostMapper = nil resolver.DefaultHostMapper = nil
resolver.DefaultLocalServer = nil resolver.DefaultLocalServer = nil
dns.ReCreateServer("", nil, nil) dns.ReCreateServer("", nil, nil)
return return
} else {
resolver.DisableIPv6 = !c.IPv6
} }
cfg := dns.Config{ cfg := dns.Config{
@ -153,8 +156,6 @@ func updateDNS(c *config.DNS) {
ProxyServer: c.ProxyServerNameserver, ProxyServer: c.ProxyServerNameserver,
} }
resolver.DisableIPv6 = !cfg.IPv6
r := dns.NewResolver(cfg) r := dns.NewResolver(cfg)
pr := dns.NewProxyServerHostResolver(r) pr := dns.NewProxyServerHostResolver(r)
m := dns.NewEnhancer(cfg) m := dns.NewEnhancer(cfg)