diff --git a/config/config.go b/config/config.go index 45c4cfdb..665b8539 100644 --- a/config/config.go +++ b/config/config.go @@ -1114,7 +1114,7 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro for pair := nsPolicy.Oldest(); pair != nil; pair = pair.Next() { k, v := pair.Key, pair.Value - if strings.Contains(k, ",") { + if strings.Contains(strings.ToLower(k), ",") { if strings.Contains(k, "geosite:") { subkeys := strings.Split(k, ":") subkeys = subkeys[1:] @@ -1123,7 +1123,7 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro newKey := "geosite:" + subkey updatedPolicy.Store(newKey, v) } - } else if strings.Contains(k, "rule-set:") { + } else if strings.Contains(strings.ToLower(k), "rule-set:") { subkeys := strings.Split(k, ":") subkeys = subkeys[1:] subkeys = strings.Split(subkeys[0], ",") @@ -1138,6 +1138,11 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro } } } else { + if strings.Contains(strings.ToLower(k), "geosite:") { + updatedPolicy.Store("geosite:"+k[8:], v) + } else if strings.Contains(strings.ToLower(k), "rule-set:") { + updatedPolicy.Store("rule-set:"+k[9:], v) + } updatedPolicy.Store(k, v) } } diff --git a/dns/resolver.go b/dns/resolver.go index e1ca95dd..0f2873f0 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -493,22 +493,21 @@ func NewResolver(config Config) *Resolver { for pair := config.Policy.Oldest(); pair != nil; pair = pair.Next() { domain, nameserver := pair.Key, pair.Value - domain = strings.ToLower(domain) if temp := strings.Split(domain, ":"); len(temp) == 2 { prefix := temp[0] key := temp[1] - switch strings.ToLower(prefix) { + switch prefix { case "rule-set": if p, ok := config.RuleProviders[key]; ok { - insertTriePolicy() + log.Debugln("Adding rule-set policy: %s ", key) r.policy = append(r.policy, domainSetPolicy{ domainSetProvider: p, dnsClients: cacheTransform(nameserver), }) continue } else { - log.Warnln("can't found ruleset policy: %s", key) + log.Warnln("Can't found ruleset policy: %s", key) } case "geosite": inverse := false @@ -516,7 +515,7 @@ func NewResolver(config Config) *Resolver { inverse = true key = key[1:] } - log.Debugln("adding geosite policy: %s inversed %t", key, inverse) + log.Debugln("Adding geosite policy: %s inversed %t", key, inverse) matcher, err := NewGeoSite(key) if err != nil { log.Warnln("adding geosite policy %s error: %s", key, err)