fix: let input prefix to lower case when parsing. Fix #868
This commit is contained in:
parent
2d73bcb951
commit
ee6b974c18
2 changed files with 11 additions and 7 deletions
|
@ -1114,7 +1114,7 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro
|
||||||
|
|
||||||
for pair := nsPolicy.Oldest(); pair != nil; pair = pair.Next() {
|
for pair := nsPolicy.Oldest(); pair != nil; pair = pair.Next() {
|
||||||
k, v := pair.Key, pair.Value
|
k, v := pair.Key, pair.Value
|
||||||
if strings.Contains(k, ",") {
|
if strings.Contains(strings.ToLower(k), ",") {
|
||||||
if strings.Contains(k, "geosite:") {
|
if strings.Contains(k, "geosite:") {
|
||||||
subkeys := strings.Split(k, ":")
|
subkeys := strings.Split(k, ":")
|
||||||
subkeys = subkeys[1:]
|
subkeys = subkeys[1:]
|
||||||
|
@ -1123,7 +1123,7 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro
|
||||||
newKey := "geosite:" + subkey
|
newKey := "geosite:" + subkey
|
||||||
updatedPolicy.Store(newKey, v)
|
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 := strings.Split(k, ":")
|
||||||
subkeys = subkeys[1:]
|
subkeys = subkeys[1:]
|
||||||
subkeys = strings.Split(subkeys[0], ",")
|
subkeys = strings.Split(subkeys[0], ",")
|
||||||
|
@ -1138,6 +1138,11 @@ func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], rulePro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
updatedPolicy.Store(k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,22 +493,21 @@ func NewResolver(config Config) *Resolver {
|
||||||
|
|
||||||
for pair := config.Policy.Oldest(); pair != nil; pair = pair.Next() {
|
for pair := config.Policy.Oldest(); pair != nil; pair = pair.Next() {
|
||||||
domain, nameserver := pair.Key, pair.Value
|
domain, nameserver := pair.Key, pair.Value
|
||||||
domain = strings.ToLower(domain)
|
|
||||||
|
|
||||||
if temp := strings.Split(domain, ":"); len(temp) == 2 {
|
if temp := strings.Split(domain, ":"); len(temp) == 2 {
|
||||||
prefix := temp[0]
|
prefix := temp[0]
|
||||||
key := temp[1]
|
key := temp[1]
|
||||||
switch strings.ToLower(prefix) {
|
switch prefix {
|
||||||
case "rule-set":
|
case "rule-set":
|
||||||
if p, ok := config.RuleProviders[key]; ok {
|
if p, ok := config.RuleProviders[key]; ok {
|
||||||
insertTriePolicy()
|
log.Debugln("Adding rule-set policy: %s ", key)
|
||||||
r.policy = append(r.policy, domainSetPolicy{
|
r.policy = append(r.policy, domainSetPolicy{
|
||||||
domainSetProvider: p,
|
domainSetProvider: p,
|
||||||
dnsClients: cacheTransform(nameserver),
|
dnsClients: cacheTransform(nameserver),
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Warnln("can't found ruleset policy: %s", key)
|
log.Warnln("Can't found ruleset policy: %s", key)
|
||||||
}
|
}
|
||||||
case "geosite":
|
case "geosite":
|
||||||
inverse := false
|
inverse := false
|
||||||
|
@ -516,7 +515,7 @@ func NewResolver(config Config) *Resolver {
|
||||||
inverse = true
|
inverse = true
|
||||||
key = key[1:]
|
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)
|
matcher, err := NewGeoSite(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnln("adding geosite policy %s error: %s", key, err)
|
log.Warnln("adding geosite policy %s error: %s", key, err)
|
||||||
|
|
Loading…
Reference in a new issue