Skip to content

Commit

Permalink
merge gunnar wolf's ipv6 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mla committed Feb 27, 2012
1 parent 23e29d7 commit 0bec752
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ip2host
Expand Up @@ -8,8 +8,6 @@
# For a usage summary, run: ip2host --usage # For a usage summary, run: ip2host --usage
# For documentation, run: perldoc ip2host # For documentation, run: perldoc ip2host


# $Id: ip2host 24 2007-01-27 05:33:06Z mla $

our $CHILDREN = 40; # Number of processes to fork our $CHILDREN = 40; # Number of processes to fork
our $TIMEOUT = 20; # DNS timeout our $TIMEOUT = 20; # DNS timeout
our $BUFFER = 50000; # Maximum number of log lines to keep in memory our $BUFFER = 50000; # Maximum number of log lines to keep in memory
Expand All @@ -30,7 +28,7 @@ use IO::Handle;
use IO::Select; use IO::Select;
use Getopt::Long; use Getopt::Long;


our $VERSION = '1.10'; our $VERSION = '1.12';


BEGIN { BEGIN {
package IP_Cache; package IP_Cache;
Expand Down Expand Up @@ -115,13 +113,15 @@ sub resolve_ips($) {
chomp($ip); chomp($ip);
my $host = undef; my $host = undef;
eval { # Try to resolve, but give up after $TIMEOUT seconds eval { # Try to resolve, but give up after $TIMEOUT seconds
my ($ip_struct);
alarm($Opt{timeout}); alarm($Opt{timeout});

my $ip_struct;
if ($ip_struct = inet_aton($ip)) { if ($ip_struct = inet_aton($ip)) {
$host = gethostbyaddr $ip_struct, AF_INET; $host = gethostbyaddr $ip_struct, AF_INET;
} elsif ($ip_struct = Socket::inet_pton(AF_INET6, $ip)) { } elsif ($ip_struct = Socket::inet_pton(AF_INET6, $ip)) {
$host = gethostbyaddr $ip_struct, AF_INET6; $host = gethostbyaddr $ip_struct, AF_INET6;
} }

alarm(0); alarm(0);
}; };
# XXX Debug # XXX Debug
Expand Down

0 comments on commit 0bec752

Please sign in to comment.