aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-12 16:26:19 +0200
committerKim Alvefur <zash@zash.se>2018-10-12 16:26:19 +0200
commita2647a3c325f0d0f63b7287524ffbdac981e8746 (patch)
treeaab061d1c4968d87d7750fb0cfb3750445c52c2b /net/server_epoll.lua
parent04bef9f4029ae4b96f023f0d7c43d3fa569542b5 (diff)
downloadprosody-a2647a3c325f0d0f63b7287524ffbdac981e8746.tar.gz
prosody-a2647a3c325f0d0f63b7287524ffbdac981e8746.zip
net.server_epoll: Add support for the conn_type argument to addclient
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 7a9bd7a3..75a8883c 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -625,14 +625,22 @@ local function wrapclient(conn, addr, port, listeners, read_size, tls_ctx)
end
-- New outgoing TCP connection
-local function addclient(addr, port, listeners, read_size, tls_ctx)
- local n = inet_pton(addr);
- if not n then return nil, "invalid-ip"; end
- local create
- if #n == 16 then
- create = socket.tcp6 or socket.tcp;
- else
- create = socket.tcp4 or socket.tcp;
+local function addclient(addr, port, listeners, read_size, tls_ctx, typ)
+ local create;
+ if not typ then
+ local n = inet_pton(addr);
+ if not n then return nil, "invalid-ip"; end
+ if #n == 16 then
+ typ = "tcp6";
+ else
+ typ = "tcp4";
+ end
+ end
+ if typ then
+ create = socket[typ];
+ end
+ if type(create) ~= "function" then
+ return nil, "invalid socket type";
end
local conn, err = create();
conn:settimeout(0);