Skip to content

Commit 3f7c01f

Browse files
committed
Skip aliased networks
1 parent 3ac3451 commit 3f7c01f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/maxminddb/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ impl<'de, T: Deserialize<'de>, S: AsRef<[u8]>> Iterator for Within<'de, T, S> {
105105
let current = self.stack.pop().unwrap();
106106
let bit_count = current.ip_bytes.len() * 8;
107107

108+
// Skip networks that are aliases for the IPv4 network
109+
if self.reader.ipv4_start != 0
110+
&& current.node == self.reader.ipv4_start
111+
&& bit_count == 128
112+
&& current.ip_bytes[..12].iter().any(|&b| b != 0)
113+
{
114+
continue;
115+
}
116+
108117
if current.node > self.node_count {
109118
// This is a data node, emit it and we're done (until the following next call)
110119
let ip_net =

0 commit comments

Comments
 (0)