unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 7/8] xt/lei-onion-convert: test TLS + SOCKS
Date: Tue,  3 Oct 2023 06:43:51 +0000	[thread overview]
Message-ID: <20231003064352.2902298-8-e@80x24.org> (raw)
In-Reply-To: <20231003064352.2902298-1-e@80x24.org>

While .onion URLs don't commonly use TLS, using Tor to access
non-.onion URLs is possible and TLS is advisable in that case.

TLS + SOCKS support is also useful for non-Tor SOCKS proxies
(e.g. "ssh -D"), but 127.0.0.1:9050 (Tor) is probably the most
standardized address.

While we're in the area: switch to v5.12, use autodie, and
ensure all necessary modules are present.
---
 xt/lei-onion-convert.t | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/xt/lei-onion-convert.t b/xt/lei-onion-convert.t
index 6dd17065..d3afbbb9 100644
--- a/xt/lei-onion-convert.t
+++ b/xt/lei-onion-convert.t
@@ -1,10 +1,12 @@
 #!perl -w
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use strict; use v5.10; use PublicInbox::TestCommon;
+use v5.12; use PublicInbox::TestCommon;
 use PublicInbox::MboxReader;
+use autodie qw(pipe close);
 my $test_tor = $ENV{TEST_TOR};
 plan skip_all => "TEST_TOR unset" unless $test_tor;
+require_mods qw(IO::Socket::Socks IO::Socket::SSL Mail::IMAPClient Net::NNTP);
 unless ($test_tor =~ m!\Asocks5h://!i) {
 	my $default = 'socks5h://127.0.0.1:9050';
 	diag "using $default (set TEST_TOR=socks5h://ADDR:PORT to override)";
@@ -19,11 +21,24 @@ my @cnv = qw(lei convert -o mboxrd:/dev/stdout);
 my @proxy_cli = ("--proxy=$test_tor");
 my $proxy_cfg = "proxy=$test_tor";
 test_lei(sub {
+	# ensure TLS + SOCKS works
+	ok !lei(qw(ls-mail-source imaps://mews.public-inbox.org/
+		-c), "imap.$proxy_cfg"),
+		'imaps fails on wrong hostname w/ Tor';
+	ok !lei(qw(ls-mail-source nntps://mews.public-inbox.org/
+		-c), "nntp.$proxy_cfg"),
+		'nntps fails on wrong hostname w/ Tor';
+
+	lei_ok qw(ls-mail-source imaps://news.public-inbox.org/
+		-c), "imap.$proxy_cfg";
+	lei_ok qw(ls-mail-source nntps://news.public-inbox.org/
+		-c), "nntp.$proxy_cfg";
+
 	my $run = {};
 	for my $args ([$nntp_url, @proxy_cli], [$imap_url, @proxy_cli],
 			[ $nntp_url, '-c', "nntp.$proxy_cfg" ],
 			[ $imap_url, '-c', "imap.$proxy_cfg" ]) {
-		pipe(my ($r, $w)) or xbail "pipe: $!";
+		pipe(my $r, my $w);
 		my $cmd = [@cnv, @$args];
 		my $td = start_script($cmd, undef, { 1 => $w, run_mode => 0 });
 		$args->[0] =~ s!\A(.+?://).*!$1...!;

  parent reply	other threads:[~2023-10-03  6:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03  6:43 [PATCH 0/8] IMAP/NNTP client improvements Eric Wong
2023-10-03  6:43 ` [PATCH 1/8] net_reader: bail out on NNTP SOCKS connection failure Eric Wong
2023-10-03  6:43 ` [PATCH 2/8] net_reader: avoid IO::Socket::SSL 2.079..2.081 warning Eric Wong
2023-10-03  6:43 ` [PATCH 3/8] config: fix key-only truthy values with urlmatch Eric Wong
2023-10-03  6:43 ` [PATCH 4/8] net_reader: support imap.sslVerify + nntp.sslVerify Eric Wong
2023-10-03  6:43 ` [PATCH 5/8] lei: workers exit after they tell lei-daemon Eric Wong
2023-10-03  6:43 ` [PATCH 6/8] net_reader: process title reflects NNTP article Eric Wong
2023-10-03  6:43 ` Eric Wong [this message]
2023-10-03  6:43 ` [PATCH 8/8] net_reader: note glob support in .onion hint Eric Wong
2023-10-03  7:11 ` "SSL" in option names is weird in 2023 Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231003064352.2902298-8-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).