- push @cmd, $uri->as_string;
- $lei->err("# @cmd") if $verbose;
- $? = 0;
- my $fh = popen_rd(\@cmd, $lei->{env}, { 2 => $lei->{2} });
- $fh = IO::Uncompress::Gunzip->new($fh);
- eval {
- PublicInbox::MboxReader->mboxrd($fh, \&each_eml,
- $self, $lei, $each_smsg);
- };
- return $lei->fail("E: @cmd: $@") if $@;
- if (($? >> 8) == 22) { # HTTP 404 from curl(1)
- $uri->query_form(q => $lei->{mset_opt}->{qstr});
- $lei->err('# no results from '.$uri->as_string);
- } elsif ($?) {
- $uri->query_form(q => $lei->{mset_opt}->{qstr});
- $lei->err('E: '.$uri->as_string);
- $lei->child_error($?);
+ $opt->{torsocks} = 'false' if $opt->{'no-torsocks'};
+ my $tor = $opt->{torsocks} //= 'auto';
+ for my $uri (@$uris) {
+ $uri->query_form(@qform);
+ my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei, $uri);
+ my $cmd = [ @cmd, $uri->as_string ];
+ if ($tor eq 'auto' && substr($uri->host, -6) eq '.onion' &&
+ (($env->{LD_PRELOAD}//'') !~ /torsocks/)) {
+ unshift @$cmd, 'torsocks';
+ } elsif (PublicInbox::Config::git_bool($tor)) {
+ unshift @$cmd, 'torsocks';
+ }
+ $lei->err("# @$cmd") if $verbose;
+ $? = 0;
+ my $fh = popen_rd($cmd, $env, { 2 => $lei->{2} });
+ $fh = IO::Uncompress::Gunzip->new($fh);
+ eval {
+ PublicInbox::MboxReader->mboxrd($fh, \&each_eml, $self,
+ $lei, $each_smsg);
+ };
+ return $lei->fail("E: @$cmd: $@") if $@;
+ if (($? >> 8) == 22) { # HTTP 404 from curl(1)
+ $uri->query_form(q => $lei->{mset_opt}->{qstr});
+ $lei->err('# no results from '.$uri->as_string);
+ } elsif ($?) {
+ $uri->query_form(q => $lei->{mset_opt}->{qstr});
+ $lei->err('E: '.$uri->as_string);
+ $lei->child_error($?);
+ }