}
sub epbit ($$) { # (sock, default)
- ref($_[0]) eq 'IO::Socket::SSL' ? PublicInbox::TLS::epollbit() : $_[1];
+ $_[0]->can('stop_SSL') ? PublicInbox::TLS::epollbit() : $_[1];
}
# returns 1 if done, 0 if incomplete
my $wbuf = $self->{wbuf};
if (MSG_MORE && (!defined($wbuf) || !scalar(@$wbuf)) &&
- ref($sock) ne 'IO::Socket::SSL') {
+ !$sock->can('stop_SSL')) {
my $n = send($sock, $_[1], MSG_MORE);
if (defined $n) {
my $nlen = bytes::length($_[1]) - $n;
sub shutdn ($) {
my ($self) = @_;
my $sock = $self->{sock} or return;
- if (ref($sock) eq 'IO::Socket::SSL') {
+ if ($sock->can('stop_SSL')) {
shutdn_tls_step($self);
} else {
$self->close;
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 ];
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 ];
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";
}
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');