about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-11-03 20:35:55 +0000
committerEric Wong <e@80x24.org>2021-11-04 03:29:38 +0000
commitafd4be5163b39050ac9892b8a511f11f417acf7b (patch)
tree92f6efec7730160d9bda8af2f69cb92b6714e25a /lib
parent60a4a6ee11a3c9126e7b825f60b2b603ac09fe33 (diff)
downloadpublic-inbox-afd4be5163b39050ac9892b8a511f11f417acf7b.tar.gz
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 ...
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LeiCurl.pm5
1 files changed, 5 insertions, 0 deletions
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);
 }