user/dev discussion of public-inbox itself
 help / color / Atom feed
6f839c555eeadf85f156deadf8b1e8a72f9a36b4 blob 1585 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
 
#!/usr/bin/perl -w
# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Useful for mapping article IDs from existing NNTP servers to MIDs
use strict;
use warnings;
use Net::NNTP;
use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
my $usage = "usage: NNTPSERVER=news.example.org $0 GROUP [FIRST_NUM]\n";
my ($msgmap, $mm);
my %opts = ( '--msgmap=s' => \$msgmap );
GetOptions(%opts) or die "bad command-line args\n$usage";

if ($msgmap) {
	require PublicInbox::Msgmap;
	require PublicInbox::MID; # mid_clean
	$mm = PublicInbox::Msgmap->new_file($msgmap, 1);
}

my $group = shift or die $usage;
my $nntp = Net::NNTP->new($ENV{NNTPSERVER} || '127.0.0.1');
my ($num, $first, $last) = $nntp->group($group);
die "Invalid group\n" if !(defined $num && defined $first && defined $last);
my $arg_first = shift;
if (defined $arg_first) {
	$arg_first =~ /\A\d+\z/ or die $usage;
	$first = $arg_first;
} elsif ($mm) {
	my $last_article = $mm->meta_accessor('last_article');
	$first = $last_article + 1 if defined $last_article;
}

my $batch = 1000;
my $i;
for ($i = $first; $i < $last; $i += $batch) {
	my $j = $i + $batch - 1;
	$j = $last if $j > $last;
	my $num2mid = $nntp->xhdr('Message-ID', "$i-$j");

	$mm->{dbh}->begin_work if $mm;
	for my $n ($i..$j) {
		defined(my $mid = $num2mid->{$n}) or next;
		print "$n $mid\n";
		if ($mm) {
			$mid = PublicInbox::MID::mid_clean($mid);
			$mm->mid_set($n, $mid);
		}
	}
	if ($mm) {
		$mm->meta_accessor('last_article', $j);
		$mm->{dbh}->commit;
	}
}
debug log:

solving 6f839c5 ...
found 6f839c5 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