Software /
code /
prosody
Diff
util/ip.lua @ 7061:eda0feeaf759
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 Jan 2016 16:16:08 +0100 |
parent | 6926:d96b2aa7a11d |
parent | 7055:23de70d19e77 |
child | 7481:b3a864df32ef |
line wrap: on
line diff
--- a/util/ip.lua Wed Jan 06 03:28:56 2016 +0100 +++ b/util/ip.lua Fri Jan 08 16:16:08 2016 +0100 @@ -25,6 +25,10 @@ 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 @@ 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)