aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit4d0edf5ebdfe6f8dfd815526145e23b212449505 (patch)
tree7989706e28c7796b303bce801a908f54050e55dd /util
parent6aca72acd8752ba17d1f5e1b3740c8fed22e81da (diff)
downloadprosody-4d0edf5ebdfe6f8dfd815526145e23b212449505.tar.gz
prosody-4d0edf5ebdfe6f8dfd815526145e23b212449505.zip
util.ip: Fix equality metamethod for Lua 5.3
Diffstat (limited to 'util')
-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",