diff options
author | Kim Alvefur <zash@zash.se> | 2017-12-01 04:33:27 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-12-01 04:33:27 +0100 |
commit | 84da11d50e5627c84b5b85f262530d80bf107685 (patch) | |
tree | eb96ccd26320b0baed2214f9bc71270eb85e846f | |
parent | 42e41f583df1697babcede6246b28e69c10dbdc4 (diff) | |
download | prosody-84da11d50e5627c84b5b85f262530d80bf107685.tar.gz prosody-84da11d50e5627c84b5b85f262530d80bf107685.zip |
util.ip: Add a method returning a normalized IP address
-rw-r--r-- | util/ip.lua | 4 |
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 |