aboutsummaryrefslogtreecommitdiffstats
path: root/util/ip.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/ip.lua')
-rw-r--r--util/ip.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 05c4ca14..4b450934 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",
@@ -61,7 +67,7 @@ function ip_methods:normal()
end
function ip_methods.bits(ip)
- return hex.to(ip.packed):upper():gsub(".", hex2bits);
+ return hex.encode(ip.packed):upper():gsub(".", hex2bits);
end
function ip_methods.bits_full(ip)