mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-22 02:07:50 +07:00
feat: support geosite attr (#98)
This commit is contained in:
parent
9e20a7fff6
commit
2a8f8f9010
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user