2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10; use PublicInbox::TestCommon;
5 use PublicInbox::MboxReader;
6 my $test_tor = $ENV{TEST_TOR};
7 plan skip_all => "TEST_TOR unset" unless $test_tor;
8 unless ($test_tor =~ m!\Asocks5h://!i) {
9 my $default = 'socks5h://127.0.0.1:9050';
10 diag "using $default (set TEST_TOR=socks5h://ADDR:PORT to override)";
13 my $onion = $ENV{TEST_ONION_HOST} //
14 '7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion';
15 my $ng = 'inbox.comp.mail.public-inbox.meta';
16 my $nntp_url = $ENV{TEST_NNTP_ONION_URL} // "nntp://$onion/$ng";
17 my $imap_url = $ENV{TEST_IMAP_ONION_URL} // "imap://$onion/$ng.0";
18 my @cnv = qw(lei convert -o mboxrd:/dev/stdout);
19 my @proxy_cli = ("--proxy=$test_tor");
20 my $proxy_cfg = "proxy=$test_tor";
23 for my $args ([$nntp_url, @proxy_cli], [$imap_url, @proxy_cli],
24 [ $nntp_url, '-c', "nntp.$proxy_cfg" ],
25 [ $imap_url, '-c', "imap.$proxy_cfg" ]) {
26 pipe(my ($r, $w)) or xbail "pipe: $!";
27 my $cmd = [@cnv, @$args];
28 my $td = start_script($cmd, undef, { 1 => $w, run_mode => 0 });
29 $args->[0] =~ s!\A(.+?://).*!$1...!;
31 ok($td, "$key running");
32 $run->{$key} = { td => $td, r => $r };
34 while (my ($key, $x) = each %$run) {
35 my ($td, $r) = delete(@$x{qw(td r)});
37 PublicInbox::MboxReader->mboxrd($r, sub {
39 if ($key =~ m!\Anntps?://!i) {
40 for (qw(Xref Newsgroups Path)) {
44 push @{$x->{eml}}, $eml;
51 like($done, qr/\Q$key\E done/, $done);
54 my @keys = keys %$run;
55 my $first_key = shift @keys;
57 is_deeply($run->{$key}, $run->{$first_key},
58 "`$key' matches `$first_key'");