projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0492361
)
util.ip: Fix protocol detection of IPv6 addresses beginning with : [Backported from...
author
Matthew Wild
<mwild1@gmail.com>
Sat, 18 May 2013 20:41:17 +0000
(21:41 +0100)
committer
Matthew Wild
<mwild1@gmail.com>
Sat, 18 May 2013 20:41:17 +0000
(21:41 +0100)
util/ip.lua
patch
|
blob
|
history
diff --git
a/util/ip.lua
b/util/ip.lua
index 226432ccff8887464b7f92b39fe432008ce22b6d..043303eebb311ce6a1d07bcc23b9bdf97db4e620 100644
(file)
--- 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";