diff options
author | Matthew Wild <mwild1@gmail.com> | 2015-11-22 15:30:27 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2015-11-22 15:30:27 +0000 |
commit | 68b9f291318cf704fdad177751223443a83bec75 (patch) | |
tree | 005a833759b5aa6eac957c8b55249ebbc1769051 /util/ip.lua | |
parent | 3c75f782eddde40791ffab6e1156d1b7861adb00 (diff) | |
download | prosody-68b9f291318cf704fdad177751223443a83bec75.tar.gz prosody-68b9f291318cf704fdad177751223443a83bec75.zip |
util.ip: Improve comparison, == doesn't necessarily handle IPv6 addresses correctly if they aren't normalized (case, ::, etc.)
Diffstat (limited to 'util/ip.lua')
-rw-r--r-- | util/ip.lua | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/util/ip.lua b/util/ip.lua index d0ae07eb..7dcace5c 100644 --- a/util/ip.lua +++ b/util/ip.lua @@ -229,13 +229,10 @@ end local function match(ipA, ipB, bits) local common_bits = commonPrefixLength(ipA, ipB); - if not bits then - return ipA == ipB; - end if bits and ipB.proto == "IPv4" then common_bits = common_bits - 96; -- v6 mapped addresses always share these bits end - return common_bits >= bits; + return common_bits >= (bits or 128); end return {new_ip = new_ip, |