Software /
code /
prosody
Changeset
5608:0200945313c9
util.ip: Fix protocol detection of IPv6 addresses beginning with :
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 May 2013 21:41:17 +0100 |
parents | 5607:eee23fb79a5e |
children | 5609:f12d1c03dd94 |
files | util/ip.lua |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/ip.lua Sat May 18 21:40:40 2013 +0100 +++ b/util/ip.lua Sat May 18 21:41:17 2013 +0100 @@ -14,8 +14,10 @@ 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";