aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-05-18 13:20:46 +0200
committerKim Alvefur <zash@zash.se>2013-05-18 13:20:46 +0200
commit2794871c57db8605a99583de29df2168181715c2 (patch)
tree0f2cb51dea138f8394524c68f5cfb3f876c3e20b /util
parent651c67dc6b70b1e0fac99e1f864656d335974f69 (diff)
parentaa4b5036e35c1e60d3eba1fc2eeeaf96ae76ab15 (diff)
downloadprosody-2794871c57db8605a99583de29df2168181715c2.tar.gz
prosody-2794871c57db8605a99583de29df2168181715c2.zip
Merge 0.9->trunk
Diffstat (limited to 'util')
-rw-r--r--util/ip.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 6ebc023b..20ea3dd7 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -23,6 +23,13 @@ local function new_ip(ipStr, proto)
elseif proto ~= "IPv4" and proto ~= "IPv6" then
return nil, "invalid protocol";
end
+ if proto == "IPv6" and ipStr:find('.', 1, true) then
+ local changed;
+ ipStr, changed = ipStr:gsub(":(%d+)%.(%d+)%.(%d+)%.(%d+)$", function(a,b,c,d)
+ return (":%04X:%04X"):format(a*256+b,c*256+d);
+ end);
+ if changed ~= 1 then return nil, "invalid-address"; end
+ end
return setmetatable({ addr = ipStr, proto = proto }, ip_mt);
end