aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_event.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-12-23 17:57:53 +0100
committerKim Alvefur <zash@zash.se>2013-12-23 17:57:53 +0100
commitcf48e76e783abc6925a78a4a3750d3a1cbaaf864 (patch)
tree90ef8d101114a4db8ee86dfa99884d8a7c586b81 /net/server_event.lua
parent3e156487cff0779f075a765451cacb2a7c47b52c (diff)
downloadprosody-cf48e76e783abc6925a78a4a3750d3a1cbaaf864.tar.gz
prosody-cf48e76e783abc6925a78a4a3750d3a1cbaaf864.zip
net.server_{select,event}: addclient: Use getaddrinfo to detect IP address type if no socket type argument given. (Argument must be given for non-TCP)
Diffstat (limited to 'net/server_event.lua')
-rw-r--r--net/server_event.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/server_event.lua b/net/server_event.lua
index ae64d50e..1a3b8ca6 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -46,6 +46,7 @@ local t_concat = table.concat
local has_luasec, ssl = pcall ( require , "ssl" )
local socket = use "socket" or require "socket"
+local getaddrinfo = socket.dns.getaddrinfo
local log = require ("util.logger").init("socket")
@@ -742,7 +743,13 @@ do
return nil, "luasec not found"
end
if not typ then
- typ = "tcp"
+ local addrinfo, err = getaddrinfo(addr)
+ if not addrinfo then return nil, err end
+ if addrinfo[1] and addrinfo[1].family == "inet6" then
+ typ = "tcp6"
+ else
+ typ = "tcp"
+ end
end
local create = socket[typ]
if type( create ) ~= "function" then