user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
65d5a76c09b43f4dec2edb08998c22ffe6d6e95e blob 791 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
 
# Copyright (C) 2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

package PublicInbox::ContentId;
use strict;
use warnings;
use base qw/Exporter/;
our @EXPORT_OK = qw/content_id/;

# not sure if less-widely supported hash families are worth bothering with
use Digest::SHA;

# Content-* headers are often no-ops, so maybe we don't need them
my @ID_HEADERS = qw(Subject From Date Message-ID References To Cc In-Reply-To);

sub content_id ($;$) {
	my ($mime, $alg) = @_;
	$alg ||= 256;
	my $dig = Digest::SHA->new($alg);
	my $hdr = $mime->header_obj;

	foreach my $h (@ID_HEADERS) {
		my @v = $hdr->header_raw($h);
		$dig->add($_) foreach @v;
	}
	$dig->add($mime->body_raw);
	'SHA-' . $dig->algorithm . ':' . $dig->hexdigest;
}

1;
debug log:

solving 65d5a76 ...
found 65d5a76 in public-inbox.git

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	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

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.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/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

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