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

This commit is contained in:
gVisor bot 2022-05-16 23:34:27 +08:00
parent 27606d2ad2
commit 125f35e426

View File

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