Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11676:993462e5e4d4
net.server_epoll: Refactor immediate TLS handshake start
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 13 Jul 2021 14:55:21 +0200 |
parent | 11675:139d80774f11 |
child | 11677:98bcc19361db |
comparison
equal
deleted
inserted
replaced
11675:139d80774f11 | 11676:993462e5e4d4 |
---|---|
568 self:setwritetimeout(cfg.ssl_handshake_timeout); | 568 self:setwritetimeout(cfg.ssl_handshake_timeout); |
569 self:debug("Prepared to start TLS"); | 569 self:debug("Prepared to start TLS"); |
570 end | 570 end |
571 end | 571 end |
572 | 572 |
573 function interface:inittls(tls_ctx) | 573 function interface:inittls(tls_ctx, now) |
574 if self._tls then return end | 574 if self._tls then return end |
575 if tls_ctx then self.tls_ctx = tls_ctx; end | 575 if tls_ctx then self.tls_ctx = tls_ctx; end |
576 self._tls = true; | 576 self._tls = true; |
577 self:debug("Starting TLS now"); | 577 self:debug("Starting TLS now"); |
578 self:updatenames(); -- Can't getpeer/sockname after wrap() | 578 self:updatenames(); -- Can't getpeer/sockname after wrap() |
610 end | 610 end |
611 self:on("starttls"); | 611 self:on("starttls"); |
612 self.ondrain = nil; | 612 self.ondrain = nil; |
613 self.onwritable = interface.tlshandshake; | 613 self.onwritable = interface.tlshandshake; |
614 self.onreadable = interface.tlshandshake; | 614 self.onreadable = interface.tlshandshake; |
615 if now then | |
616 return self:tlshandshake() | |
617 end | |
615 self:setreadtimeout(cfg.ssl_handshake_timeout); | 618 self:setreadtimeout(cfg.ssl_handshake_timeout); |
616 self:setwritetimeout(cfg.ssl_handshake_timeout); | 619 self:setwritetimeout(cfg.ssl_handshake_timeout); |
617 self:set(true, true); | 620 self:set(true, true); |
618 end | 621 end |
619 | 622 |
699 end | 702 end |
700 local client = wrapsocket(conn, self, nil, self.listeners); | 703 local client = wrapsocket(conn, self, nil, self.listeners); |
701 client:debug("New connection %s on server %s", client, self); | 704 client:debug("New connection %s on server %s", client, self); |
702 if self.tls_direct then | 705 if self.tls_direct then |
703 client:add(true, true); | 706 client:add(true, true); |
704 if client:inittls(self.tls_ctx) then | 707 client:inittls(self.tls_ctx, true); |
705 client:setreadtimeout(cfg.ssl_handshake_timeout); | |
706 client:setwritetimeout(cfg.ssl_handshake_timeout); | |
707 client:tlshandshake(); | |
708 end | |
709 else | 708 else |
710 client:add(true, false); | 709 client:add(true, false); |
711 client:onconnect(); | 710 client:onconnect(); |
712 client:onreadable(); | 711 client:onreadable(); |
713 end | 712 end |