aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-13 17:28:50 +0200
committerKim Alvefur <zash@zash.se>2018-09-13 17:28:50 +0200
commitfee3f096fc0515a3e496bfafdcedbcd515a789b0 (patch)
tree0c01ce25d6be6a39f42e065c76480edacf448da7
parent19594a74621904bb8ac3e6d7ecdc188a0c54fbab (diff)
downloadprosody-fee3f096fc0515a3e496bfafdcedbcd515a789b0.tar.gz
prosody-fee3f096fc0515a3e496bfafdcedbcd515a789b0.zip
net.server_epoll: Factor Direct TLS handling out of connection initialization
Eventually it should be possible to create a socket that has a TLS context but that does not automatically start TLS on connect.
-rw-r--r--net/server_epoll.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 0c19b2a2..0de590ce 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -454,6 +454,7 @@ function interface:tlshandskake()
self.onreadable = nil;
self._tls = true;
self:on("status", "ssl-handshake-complete");
+ self.init = nil; -- Restore default method
self:init();
elseif err == "wantread" then
log("debug", "TLS handshake on %s to wait until readable", self);
@@ -488,6 +489,9 @@ local function wrapsocket(client, server, pattern, listeners, tls_ctx) -- luasoc
if client.getsockname then
conn.sockname, conn.sockport = client:getsockname();
end
+ if tls_ctx then
+ conn.init = interface.starttls;
+ end
return conn;
end
@@ -507,12 +511,8 @@ end
-- Initialization
function interface:init()
- if self.tls_ctx and not self._tls then
- return self:starttls();
- else
- self:setwritetimeout();
- return self:setflags(true, true);
- end
+ self:setwritetimeout();
+ return self:setflags(true, true);
end
function interface:pause()