/[hydra]/hydra/examples/resolver.pl
ViewVC logotype

Annotation of /hydra/examples/resolver.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Sep 21 13:54:15 2002 UTC (21 years, 7 months ago) by nmav
Branch point for: boas, MAIN
File MIME type: text/plain
Initial revision

1 nmav 1.1 #!/usr/bin/perl
2    
3     # IP address resolver for Boa
4    
5     # If you want an "in place" change to the log file,
6     # change the first line to
7     #!/usr/local/bin/perl -i.bak
8     # Otherwise, send the output of this program wherever you want:
9     # resolver.pl access_log >access_log_resolved
10    
11     $AF_INET = 2;
12    
13     while(<>) {
14     next unless (($ip, $rest) = /([\d\.]+) (.*)/o);
15    
16     if(!$hosts{$ip}) {
17     $packed_ip = pack('C4', split(/\./, $ip));
18     $host = (gethostbyaddr($packed_ip, $AF_INET))[0];
19     $hosts{$ip} = ($host ? $host : $ip);
20     }
21    
22     print "$hosts{$ip} $rest\n";
23     }
24    

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26