user/dev discussion of public-inbox itself
 help / color / Atom feed
3f05b68a368403d7acecac6b9b83ab0b7a87aa12 blob 1723 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
# Copyright (C) 2015-2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD);
use POSIX qw(dup2);
use strict;
use warnings;

sub stream_to_string {
	my ($res) = @_;
	my $body = $res->[2];
	my $str = '';
	while (defined(my $chunk = $body->getline)) {
		$str .= $chunk;
	}
	$body->close;
	$str;
}

sub tcp_server () {
	IO::Socket::INET->new(
		LocalAddr => '127.0.0.1',
		ReuseAddr => 1,
		Proto => 'tcp',
		Type => Socket::SOCK_STREAM(),
		Listen => 1024,
	)
}

sub unix_server ($) {
	IO::Socket::UNIX->new(
		Listen => 1024,
		Type => Socket::SOCK_STREAM(),
		Local => $_[0],
	)
}

sub spawn_listener {
	my ($env, $cmd, $socks) = @_;
	my $pid = fork;
	defined $pid or die "fork failed: $!\n";
	if ($pid == 0) {
		# pretend to be systemd (cf. sd_listen_fds(3))
		my $fd = 3; # 3 == SD_LISTEN_FDS_START
		foreach my $s (@$socks) {
			my $fl = fcntl($s, F_GETFD, 0);
			if (($fl & FD_CLOEXEC) != FD_CLOEXEC) {
				warn "got FD:".fileno($s)." w/o CLOEXEC\n";
			}
			fcntl($s, F_SETFD, $fl &= ~FD_CLOEXEC);
			dup2(fileno($s), $fd++) or die "dup2 failed: $!\n";
		}
		$ENV{LISTEN_PID} = $$;
		$ENV{LISTEN_FDS} = scalar @$socks;
		%ENV = (%ENV, %$env) if $env;
		exec @$cmd;
		die "FAIL: ",join(' ', @$cmd), ": $!\n";
	}
	$pid;
}

sub require_git ($;$) {
	my ($req, $maybe) = @_;
	my ($req_maj, $req_min) = split(/\./, $req);
	my ($cur_maj, $cur_min) = (`git --version` =~ /version (\d+)\.(\d+)/);

	my $req_int = ($req_maj << 24) | ($req_min << 16);
	my $cur_int = ($cur_maj << 24) | ($cur_min << 16);
	if ($cur_int < $req_int) {
		return 0 if $maybe;
		plan skip_all => "git $req+ required, have $cur_maj.$cur_min";
	}
	1;
}

1;
debug log:

solving 3f05b68a ...
found 3f05b68a in https://80x24.org/public-inbox.git

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git