aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
commit1c2694ccf7e515e481f054743587cf430f24a02f (patch)
treeff6be3f404602740d3958df4616268932ef7ac7c /net
parentb18c28c0566c71725891cf1499e82c98dd581ac7 (diff)
downloadprosody-1c2694ccf7e515e481f054743587cf430f24a02f.tar.gz
prosody-1c2694ccf7e515e481f054743587cf430f24a02f.zip
net.server_epoll: Make addclient use wrapclient
Diffstat (limited to 'net')
-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)