]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_reader: preserve memoized IMAPClient arg for SOCKS
authorEric Wong <e@80x24.org>
Thu, 9 Sep 2021 05:25:00 +0000 (05:25 +0000)
committerEric Wong <e@80x24.org>
Thu, 9 Sep 2021 05:42:55 +0000 (05:42 +0000)
Multiple invocations of mic_new may happen in long-lived
processes, so do not let mic_new make irreversible changes
to the cached args when using a SOCKS proxy.

lib/PublicInbox/NetReader.pm

index 9faa362c397acc5c110ac6271090b161f92a1bf2..5199a3a3478306bac73f26690424dbb491bcf69f 100644 (file)
@@ -42,16 +42,16 @@ EOM
 
 sub mic_new ($$$$) {
        my ($self, $mic_arg, $sec, $uri) = @_;
-       my %socks;
+       my %mic_arg = %$mic_arg;
        my $sa = $self->{imap_opt}->{$sec}->{-proxy_cfg} || $self->{-proxy_cli};
        if ($sa) {
                my %opt = %$sa;
-               $opt{ConnectAddr} = delete $mic_arg->{Server};
-               $opt{ConnectPort} = delete $mic_arg->{Port};
-               $socks{Socket} = IO::Socket::Socks->new(%opt) or die
+               $opt{ConnectAddr} = delete $mic_arg{Server};
+               $opt{ConnectPort} = delete $mic_arg{Port};
+               $mic_arg{Socket} = IO::Socket::Socks->new(%opt) or die
                        "E: <$$uri> ".eval('$IO::Socket::Socks::SOCKS_ERROR');
        }
-       PublicInbox::IMAPClient->new(%$mic_arg, %socks, Keepalive => 1);
+       PublicInbox::IMAPClient->new(%mic_arg, Keepalive => 1);
 }
 
 sub auth_anon_cb { '' }; # for Mail::IMAPClient::Authcallback