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} //'ou63pmih66umazou.onion';
14 my $ng = 'inbox.comp.mail.public-inbox.meta';
15 my $nntp_url = $ENV{TEST_NNTP_ONION_URL} // "nntp://$onion/$ng";
16 my $imap_url = $ENV{TEST_IMAP_ONION_URL} // "imap://$onion/$ng.0";
17 my @cnv = qw(lei convert -o mboxrd:/dev/stdout);
18 my @proxy_cli = ("--proxy=$test_tor");
19 my $proxy_cfg = "proxy=$test_tor";
22 for my $args ([$nntp_url, @proxy_cli], [$imap_url, @proxy_cli],
23 [ $nntp_url, '-c', "nntp.$proxy_cfg" ],
24 [ $imap_url, '-c', "imap.$proxy_cfg" ]) {
25 pipe(my ($r, $w)) or xbail "pipe: $!";
26 my $cmd = [@cnv, @$args];
27 my $td = start_script($cmd, undef, { 1 => $w, run_mode => 0 });
28 $args->[0] =~ s!\A(.+?://).*!$1...!;
30 ok($td, "$key running");
31 $run->{$key} = { td => $td, r => $r };
33 while (my ($key, $x) = each %$run) {
34 my ($td, $r) = delete(@$x{qw(td r)});
36 PublicInbox::MboxReader->mboxrd($r, sub {
38 if ($key =~ m!\Anntps?://!i) {
39 for (qw(Xref Newsgroups Path)) {
43 push @{$x->{eml}}, $eml;
50 like($done, qr/\Q$key\E done/, $done);
53 my @keys = keys %$run;
54 my $first_key = shift @keys;
56 is_deeply($run->{$key}, $run->{$first_key},
57 "`$key' matches `$first_key'");