Changeset

9306:35c128b42509

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.
author Kim Alvefur <zash@zash.se>
date Thu, 13 Sep 2018 17:28:50 +0200
parents 9305:f14c81fd44a4
children 9307:feaef6215bb8
files net/server_epoll.lua
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Thu Sep 13 16:18:59 2018 +0100
+++ b/net/server_epoll.lua	Thu Sep 13 17:28:50 2018 +0200
@@ -454,6 +454,7 @@
 		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 @@
 	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 @@
 
 -- 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()