Software /
code /
prosody
Comparison
net/server_select.lua @ 12480:7e9ebdc75ce4
net: isolate LuaSec-specifics
For this, various accessor functions are now provided directly on the
sockets, which reach down into the LuaSec implementation to obtain the
information.
While this may seem of little gain at first, it hides the implementation
detail of the LuaSec+LuaSocket combination that the actual socket and
the TLS layer are separate objects.
The net gain here is that an alternative implementation does not have to
emulate that specific implementation detail and "only" has to expose
LuaSec-compatible data structures on the new functions.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Wed, 27 Apr 2022 17:44:14 +0200 |
parent | 11741:dcf38ac6a38c |
child | 12481:2ee27587fec7 |
comparison
equal
deleted
inserted
replaced
12478:82270a6b1234 | 12480:7e9ebdc75ce4 |
---|---|
356 handler.ssl = function( ) | 356 handler.ssl = function( ) |
357 return ssl | 357 return ssl |
358 end | 358 end |
359 handler.sslctx = function ( ) | 359 handler.sslctx = function ( ) |
360 return sslctx | 360 return sslctx |
361 end | |
362 handler.ssl_info = function( ) | |
363 return socket.info and socket:info() | |
364 end | |
365 handler.ssl_peercertificate = function( ) | |
366 return socket.getpeercertificate and socket:getpeercertificate() | |
367 end | |
368 handler.ssl_peerverification = function( ) | |
369 return socket.getpeerverification and socket:getpeerverification() | |
370 end | |
371 handler.ssl_peerfinished = function( ) | |
372 return socket.getpeerfinished and socket:getpeerfinished() | |
361 end | 373 end |
362 handler.send = function( _, data, i, j ) | 374 handler.send = function( _, data, i, j ) |
363 return send( socket, data, i, j ) | 375 return send( socket, data, i, j ) |
364 end | 376 end |
365 handler.receive = function( pattern, prefix ) | 377 handler.receive = function( pattern, prefix ) |
650 needtls = true | 662 needtls = true |
651 return | 663 return |
652 end | 664 end |
653 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) ) | 665 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) ) |
654 local oldsocket, err = socket | 666 local oldsocket, err = socket |
655 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket | 667 socket, err = sslctx:wrap(socket) -- wrap socket |
656 | 668 |
657 if not socket then | 669 if not socket then |
658 out_put( "server.lua: error while starting tls on client: ", tostring(err or "unknown error") ) | 670 out_put( "server.lua: error while starting tls on client: ", tostring(err or "unknown error") ) |
659 return nil, err -- fatal error | 671 return nil, err -- fatal error |
660 end | 672 end |
661 | 673 |
662 if socket.sni then | 674 if socket.sni then |
663 if self.servername then | 675 if self.servername then |
664 socket:sni(self.servername); | 676 socket:sni(self.servername); |
665 elseif self._server and type(self._server.hosts) == "table" and next(self._server.hosts) ~= nil then | 677 elseif next(sslctx._sni_contexts) ~= nil then |
666 socket:sni(self.server().hosts, true); | 678 socket:sni(sslctx._sni_contexts, true); |
667 end | 679 end |
668 end | 680 end |
669 | 681 |
670 socket:settimeout( 0 ) | 682 socket:settimeout( 0 ) |
671 | 683 |