util.ip: Add a method returning a normalized IP address

This commit is contained in:
Kim Alvefur 2017-12-01 04:33:27 +01:00
parent 42e41f583d
commit 84da11d50e

View file

@ -52,6 +52,10 @@ local function new_ip(ipStr, proto)
return setmetatable({ addr = ipStr, packed = packed, proto = proto, zone = zone }, ip_mt);
end
function ip_methods:normal()
return net.ntop(self.packed);
end
function ip_methods.bits(ip)
return hex.to(ip.packed):upper():gsub(".", hex2bits);
end