From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 046D61F953 for ; Wed, 3 Nov 2021 20:35:56 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_curl: use http.proxy knob via URL match for curl Date: Wed, 3 Nov 2021 20:35:55 +0000 Message-Id: <20211103203555.31972-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Using the --proxy on the command-line affects the entire lei invocation, and users searching HTTP(S) remotes and writing to an IMAP folder may want more fine-grained proxy use: lei q -o imap://no-proxy.example/foo -O https://need-proxy.example/bar ... --- lib/PublicInbox/LeiCurl.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PublicInbox/LeiCurl.pm b/lib/PublicInbox/LeiCurl.pm index ce57e796..5ffade99 100644 --- a/lib/PublicInbox/LeiCurl.pm +++ b/lib/PublicInbox/LeiCurl.pm @@ -75,6 +75,11 @@ EOM sub for_uri { my ($self, $lei, $uri, @opt) = @_; my $pfx = torsocks($self, $lei, $uri) or return; # error + if ($uri->scheme =~ /\Ahttps?\z/i) { + my $cfg = $lei->_lei_cfg; + my $p = $cfg ? $cfg->urlmatch('http.Proxy', $$uri) : undef; + push(@opt, "--proxy=$p") if defined($p); + } bless [ @$pfx, @$self, @opt, $uri->as_string ], ref($self); }