From: Eric Wong Date: Mon, 25 Jan 2021 01:18:57 +0000 (-0800) Subject: lei q: continue remote search if torsocks(1) is missing X-Git-Tag: v1.7.0~1296 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=9c1ef5c25100ad23c59404d5ca80994645f8c9c8;p=public-inbox.git lei q: continue remote search if torsocks(1) is missing torsocks is just one of many ways to get curl to use Tor, so we'll continue if we can't find torsocks in our PATH and assume the user has a proxy configured via curlrc, the command-line, environment variable, or even firewall rules. --- diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 369f6f89..b470c113 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -228,10 +228,16 @@ sub query_remote_mboxrd { my $cmd = [ @cmd, $uri->as_string ]; if ($tor eq 'auto' && substr($uri->host, -6) eq '.onion' && (($env->{LD_PRELOAD}//'') !~ /torsocks/)) { - unshift @$cmd, 'torsocks'; + unshift @$cmd, which('torsocks'); } elsif (PublicInbox::Config::git_bool($tor)) { - unshift @$cmd, 'torsocks'; + unshift @$cmd, which('torsocks'); } + + # continue anyways if torsocks is missing; a proxy may be + # specified via CLI, curlrc, environment variable, or even + # firewall rule + shift(@$cmd) if !$cmd->[0]; + $lei->err("# @$cmd") if $verbose; $? = 0; my $fh = popen_rd($cmd, $env, $rdr);