Commit ff039d5c authored by Max Lv's avatar Max Lv

Fix the match function of ByteAddress

It's necessary to mask both a and b here, which can be reproduced by
searching "ip" in m.baidu.com.
parent 8d7c098d
......@@ -65,7 +65,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet>
if (a[i] != b[i]) return false
++i
}
return i * 8 == prefixSize || a[i].toInt() == b[i].toInt() and 256 - (1 shl i * 8 + 8 - prefixSize)
val mask = 256 - (1 shl i * 8 + 8 - prefixSize)
return i * 8 == prefixSize || a[i].toInt() and mask == b[i].toInt() and mask
}
}
fun toImmutable() = Immutable(address.address.also {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment