diff options
author | Eric Wong <e@80x24.org> | 2019-06-26 06:36:27 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-26 06:36:27 +0000 |
commit | 84d8920b92686e975929aebe845b6d4ea0a9ef0d (patch) | |
tree | 91a1123aaa44ad8fbb63c9dbf912d6dca95b0818 /lib/PublicInbox/TLS.pm | |
parent | c19a4e88f49ba3496751c4b87ebcfa0f6b47f0ce (diff) | |
parent | c30b4427b340aeb242273a7b890fbd7e50132f51 (diff) | |
download | public-inbox-84d8920b92686e975929aebe845b6d4ea0a9ef0d.tar.gz |
* origin/nntp-tls: (59 commits) ds: ->write must not clobber empty wbuf array Makefile: skip DSKQXS in global syntax check ds: reduce overhead of tempfile creation Revert "ci: require IO::KQueue on FreeBSD, for now" ds: reimplement IO::Poll support to look like epoll ds: split out IO::KQueue-specific code daemon: use FreeBSD accept filters on non-NNTP daemon: set TCP_DEFER_ACCEPT on everything but NNTP nntp: send greeting immediately for plain sockets ci: require IO::KQueue on FreeBSD, for now nntp: lazily allocate and stash rbuf ds: flush_write runs ->write callbacks even if closed nntp: simplify long response logic and fix nesting ds: always use EV_ADD with EV_SET nntp: reduce allocations for greeting ds: allow ->write callbacks to syswrite directly daemon: use SSL_MODE_RELEASE_BUFFERS t/nntpd-tls: slow client connection test nntp: call SSL_shutdown in normal cases ds|nntp: use CORE::close on socket ...
Diffstat (limited to 'lib/PublicInbox/TLS.pm')
-rw-r--r-- | lib/PublicInbox/TLS.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/PublicInbox/TLS.pm b/lib/PublicInbox/TLS.pm new file mode 100644 index 00000000..576c11d7 --- /dev/null +++ b/lib/PublicInbox/TLS.pm @@ -0,0 +1,24 @@ +# Copyright (C) 2019 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> + +# IO::Socket::SSL support code +package PublicInbox::TLS; +use strict; +use IO::Socket::SSL; +require Carp; +use Errno qw(EAGAIN); +use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT); + +sub err () { $SSL_ERROR } + +# returns the EPOLL event bit which matches the existing SSL error +sub epollbit () { + if ($! == EAGAIN) { + return EPOLLIN if $SSL_ERROR == SSL_WANT_READ; + return EPOLLOUT if $SSL_ERROR == SSL_WANT_WRITE; + die "unexpected SSL error: $SSL_ERROR"; + } + 0; +} + +1; |