--- Coro/myhttpd/access.pl 2001/08/16 16:40:07 1.5
+++ Coro/myhttpd/access.pl 2001/08/19 23:57:52 1.6
@@ -1,11 +1,12 @@
-our @blocklist;
+our @blockuri;
+our @blockref;
-sub read_blocklist {
+sub read_blockuri {
local *B;
my %group;
- @blocklist = ();
- if (open B, ") {
chomp;
if (/^group\s+(\S+)\s+(.*)/i) {
@@ -17,52 +18,46 @@
push @r, $group{$_} ? @{$group{$_}} : $_;
}
print "not($g) => (@r)\n";
- push @blocklist, [qr/$g/i, \@r];
+ push @blockuri, [qr/$g/i, \@r];
} elsif (/\S/) {
- print "blocklist: unparsable line: $_\n";
+ print "blockuri: unparsable line: $_\n";
}
}
} else {
- print "no blocklst\n";
+ print "no blockuri\n";
}
}
-read_blocklist;
-
-use Tie::Cache;
-tie %whois_cache, Tie::Cache::, $MAX_CONNECTS * 1.5;
-
-sub conn::access_check {
- my $self = shift;
-
- my $uri = $self->{path};
- my %disallow;
-
- for (@blocklist) {
- if ($uri =~ $_->[0]) {
- $disallow{$_}++ for @{$_->[1]};
+sub read_blockref {
+ local *B;
+ @blockref = ();
+ if (open B, ") {
+ chomp;
+ if (/^([^\t]*)\t\s*(.*)/) {
+ push @blockref, qr/^$1/i;
+ } elsif (/\S/) {
+ print "blockref: unparsable line: $_\n";
+ }
}
- }
-
- my $whois = $whois_cache{$self->{remote_addr}}
- ||= ::ip_request($self->{remote_addr});
-
- my $country = "XX";
-
- if ($whois =~ /^\*cy: (\S+)/m) {
- $country = uc $1;
} else {
- $self->slog(9, "no country($whois)");
+ print "no blockref\n";
}
+}
- $self->{country} = $country;
+read_blockuri;
+read_blockref;
- if ($disallow{$country}) {
- $self->slog(6, "DISALLOW($uri,$country)");
+use Tie::Cache;
+tie %whois_cache, Tie::Cache::, $MAX_CONNECTS * 1.5;
- $whois =~ s/&/&/g;
- $whois =~ s/</g;
- $self->err(403, "forbidden", { "Content-Type" => "text/html" }, <err(403, "forbidden", { "Content-Type" => "text/html" }, <
This material is licensed in your country!
@@ -73,7 +68,7 @@
My research has shown that your IP address
($self->{remote_addr}) most probably is located in this country:
-$country (ISO-3166-2 code, XX == unknown). The full record is:
+$self->{country} (ISO-3166-2 code, XX == unknown). The full record is:
$whois
@@ -97,6 +92,85 @@