aboutsummaryrefslogtreecommitdiffstats
path: root/util/ip.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-01-08 16:16:08 +0100
committerKim Alvefur <zash@zash.se>2016-01-08 16:16:08 +0100
commitebdebb946d9d2c501c0fe7d76d57798ab60e3ff9 (patch)
treefa735fdc4d7fd7f7b8f14ea5dc1e5a86a0ca5dde /util/ip.lua
parentb057664428d529b182ac9a69800402d2f517b43b (diff)
parent224a98b2c63864a480ca38056ea945f92e8122b8 (diff)
downloadprosody-ebdebb946d9d2c501c0fe7d76d57798ab60e3ff9.tar.gz
prosody-ebdebb946d9d2c501c0fe7d76d57798ab60e3ff9.zip
Merge 0.9->0.10
Diffstat (limited to 'util/ip.lua')
-rw-r--r--util/ip.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 7dcace5c..ec3b4d7e 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -25,6 +25,10 @@ local function new_ip(ipStr, proto)
elseif proto ~= "IPv4" and proto ~= "IPv6" then
return nil, "invalid protocol";
end
+ local zone;
+ if proto == "IPv6" and ipStr:find('%', 1, true) then
+ ipStr, zone = ipStr:match("^(.-)%%(.*)");
+ 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)
@@ -33,7 +37,7 @@ local function new_ip(ipStr, proto)
if changed ~= 1 then return nil, "invalid-address"; end
end
- return setmetatable({ addr = ipStr, proto = proto }, ip_mt);
+ return setmetatable({ addr = ipStr, proto = proto, zone = zone }, ip_mt);
end
local function toBits(ip)