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 | b8212a93db0341869f127ee43150650d6b9c8bac (patch) | |
tree | eb96ccd26320b0baed2214f9bc71270eb85e846f /util | |
parent | 72f20aab04f7aa8092eef46240e9cc279ac6032b (diff) | |
download | prosody-b8212a93db0341869f127ee43150650d6b9c8bac.tar.gz prosody-b8212a93db0341869f127ee43150650d6b9c8bac.zip |
util.ip: Add a method returning a normalized IP address
Diffstat (limited to 'util')
-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 |