aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-01-15 21:16:08 +0100
committerKim Alvefur <zash@zash.se>2020-01-15 21:16:08 +0100
commit78eb3b5935a53e1a4e1217555f438674ca40e2ba (patch)
tree7989706e28c7796b303bce801a908f54050e55dd
parent34098ab9da64b314b430d82b3530035670039f79 (diff)
downloadprosody-78eb3b5935a53e1a4e1217555f438674ca40e2ba.tar.gz
prosody-78eb3b5935a53e1a4e1217555f438674ca40e2ba.zip
util.ip: Fix equality metamethod for Lua 5.3
-rw-r--r--util/ip.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/ip.lua b/util/ip.lua
index d1808225..d039e475 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -19,8 +19,14 @@ local ip_mt = {
return ret;
end,
__tostring = function (ip) return ip.addr; end,
- __eq = function (ipA, ipB) return ipA.packed == ipB.packed; end
};
+ip_mt.__eq = function (ipA, ipB)
+ if getmetatable(ipA) ~= ip_mt or getmetatable(ipB) ~= ip_mt then
+ -- Lua 5.3+ calls this if both operands are tables, even if metatables differ
+ return false;
+ end
+ return ipA.packed == ipB.packed;
+end
local hex2bits = {
["0"] = "0000", ["1"] = "0001", ["2"] = "0010", ["3"] = "0011",