chore: clean up code
This commit is contained in:
parent
2fef00d2a8
commit
f4251e58a5
1 changed files with 14 additions and 17 deletions
|
@ -989,30 +989,27 @@ func parseNameServerPolicy(nsPolicy map[string]any, preferH3 bool) (map[string][
|
||||||
re := regexp.MustCompile(`[a-zA-Z0-9\-]+\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?`)
|
re := regexp.MustCompile(`[a-zA-Z0-9\-]+\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?`)
|
||||||
|
|
||||||
for k, v := range nsPolicy {
|
for k, v := range nsPolicy {
|
||||||
if strings.Contains(k, "geosite:") {
|
if strings.Contains(k, ",") {
|
||||||
subkeys := strings.Split(k, ":")
|
if strings.Contains(k, "geosite:") {
|
||||||
subkeys = subkeys[1:]
|
subkeys := strings.Split(k, ":")
|
||||||
subkeys = strings.Split(subkeys[0], ",")
|
subkeys = subkeys[1:]
|
||||||
//log.Infoln("subkeys:%+v", subkeys)
|
subkeys = strings.Split(subkeys[0], ",")
|
||||||
for _, subkey := range subkeys {
|
for _, subkey := range subkeys {
|
||||||
newKey := "geosite:" + subkey
|
newKey := "geosite:" + subkey
|
||||||
//log.Infoln("newKey:%+v", newKey)
|
updatedPolicy[newKey] = v
|
||||||
updatedPolicy[newKey] = v
|
}
|
||||||
}
|
} else if re.MatchString(k) {
|
||||||
} else if re.MatchString(k) {
|
subkeys := strings.Split(k, ",")
|
||||||
subkeys := strings.Split(k, ",")
|
for _, subkey := range subkeys {
|
||||||
//log.Infoln("subkeys:%+v", subkeys)
|
updatedPolicy[subkey] = v
|
||||||
for _, subkey := range subkeys {
|
}
|
||||||
updatedPolicy[subkey] = v
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updatedPolicy[k] = v
|
updatedPolicy[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log.Infoln("updatedPolicy:%+v", updatedPolicy)
|
|
||||||
|
|
||||||
for domain, server := range updatedPolicy {
|
for domain, server := range updatedPolicy {
|
||||||
|
|
||||||
servers, err := utils.ToStringSlice(server)
|
servers, err := utils.ToStringSlice(server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue