aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-08-10 20:57:05 +0200
committerKim Alvefur <zash@zash.se>2016-08-10 20:57:05 +0200
commitf14ac4df604a27a7e0cd3315cf57abcfb7424123 (patch)
treeff6be3f404602740d3958df4616268932ef7ac7c /net/server_epoll.lua
parent57c3c911f50ea40ce2aa4c744ad9f680c3bdb24a (diff)
downloadprosody-f14ac4df604a27a7e0cd3315cf57abcfb7424123.tar.gz
prosody-f14ac4df604a27a7e0cd3315cf57abcfb7424123.zip
net.server_epoll: Make addclient use wrapclient
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index c450f658..c1bcbc39 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -424,12 +424,6 @@ function interface:onconnect()
self.listeners.onconnect(self);
end
-local function addclient(addr, port, listeners, pattern, tls)
- local conn, err = socket.connect(addr, port);
- if not conn then return conn, err; end
- return wrapsocket(conn, nil, pattern, listeners, tls);
-end
-
local function addserver(addr, port, listeners, pattern, tls)
local conn, err = socket.bind(addr, port, cfg.tcp_backlog);
if not conn then return conn, err; end
@@ -466,6 +460,20 @@ local function wrapclient(conn, addr, port, listeners, pattern, tls)
return client;
end
+local function addclient(addr, port, listeners, pattern, tls)
+ local conn, err = socket.connect(addr, port);
+ if not conn then return conn, err; end
+ conn:settimeout(0);
+ local client = wrapclient(conn, addr, port, listeners, pattern, tls);
+ if tls then
+ client._tls = false;
+ client:starttls();
+ else
+ client:setflags(true, true);
+ end
+ return client;
+end
+
local function link(from, to)
from.listeners = setmetatable({
onincoming = function (_, data)