1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # wrap Net::NNTP client with SOCKS support
5 package PublicInbox::NetNNTPSocks;
10 our @ISA = qw(IO::Socket::Socks);
11 my @SOCKS_KEYS = qw(ProxyAddr ProxyPort SocksVersion SocksDebug SocksResolve);
13 # use this instead of Net::NNTP->new if using Proxy*
15 my (undef, %opt) = @_;
16 require IO::Socket::Socks;
17 local @Net::NNTP::ISA = (qw(Net::Cmd), __PACKAGE__);
19 defined($opt{$_}) ? ($_ => $opt{$_}) : ()
21 Net::NNTP->new(%opt); # this calls our new() below:
24 # called by Net::NNTP->new
26 my ($self, %opt) = @_;
27 @OPT{qw(ConnectAddr ConnectPort)} = @opt{qw(PeerAddr PeerPort)};
28 my $ret = $self->SUPER::new(%OPT) or
29 die 'SOCKS error: '.eval('$IO::Socket::Socks::SOCKS_ERROR');