summaryrefslogtreecommitdiff
path: root/bin/guess-uris
diff options
context:
space:
mode:
Diffstat (limited to 'bin/guess-uris')
-rwxr-xr-xbin/guess-uris68
1 files changed, 68 insertions, 0 deletions
diff --git a/bin/guess-uris b/bin/guess-uris
new file mode 100755
index 0000000..9b858d7
--- /dev/null
+++ b/bin/guess-uris
@@ -0,0 +1,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: