Merge branch 'raymaster' into flymaster

pull/2141/head
vcptr 2019-11-19 14:00:46 +08:00
commit 3c3a828e3b
1 changed files with 18 additions and 0 deletions

View File

@ -178,6 +178,24 @@ func (c *DnsConfig) Build() (*dns.Config, error) {
mapping.Domain = domain[5:]
mappings = append(mappings, mapping)
} else if strings.HasPrefix(domain, "ext:") {
kv := strings.Split(domain[4:], ":")
if len(kv) != 2 {
return nil, newError("invalid external resource: ", domain)
}
filename := kv[0]
country := kv[1]
domains, err := loadGeositeWithAttr(filename, country)
if err != nil {
return nil, newError("failed to load domains: ", country, " from ", filename).Base(err)
}
for _, d := range domains {
mapping := getHostMapping(addr)
mapping.Type = typeMap[d.Type]
mapping.Domain = d.Value
mappings = append(mappings, mapping)
}
} else {
mapping := getHostMapping(addr)
mapping.Type = dns.DomainMatchingType_Full