projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0979336
)
util.ip: Improve comparison, == doesn't necessarily handle IPv6 addresses correctly...
author
Matthew Wild
<mwild1@gmail.com>
Sun, 22 Nov 2015 15:30:27 +0000
(15:30 +0000)
committer
Matthew Wild
<mwild1@gmail.com>
Sun, 22 Nov 2015 15:30:27 +0000
(15:30 +0000)
util/ip.lua
patch
|
blob
|
history
diff --git
a/util/ip.lua
b/util/ip.lua
index d0ae07eb8aa3c57cd18e178b20ff10c391d0ed4b..7dcace5cac35d8ec271a4fd2328ce58b7e020fcc 100644
(file)
--- 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,