mirror of
https://github.com/v2fly/domain-list-community.git
synced 2026-01-05 14:23:58 +07:00
Remove support for partial include
This reverts e640ac2783
It is problematic and I will implement a new one
This commit is contained in:
73
main.go
73
main.go
@@ -191,43 +191,6 @@ func Load(path string) (*List, error) {
|
|||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMatchAttr(Attrs []string, includeKey string) bool {
|
|
||||||
isMatch := false
|
|
||||||
mustMatch := true
|
|
||||||
matchName := includeKey
|
|
||||||
if strings.HasPrefix(includeKey, "!") {
|
|
||||||
isMatch = true
|
|
||||||
mustMatch = false
|
|
||||||
matchName = strings.TrimLeft(includeKey, "!")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, Attr := range Attrs {
|
|
||||||
if mustMatch {
|
|
||||||
if matchName == Attr {
|
|
||||||
isMatch = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if matchName == Attr {
|
|
||||||
isMatch = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isMatch
|
|
||||||
}
|
|
||||||
|
|
||||||
func createIncludeAttrEntrys(list *List, matchAttr string) []Entry {
|
|
||||||
newEntryList := make([]Entry, 0, len(list.Entry))
|
|
||||||
for _, entry := range list.Entry {
|
|
||||||
matched := isMatchAttr(entry.Attrs, matchAttr)
|
|
||||||
if matched {
|
|
||||||
newEntryList = append(newEntryList, entry)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newEntryList
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
||||||
pl := &ParsedList{
|
pl := &ParsedList{
|
||||||
Name: list.Name,
|
Name: list.Name,
|
||||||
@@ -240,35 +203,15 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
|||||||
for _, entry := range entryList {
|
for _, entry := range entryList {
|
||||||
if entry.Type == RuleTypeInclude {
|
if entry.Type == RuleTypeInclude {
|
||||||
refName := strings.ToUpper(entry.Value)
|
refName := strings.ToUpper(entry.Value)
|
||||||
if entry.Attrs != nil {
|
if pl.Inclusion[refName] {
|
||||||
for _, attr := range entry.Attrs {
|
continue
|
||||||
InclusionName := strings.ToUpper(refName + "@" + attr)
|
|
||||||
if pl.Inclusion[InclusionName] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pl.Inclusion[InclusionName] = true
|
|
||||||
|
|
||||||
refList := ref[refName]
|
|
||||||
if refList == nil {
|
|
||||||
return nil, fmt.Errorf("list not found: %s", entry.Value)
|
|
||||||
}
|
|
||||||
attrEntrys := createIncludeAttrEntrys(refList, attr)
|
|
||||||
if len(attrEntrys) != 0 {
|
|
||||||
newEntryList = append(newEntryList, attrEntrys...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
InclusionName := refName
|
|
||||||
if pl.Inclusion[InclusionName] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pl.Inclusion[InclusionName] = true
|
|
||||||
refList := ref[refName]
|
|
||||||
if refList == nil {
|
|
||||||
return nil, fmt.Errorf("list not found: %s", entry.Value)
|
|
||||||
}
|
|
||||||
newEntryList = append(newEntryList, refList.Entry...)
|
|
||||||
}
|
}
|
||||||
|
pl.Inclusion[refName] = true
|
||||||
|
refList := ref[refName]
|
||||||
|
if refList == nil {
|
||||||
|
return nil, fmt.Errorf("list not found: %s", entry.Value)
|
||||||
|
}
|
||||||
|
newEntryList = append(newEntryList, refList.Entry...)
|
||||||
hasInclude = true
|
hasInclude = true
|
||||||
} else {
|
} else {
|
||||||
newEntryList = append(newEntryList, entry)
|
newEntryList = append(newEntryList, entry)
|
||||||
|
|||||||
Reference in New Issue
Block a user