diff options
author | Eric Wong <e@yhbt.net> | 2020-06-16 22:31:20 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-06-21 00:42:32 +0000 |
commit | 8fd41797b24736dfdccfacc5acc473234a29758a (patch) | |
tree | 0a6f467777653ff98a5b933f0bd8bb748c809ff2 /lib/PublicInbox/NNTP.pm | |
parent | 74c897120af8ac4cac17d9f76d21c84f903e24be (diff) | |
download | public-inbox-8fd41797b24736dfdccfacc5acc473234a29758a.tar.gz |
daemon: use ->can to check for IO::Socket::SSL
Doing a ref($obj) string comparison ties us to IO::Socket::SSL (and OpenSSL) In the future, we may support GnuTLS or other TLS implementations. This was already done in the IMAP code.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index bffd773c..be3bddc3 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -47,7 +47,7 @@ sub new ($$$) { my $self = fields::new($class); my $ev = EPOLLIN; my $wbuf; - if (ref($sock) eq 'IO::Socket::SSL' && !$sock->accept_SSL) { + if ($sock->can('accept_SSL') && !$sock->accept_SSL) { return CORE::close($sock) if $! != EAGAIN; $ev = PublicInbox::TLS::epollbit(); $wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ]; @@ -97,7 +97,7 @@ sub process_line ($$) { sub cmd_capabilities ($;$) { my ($self, undef) = @_; my $res = $CAPABILITIES; - if (ref($self->{sock}) ne 'IO::Socket::SSL' && + if (!$self->{sock}->can('accept_SSL') && $self->{nntpd}->{accept_tls}) { $res .= "STARTTLS\r\n"; } @@ -896,7 +896,7 @@ sub cmd_starttls ($) { my ($self) = @_; my $sock = $self->{sock} or return; # RFC 4642 2.2.1 - return r502 if (ref($sock) eq 'IO::Socket::SSL' || $self->compressed); + return r502 if ($sock->can('accept_SSL') || $self->compressed); my $opt = $self->{nntpd}->{accept_tls} or return '580 can not initiate TLS negotiation'; res($self, '382 Continue with TLS negotiation'); |