aboutsummaryrefslogtreecommitdiffstats
path: root/util/ip.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-12-01 04:33:27 +0100
committerKim Alvefur <zash@zash.se>2017-12-01 04:33:27 +0100
commit84da11d50e5627c84b5b85f262530d80bf107685 (patch)
treeeb96ccd26320b0baed2214f9bc71270eb85e846f /util/ip.lua
parent42e41f583df1697babcede6246b28e69c10dbdc4 (diff)
downloadprosody-84da11d50e5627c84b5b85f262530d80bf107685.tar.gz
prosody-84da11d50e5627c84b5b85f262530d80bf107685.zip
util.ip: Add a method returning a normalized IP address
Diffstat (limited to 'util/ip.lua')
-rw-r--r--util/ip.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 894fe2fb..7c438593 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -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