]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NetReader.pm
net_reader: tie SocksDebug to {imap,nntp}.Debug
[public-inbox.git] / lib / PublicInbox / NetReader.pm
index abcb5d2f0432e7867f995d7e974411af20eb8a0c..e703cddb1ce686eadda1823d4428f0db7972bcb3 100644 (file)
@@ -35,6 +35,7 @@ sub socks_args ($) {
                eval { require IO::Socket::Socks } or die <<EOM;
 IO::Socket::Socks missing for socks5h://$h:$p
 EOM
+               # for IO::Socket::Socks
                return { ProxyAddr => $h, ProxyPort => $p };
        }
        die "$val not understood (only socks5h:// is supported)\n";
@@ -45,7 +46,12 @@ sub mic_new ($$$$) {
        my %mic_arg = %$mic_arg;
        my $sa = $self->{cfg_opt}->{$sec}->{-proxy_cfg} || $self->{-proxy_cli};
        if ($sa) {
+               # this `require' needed for worker[1..Inf], since socks_args
+               # only got called in worker[0]
+               require IO::Socket::Socks;
+
                my %opt = %$sa;
+               $opt{SocksDebug} = 1 if $mic_arg{Debug};
                $opt{ConnectAddr} = delete $mic_arg{Server};
                $opt{ConnectPort} = delete $mic_arg{Port};
                $mic_arg{Socket} = IO::Socket::Socks->new(%opt) or die
@@ -165,6 +171,7 @@ sub nn_new ($$$) {
        my $nn;
        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 $@;
        } else {