fix: resolve IPv6 rule-set issue #959.

This commit is contained in:
Larvan2 2024-01-06 17:54:09 +08:00
parent 4af94df142
commit 6bc915526f
2 changed files with 12 additions and 0 deletions

View file

@ -185,6 +185,10 @@ func addIpv6Cidr(trie *IpCidrTrie, ip net.IP, groupSize int) {
}
for i := 2; i < groupSize; i += 2 {
if ip[i] == 0 && ip[i+1] == 0 {
node.Mark = true
}
if node.Mark {
return
}

View file

@ -74,6 +74,14 @@ func TestIpv6AddFail(t *testing.T) {
assert.IsType(t, new(net.ParseError), err)
}
func TestIpv6SearchSub(t *testing.T) {
trie := NewIpCidrTrie()
assert.NoError(t, trie.AddIpCidrForString("240e::/18"))
assert.Equal(t, true, trie.IsContainForString("240e:964:ea02:100:1800::71"))
}
func TestIpv6Search(t *testing.T) {
trie := NewIpCidrTrie()