ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/netgeo.pl
(Generate patch)

Comparing Coro/myhttpd/netgeo.pl (file contents):
Revision 1.16 by root, Sat Sep 17 20:21:11 2005 UTC vs.
Revision 1.18 by root, Sat Dec 8 21:01:16 2007 UTC

4 4
5use Socket; 5use Socket;
6use Fcntl; 6use Fcntl;
7 7
8use Coro; 8use Coro;
9use Coro::Event; 9use Coro::EV;
10use Coro::Semaphore; 10use Coro::Semaphore;
11use Coro::SemaphoreSet; 11use Coro::SemaphoreSet;
12use Coro::Socket; 12use Coro::Socket;
13use Coro::Timer; 13use Coro::Timer;
14 14
15use BerkeleyDB; 15use BerkeleyDB;
16
17$Event::DIED = sub {
18 Event::verbose_exception_handler(@_);
19 #Event::unloop_all();
20};
21 16
22tie %netgeo::whois, BerkeleyDB::Btree, 17tie %netgeo::whois, BerkeleyDB::Btree,
23 -Env => $db_env, 18 -Env => $db_env,
24 -Filename => "whois", 19 -Filename => "whois",
25 -Flags => DB_CREATE, 20 -Flags => DB_CREATE,
30 -Flags => DB_CREATE, 25 -Flags => DB_CREATE,
31 or die "unable to create/open iprange table"; 26 or die "unable to create/open iprange table";
32 27
33package Whois; 28package Whois;
34 29
35use Coro::Event; 30use Coro::EV;
36 31
37sub new { 32sub new {
38 my $class = shift; 33 my $class = shift;
39 my $name = shift; 34 my $name = shift;
40 my $ip = shift; 35 my $ip = shift;
121 my ($self, $ip) = @_; 116 my ($self, $ip) = @_;
122 117
123 my $whois = $self->whois_request($ip); 118 my $whois = $self->whois_request($ip);
124 119
125 return if $whois =~ /^No match/; 120 return if $whois =~ /^No match/;
126 return if $whois =~ /^\*de: This network range is not allocated to /; # APINIC e.g. 24.0.0.0
127 121
128 if ($whois =~ /^To single out one record/m) { 122 if ($whois =~ /^To single out one record/m) {
129 my $handle; 123 my $handle;
130 while ($whois =~ /\G\S.*\(([A-Z0-9\-]+)\).*\n/mg) { 124 while ($whois =~ /\G\S.*\(([A-Z0-9\-]+)\).*\n/mg) {
131 $handle = $1; 125 $handle = $1;
231 }gex; 225 }gex;
232 226
233 $whois =~ /^\*in: 0\.0\.0\.0 - 255\.255\.255\.255/ 227 $whois =~ /^\*in: 0\.0\.0\.0 - 255\.255\.255\.255/
234 and return; 228 and return;
235 229
230 $whois =~ /^\*de: This network range is not allocated to /m # APINIC e.g. 24.0.0.0
231 and return;
232
236 $whois =~ /^\*ac: XXX0/m # 192.0.0.0 233 $whois =~ /^\*ac: XXX0/m # 192.0.0.0
237 and return; 234 and return;
238 235
239 $whois =~ /^\*st: (?:ALLOCATED )?UNSPECIFIED/m 236 $whois =~ /^\*st: (?:ALLOCATED )?UNSPECIFIED/m
240 and return; 237 and return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines