Changeset

9850:9a905888b96c

net.server_event: Add SNI support (#409) Snippet adapted from server_epoll
author Kim Alvefur <zash@zash.se>
date Sun, 10 Mar 2019 19:32:54 +0100
parents 9849:70e56f126177
children 9851:75d2874502c3
files net/server_event.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Fri Sep 14 01:30:56 2018 +0200
+++ b/net/server_event.lua	Sun Mar 10 19:32:54 2019 +0100
@@ -164,6 +164,15 @@
 		debug( "fatal error while ssl wrapping:", err )
 		return false
 	end
+
+	if self.conn.sni then
+		if self.servername then
+			self.conn:sni(self.servername);
+		elseif self._server and self._server.hosts then
+			self.conn:sni(self._server.hosts, true);
+		end
+	end
+
 	self.conn:settimeout( 0 )  -- set non blocking
 	local handshakecallback = coroutine_wrap(function( event )
 		local _, err
@@ -665,6 +674,7 @@
 
 		_ip = addr, _port = port, _pattern = pattern,
 		_sslctx = sslctx;
+		hosts = {};
 	}
 	interface.id = tostring(interface):match("%x+$");
 	interface.readcallback = function( event )  -- server handler, called on incoming connections