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.12 by root, Tue Sep 10 04:37:44 2002 UTC vs.
Revision 1.16 by root, Sat Sep 17 20:21:11 2005 UTC

8use Coro; 8use Coro;
9use Coro::Event; 9use Coro::Event;
10use Coro::Semaphore; 10use Coro::Semaphore;
11use Coro::SemaphoreSet; 11use Coro::SemaphoreSet;
12use Coro::Socket; 12use Coro::Socket;
13use Coro::Timer;
13 14
14use BerkeleyDB; 15use BerkeleyDB;
15 16
16$Event::DIED = sub { 17$Event::DIED = sub {
17 Event::verbose_exception_handler(@_); 18 Event::verbose_exception_handler(@_);
83 $timeout *= 2; 84 $timeout *= 2;
84 $timeout = 1 if $timeout > 600; 85 $timeout = 1 if $timeout > 600;
85 } else { 86 } else {
86 last; 87 last;
87 } 88 }
89 } else {
90 # only retry once a minute
91 print STDERR "unable to connect to $self->{ip} ($self->{name}), retrying...\n";
92 Coro::Timer::sleep 300;
88 } 93 }
89 } 94 }
90 95
91 $netgeo::whois{$id} = $whois; 96 $netgeo::whois{$id} = $whois;
92 } 97 }
115sub ip_request { 120sub ip_request {
116 my ($self, $ip) = @_; 121 my ($self, $ip) = @_;
117 122
118 my $whois = $self->whois_request($ip); 123 my $whois = $self->whois_request($ip);
119 124
120 return () if $whois =~ /^No match/; 125 return if $whois =~ /^No match/;
126 return if $whois =~ /^\*de: This network range is not allocated to /; # APINIC e.g. 24.0.0.0
121 127
122 if ($whois =~ /^To single out one record/m) { 128 if ($whois =~ /^To single out one record/m) {
123 my $handle; 129 my $handle;
124 while ($whois =~ /\G\S.*\(([A-Z0-9\-]+)\).*\n/mg) { 130 while ($whois =~ /\G\S.*\(([A-Z0-9\-]+)\).*\n/mg) {
125 $handle = $1; 131 $handle = $1;
126 #return if $handle =~ /-(RIPE|APNIC)/; # heuristic, bbut bad because ripe might not have better info 132 #return if $handle =~ /-(RIPE|APNIC)/; # heuristic, but bad because ripe might not have better info
127 } 133 }
128 $handle or die "$whois ($ip): unparseable multimatch\n"; 134 $handle or die "$whois ($ip): unparseable multimatch\n";
129 $whois = $self->whois_request("!$handle"); 135 $whois = $self->whois_request("!$handle");
130 } 136 }
131 137
311 317
312our %WHOIS; 318our %WHOIS;
313 319
314#$WHOIS{ARIN} = new Whois::ARIN ARIN => "whois.arin.net", port => 43, maxjobs => 12; 320#$WHOIS{ARIN} = new Whois::ARIN ARIN => "whois.arin.net", port => 43, maxjobs => 12;
315$WHOIS{ARIN} = new Whois::RWHOIS ARIN => "rwhois.arin.net", port => 4321, maxjobs => 12; 321$WHOIS{ARIN} = new Whois::RWHOIS ARIN => "rwhois.arin.net", port => 4321, maxjobs => 12;
316$WHOIS{RIPE} = new Whois::RIPE RIPE => "whois.ripe.net", port => 43, rflags => "-FSTin ", maxjobs => 20; 322$WHOIS{RIPE} = new Whois::RIPE RIPE => "whois.ripe.net", port => 43, rflags => "-FTin ", maxjobs => 20;
317$WHOIS{APNIC} = new Whois::RIPE APNIC => "whois.apnic.net", port => 43, rflags => "-FSTin ", maxjobs => 20; 323$WHOIS{APNIC} = new Whois::RIPE APNIC => "whois.apnic.net", port => 43, rflags => "-FTin ", maxjobs => 20;
318$WHOIS{LACNIC} = new Whois::RIPE LACNIC => "whois.lacnic.net", port => 43, maxjobs => 20; 324$WHOIS{LACNIC} = new Whois::RIPE LACNIC => "whois.lacnic.net", port => 43, maxjobs => 20;
319 325
320$whoislock = new Coro::SemaphoreSet; 326$whoislock = new Coro::SemaphoreSet;
321 327
322sub ip_request { 328sub ip_request {
336 } 342 }
337 343
338 my ($arin, $ripe, $apnic); 344 my ($arin, $ripe, $apnic);
339 345
340 $whois = $WHOIS{RIPE}->ip_request($ip) 346 $whois = $WHOIS{RIPE}->ip_request($ip)
341 || $WHOIS{LACNIC}->ip_request($ip)
342 || $WHOIS{APNIC} ->ip_request($ip) 347 || $WHOIS{APNIC} ->ip_request($ip)
343 || $WHOIS{ARIN} ->ip_request($ip) 348 || $WHOIS{ARIN} ->ip_request($ip)
349# || $WHOIS{LACNIC}->ip_request($ip)
344 ; 350 ;
345 351
346 $whois =~ /^\*in: ([0-9.]+)\s+-\s+([0-9.]+)\s*$/mi 352 $whois =~ /^\*in: ([0-9.]+)\s+-\s+([0-9.]+)\s*$/mi
347 or do { warn "$whois($ip): no addresses found\n", last }; 353 or do { warn "$whois($ip): no addresses found\n", last };
348 354
372 #print "\n\n"; 378 #print "\n\n";
373 #print ip_request "62.116.167.250"; 379 #print ip_request "62.116.167.250";
374 #print "\n\n"; 380 #print "\n\n";
375 #print ip_request "133.11.128.254"; # jp 381 #print ip_request "133.11.128.254"; # jp
376 #print "\n\n"; 382 #print "\n\n";
377 #print ip_request "151.197.52.251"; 383 print ip_request "80.131.153.93";
378 #print "\n\n"; 384 print "\n\n";
379} 385}
380 386
3811; 3871;
382 388
383 389

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines