diff options
author | Eric Wong <e@80x24.org> | 2023-10-03 06:43:45 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-03 10:16:04 +0000 |
commit | 699eeb49a23399671f8ed0fa142d6cdaa0593b60 (patch) | |
tree | 54e6e7fc88de600ddac698b9b142b13b67d34aff /lib/PublicInbox/NetNNTPSocks.pm | |
parent | 299aac294ec359a2f069e0e881ef82f55a101def (diff) | |
download | public-inbox-699eeb49a23399671f8ed0fa142d6cdaa0593b60.tar.gz |
It takes some effort to get Net::NNTP and IO::Socket::Socks to place nice together, but we don't want the setsockopt call to fail on an undefined value. So die with an error that tries to show various possible error sources. $SOCKS_ERROR is a special variable, so even using `//' (defined-or) operator isn't enough to squelch warnings about using it in its uninitialized state.
Diffstat (limited to 'lib/PublicInbox/NetNNTPSocks.pm')
-rw-r--r-- | lib/PublicInbox/NetNNTPSocks.pm | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/PublicInbox/NetNNTPSocks.pm b/lib/PublicInbox/NetNNTPSocks.pm index fcd2e580..5b15dd59 100644 --- a/lib/PublicInbox/NetNNTPSocks.pm +++ b/lib/PublicInbox/NetNNTPSocks.pm @@ -17,16 +17,18 @@ sub new_socks { local %OPT = map {; defined($opt{$_}) ? ($_ => $opt{$_}) : () } @SOCKS_KEYS; - Net::NNTP->new(%opt); # this calls our new() below: + no warnings 'uninitialized'; # needed for $SOCKS_ERROR + Net::NNTP->new(%opt) // die "errors: \$!=$! SOCKS=", + eval('$IO::Socket::Socks::SOCKS_ERROR // ""'), + ', SSL=', + (eval('IO::Socket::SSL->errstr') // ''), "\n"; } # called by Net::NNTP->new sub new { my ($self, %opt) = @_; @OPT{qw(ConnectAddr ConnectPort)} = @opt{qw(PeerAddr PeerPort)}; - my $ret = $self->SUPER::new(%OPT) or - die 'SOCKS error: '.eval('$IO::Socket::Socks::SOCKS_ERROR'); - $ret; + $self->SUPER::new(%OPT); } 1; |