Skip to content

Commit

Permalink
fix: resolve IPv6 rule-set issue #959.
Browse files Browse the repository at this point in the history
  • Loading branch information
Larvan2 committed Jan 6, 2024
1 parent 4af94df commit 6bc9155
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions component/trie/ipcidr_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions component/trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 6bc9155

Please sign in to comment.