* [PATCH 1/8] net_reader: bail out on NNTP SOCKS connection failure
2023-10-03 6:43 7% [PATCH 0/8] IMAP/NNTP client improvements Eric Wong
@ 2023-10-03 6:43 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-10-03 6:43 UTC (permalink / raw)
To: meta
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.
---
lib/PublicInbox/NetNNTPSocks.pm | 10 ++++++----
lib/PublicInbox/NetReader.pm | 3 +--
2 files changed, 7 insertions(+), 6 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;
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 6802fa72..32e4c20f 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -180,8 +180,7 @@ sub nn_new ($$$) {
if (defined $nn_arg->{ProxyAddr}) {
require PublicInbox::NetNNTPSocks;
$nn_arg->{SocksDebug} = 1 if $nn_arg->{Debug};
- eval { $nn = PublicInbox::NetNNTPSocks->new_socks(%$nn_arg) };
- die "E: <$uri> $@\n" if $@;
+ $nn = PublicInbox::NetNNTPSocks->new_socks(%$nn_arg) or return;
} else {
$nn = Net::NNTP->new(%$nn_arg) or return;
}
^ permalink raw reply related [relevance 7%]
* [PATCH 0/8] IMAP/NNTP client improvements
@ 2023-10-03 6:43 7% Eric Wong
2023-10-03 6:43 7% ` [PATCH 1/8] net_reader: bail out on NNTP SOCKS connection failure Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-10-03 6:43 UTC (permalink / raw)
To: meta
These affect both lei and -watch
Eric Wong (8):
net_reader: bail out on NNTP SOCKS connection failure
net_reader: avoid IO::Socket::SSL 2.079..2.081 warning
config: fix key-only truthy values with urlmatch
net_reader: support imap.sslVerify + nntp.sslVerify
lei: workers exit after they tell lei-daemon
net_reader: process title reflects NNTP article
xt/lei-onion-convert: test TLS + SOCKS
net_reader: note glob support in .onion hint
lib/PublicInbox/Config.pm | 18 ++++---
lib/PublicInbox/LEI.pm | 1 +
lib/PublicInbox/NetNNTPSocks.pm | 10 ++--
lib/PublicInbox/NetReader.pm | 87 +++++++++++++++++++++------------
t/imapd-tls.t | 18 +++++--
t/nntpd-tls.t | 19 +++++--
xt/lei-onion-convert.t | 21 ++++++--
7 files changed, 123 insertions(+), 51 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-10-03 6:43 7% [PATCH 0/8] IMAP/NNTP client improvements Eric Wong
2023-10-03 6:43 7% ` [PATCH 1/8] net_reader: bail out on NNTP SOCKS connection failure Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).