Software /
code /
prosody
Diff
util/ip.lua @ 5599:34e9f237b915
Merge 0.9->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 May 2013 13:20:46 +0200 |
parent | 5588:8c1a3243d16f |
parent | 5597:6fe09707c73b |
child | 5603:e07f4f02e4f9 |
line wrap: on
line diff
--- a/util/ip.lua Sat May 18 12:03:03 2013 +0100 +++ b/util/ip.lua Sat May 18 13:20:46 2013 +0200 @@ -23,6 +23,13 @@ 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