Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11675:139d80774f11
net.server_epoll: Keep socket registered in epoll trough TLS wrapping
There's the theory that the socket isn't the same before/after wrap(),
but since epoll operates on FD numbers this shouldn't matter.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 13 Jul 2021 14:51:05 +0200 |
parent | 11674:8253f6a30afc |
child | 11676:993462e5e4d4 |
comparison
equal
deleted
inserted
replaced
11674:8253f6a30afc | 11675:139d80774f11 |
---|---|
573 function interface:inittls(tls_ctx) | 573 function interface:inittls(tls_ctx) |
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:del(); | |
579 self:updatenames(); -- Can't getpeer/sockname after wrap() | 578 self:updatenames(); -- Can't getpeer/sockname after wrap() |
580 local ok, conn, err = pcall(luasec.wrap, self.conn, self.tls_ctx); | 579 local ok, conn, err = pcall(luasec.wrap, self.conn, self.tls_ctx); |
581 if not ok then | 580 if not ok then |
582 conn, err = ok, conn; | 581 conn, err = ok, conn; |
583 self:debug("Failed to initialize TLS: %s", err); | 582 self:debug("Failed to initialize TLS: %s", err); |
613 self.ondrain = nil; | 612 self.ondrain = nil; |
614 self.onwritable = interface.tlshandshake; | 613 self.onwritable = interface.tlshandshake; |
615 self.onreadable = interface.tlshandshake; | 614 self.onreadable = interface.tlshandshake; |
616 self:setreadtimeout(cfg.ssl_handshake_timeout); | 615 self:setreadtimeout(cfg.ssl_handshake_timeout); |
617 self:setwritetimeout(cfg.ssl_handshake_timeout); | 616 self:setwritetimeout(cfg.ssl_handshake_timeout); |
618 self:add(true, true); | 617 self:set(true, true); |
619 end | 618 end |
620 | 619 |
621 function interface:tlshandshake() | 620 function interface:tlshandshake() |
622 self:setwritetimeout(false); | 621 self:setwritetimeout(false); |
623 self:setreadtimeout(false); | 622 self:setreadtimeout(false); |