aboutsummaryrefslogtreecommitdiffstats
path: root/util/ip.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-05-18 21:41:17 +0100
committerMatthew Wild <mwild1@gmail.com>2013-05-18 21:41:17 +0100
commitb985f77de301b6743d35e96b2dc7633ce8b456e3 (patch)
tree5e1245718c80ef5fde333a5a458375524da90d36 /util/ip.lua
parent5b21f4242a430f04173354fd140cc40ed9ea7e5d (diff)
downloadprosody-b985f77de301b6743d35e96b2dc7633ce8b456e3.tar.gz
prosody-b985f77de301b6743d35e96b2dc7633ce8b456e3.zip
util.ip: Fix protocol detection of IPv6 addresses beginning with : [Backported from 0.10]
Diffstat (limited to 'util/ip.lua')
-rw-r--r--util/ip.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 226432cc..043303ee 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -14,8 +14,10 @@ local hex2bits = { ["0"] = "0000", ["1"] = "0001", ["2"] = "0010", ["3"] = "0011
local function new_ip(ipStr, proto)
if not proto then
local sep = ipStr:match("^%x+(.)");
- if sep == ":" then proto = "IPv6"
- elseif sep == "." then proto = "IPv4"
+ if sep == ":" or (not(sep) and ipStr:sub(1,1) == ":") then
+ proto = "IPv6"
+ elseif sep == "." then
+ proto = "IPv4"
end
if not proto then
return nil, "invalid address";