aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-10 19:32:33 +0100
committerKim Alvefur <zash@zash.se>2019-03-10 19:32:33 +0100
commit5fb7d2d35a2c24a9152931d29d614c2aa8714c7e (patch)
tree92b117695ca95a40201e0a219d20c9792861c642
parentaf5e6fcb649c43591524e5f00bf178428718123a (diff)
downloadprosody-5fb7d2d35a2c24a9152931d29d614c2aa8714c7e.tar.gz
prosody-5fb7d2d35a2c24a9152931d29d614c2aa8714c7e.zip
net.server_select: SNI support (#409)
-rw-r--r--net/server_select.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index d82936e6..b52cc6d7 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -184,6 +184,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, ssldi
handler.sslctx = function( )
return sslctx
end
+ handler.hosts = {} -- sni
handler.remove = function( )
connections = connections - 1
if handler then
@@ -627,11 +628,20 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
out_put( "server.lua: attempting to start tls on " .. tostring( socket ) )
local oldsocket, err = socket
socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
+
if not socket then
out_put( "server.lua: error while starting tls on client: ", tostring(err or "unknown error") )
return nil, err -- fatal error
end
+ if socket.sni then
+ if self.servername then
+ socket:sni(self.servername);
+ elseif self.server() and self.server().hosts then
+ socket:sni(self.server().hosts, true);
+ end
+ end
+
socket:settimeout( 0 )
-- add the new socket to our system