feat: nameserver-policy support use rule-providers and reduce domain-set memory

This commit is contained in:
Skyxim
2023-04-01 11:53:39 +08:00
parent 991de009be
commit cfd03a99c2
30 changed files with 503 additions and 141 deletions

View File

@@ -105,3 +105,23 @@ func TestTrie_WildcardBoundary(t *testing.T) {
assert.NotNil(t, tree.Search("example.com"))
}
func TestTrie_Foreach(t *testing.T) {
tree := New[netip.Addr]()
domainList := []string{
"google.com",
"stun.*.*.*",
"test.*.google.com",
"+.baidu.com",
"*.baidu.com",
"*.*.baidu.com",
}
for _, domain := range domainList {
tree.Insert(domain, localIP)
}
count := 0
tree.Foreach(func(domain string, data netip.Addr) {
count++
})
assert.Equal(t, 7, count)
}