X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fip.lua;h=043303eebb311ce6a1d07bcc23b9bdf97db4e620;hb=533fc1fa57ce10fc0821f8edaeb247f2710a543c;hp=226432ccff8887464b7f92b39fe432008ce22b6d;hpb=0492361698eede7a7779c8c9e97d26093e126d73;p=prosody.git 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";