diff --git a/component/routing/optimizer.go b/component/routing/optimizer.go index 8ae1a07..c0de779 100644 --- a/component/routing/optimizer.go +++ b/component/routing/optimizer.go @@ -167,11 +167,26 @@ func (o *DatReaderOptimizer) loadGeoSite(filename string, code string) (params [ return nil, err } o.Logger.Debugf("Read geosite \"%v:%v\" from %v", filename, code, filePath) + code, attr, _ := strings.Cut(code, "@") geoSite, err := geodata.UnmarshalGeoSite(o.Logger, filePath, code) if err != nil { return nil, err } for _, item := range geoSite.Domain { + if attr != "" { + // Filter by attr. + attrHit := false + for _, itemAttr := range item.Attribute { + if strings.EqualFold(itemAttr.Key, attr) { + attrHit = true + break + } + } + if !attrHit { + continue + } + } + switch item.Type { case geodata.Domain_Full: // Full. diff --git a/docs/dns.md b/docs/dns.md index a121db6..ac47b35 100644 --- a/docs/dns.md +++ b/docs/dns.md @@ -33,6 +33,7 @@ dns { # DNS request name (omit suffix dot '.'). qname(geosite:category-ads-all) -> reject + qname(geosite:google@cn) -> alidns # Also see: https://github.com/v2ray/domain-list-community#attributes qname(suffix: abc.com, keyword: google) -> googledns qname(full: ok.com, regex: '^yes') -> googledns # DNS request type