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
|
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use English;
my $user_agent =
LWP::UserAgent->new(env_proxy => 1,
keep_alive => 1,
timeout => 30 );
for my $arg (@ARGV) {
my $uri = URI->new($arg);
if ($user_agent->is_protocol_supported( $uri )) {
my $response = $user_agent->get($arg);
unless ($response->is_success) {
warn ("$PROGRAM_NAME: Get failed for $arg (".$response->code()." ".$response->message().")\n");
next;
}
my $content = $response->content;
my @uris = $content =~ m/href = "? (.*?) (?:"|>)/xig;
my $base = $arg;
$base =~ s,/[^/]*$,,;
@uris = map { $_ = /:/ ? $_ : $base.'/'.$_; s,i(?<=[^:])//,/,g; s,/[^/]*?/../,/,; $_; } @uris;
my $workaround_echolot = $content =~ m,palfrader.org/echolot,;
my %resources;
for (@uris) {
$resources{'rlist'} = $_ if (/rlist1?(?:\.txt)?$|MyCypSta1\.txt$/i);
$resources{'mlist'} = $_ if (/mlist1?(?:\.txt)?$|mixlist(?:\.txt)?$|MyMixSta1\.txt$/i);
$resources{'rlist_html'} = $_ if (/rlist1?\.[sp]?html$|MyCypSta1\.[sp]?html$|remailer-list\.[sp]?html$/i);
$resources{'mlist_html'} = $_ if (/mlist1?\.[sp]?html$|mixlist\.[sp]?html$|MyMixSta1\.[sp]?html$|mixmaster-list\.[sp]?html$/i);
$resources{'rlist2'} = $_ if (/rlist2(?:\.txt)?$|MyCypSta2\.txt$/i);
$resources{'mlist2'} = $_ if (/mlist2(?:\.txt)?$|mixlist2(?:\.txt)?$|MyMixSta2\.txt$/i);
$resources{'rlist2_html'} = $_ if (/rlist2\.[sp]?html$|MyCypSta2\.[sp]?html$/i);
$resources{'mlist2_html'} = $_ if (/mlist2\.[sp]?html$|mixlist2\.[sp]?html$|MyMixSta2\.[sp]?html$/i);
$resources{'rchain'} = $_ if (/rchain(?:\.txt)?$|MyRChain\.txt$/i);
$resources{'rchain_html'} = $_ if (/rchain\.[sp]?html$|MyRChain\.[sp]?html$/i);
$resources{'pgpring'} = $_ if (/pubring(-all)?\.asc$|pgp-all.asc$|rsa-dss\.asc$|rsa\+dss.asc/i);
$resources{'pgpring_rsa'} = $_ if (/pubring-?rsa\.asc$|pgp-rsa\.asc$|rsa-only\.asc$|rsakeys\.asc|rsa.asc/i);
$resources{'mixring'} = $_ if (/pubring\.mix$/i);
$resources{'type2list'} = $_ if (/type2\.list?$/i);
}
if ($workaround_echolot) {
my $warned = 0;
for my $file (qw{rlist mlist rlist2 mlist2}) {
unless (defined ($resources{$file})) {
warn("Guessing echolot stats\n"), $warned++ unless ($warned);
$resources{$file} = $resources{$file.'_html'};
$resources{$file} =~ s/\.html$/.txt/;
}
}
};
printf ("%-12s= %s\n", 'base', $arg);
for my $key (qw{rlist mlist rlist2 mlist2 rlist_html mlist_html rlist2_html mlist2_html rchain rchain_html pgpring pgpring_rsa mixring type2list}) {
printf ("%-12s= %s\n", $key, $resources{$key}) if defined $resources{$key};
}
} else {
warn ("$PROGRAM_NAME: Protocoll for '$arg' not supported\n");
};
}
# vim:set ts=2:
# vim:set shiftwidth=2:
|