Software /
code /
prosody
Comparison
net/server_select.lua @ 9851:75d2874502c3
net.server_select: SNI support (#409)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 10 Mar 2019 19:32:33 +0100 |
parent | 9835:20bf5b47c1fb |
child | 9853:9aea8dbb105d |
comparison
equal
deleted
inserted
replaced
9850:9a905888b96c | 9851:75d2874502c3 |
---|---|
182 return sslctx ~= nil | 182 return sslctx ~= nil |
183 end | 183 end |
184 handler.sslctx = function( ) | 184 handler.sslctx = function( ) |
185 return sslctx | 185 return sslctx |
186 end | 186 end |
187 handler.hosts = {} -- sni | |
187 handler.remove = function( ) | 188 handler.remove = function( ) |
188 connections = connections - 1 | 189 connections = connections - 1 |
189 if handler then | 190 if handler then |
190 handler.resume( ) | 191 handler.resume( ) |
191 end | 192 end |
625 return | 626 return |
626 end | 627 end |
627 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) ) | 628 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) ) |
628 local oldsocket, err = socket | 629 local oldsocket, err = socket |
629 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket | 630 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket |
631 | |
630 if not socket then | 632 if not socket then |
631 out_put( "server.lua: error while starting tls on client: ", tostring(err or "unknown error") ) | 633 out_put( "server.lua: error while starting tls on client: ", tostring(err or "unknown error") ) |
632 return nil, err -- fatal error | 634 return nil, err -- fatal error |
635 end | |
636 | |
637 if socket.sni then | |
638 if self.servername then | |
639 socket:sni(self.servername); | |
640 elseif self.server() and self.server().hosts then | |
641 socket:sni(self.server().hosts, true); | |
642 end | |
633 end | 643 end |
634 | 644 |
635 socket:settimeout( 0 ) | 645 socket:settimeout( 0 ) |
636 | 646 |
637 -- add the new socket to our system | 647 -- add the new socket to our system |