aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-10-16 17:40:33 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2014-10-16 17:44:04 +0300
commitb042d54681f0b8a3eecfd5debc1f2d76ecdcf4d7 (patch)
treed01ebb9d892118038dcbaf2e5bcd1bed8b0d698b
parent4005897a75d88355c6da8513bf7a4a13c301c97a (diff)
downloaddnstools-b042d54681f0b8a3eecfd5debc1f2d76ecdcf4d7.tar.gz
dnstools-b042d54681f0b8a3eecfd5debc1f2d76ecdcf4d7.tar.bz2
whoseip: bugfixes
* whoseip.pl (ripe_decode): Handle %ERROR return (whois): Add server, port, and term keys to the %res. Correctly remove line terminators and trailing whitespace. (serve): pass server and port to ipdb_insert Update docs.
-rw-r--r--whoseip/whoseip.pl26
1 files changed, 18 insertions, 8 deletions
diff --git a/whoseip/whoseip.pl b/whoseip/whoseip.pl
index d64280e..d5f58d0 100644
--- a/whoseip/whoseip.pl
+++ b/whoseip/whoseip.pl
@@ -210,8 +210,11 @@ use constant RIPE_IGNR => 2;
sub ripe_decode {
my ($input, $ref) = @_;
- return if ($input =~ /^%/);
+ error("WHOIS($ref->{server}:$ref->{port}): $1")
+ if ($input =~ /^%ERROR:(.+)/);
+ return if ($input =~ /^%/);
+
if ($ref->{state} == RIPE_INIT) {
if ($input eq '') {
return;
@@ -421,9 +424,9 @@ sub whois($$) {
}
local $/ = LF;
- my %res;
+ my %res = (server => $server, port => $port, term => $ip);
while (<$sock>) {
- chomp;
+ s/\s*$CR?$LF$//;
debug(4, "RECV: $_");
if (/%% referto: whois -h (\S+) -p (\S+)/) {
$res{referto} = "$1:$2";
@@ -437,9 +440,6 @@ sub whois($$) {
}
}
close $sock;
-# while (my ($k,$v) = each %res) {
-# print "$k $v\n";
-# }
return %res;
}
@@ -481,7 +481,10 @@ sub serve {
$res{status} = 'OK';
if (defined($dbf)) {
foreach my $cidr (split /,/, $res{cidr}) {
- ipdb_insert($dbf, $cidr, $res{country}, cidr=>$res{cidr});
+ ipdb_insert($dbf, $cidr, $res{country},
+ cidr => $res{cidr},
+ server => $res{server},
+ port => $res{port});
}
}
}
@@ -494,7 +497,6 @@ sub serve {
$res{diag} = 'invalid input';
}
$res{source} = 'QUERY';
- $res{term} = $term;
return %res;
}
@@ -1097,6 +1099,14 @@ Where the information was obtained from. B<QUERY>, if it was retrieved
from a remote B<whois> server and B<CACHE>, if it was read from the
cache database.
+=item B<${server}>
+
+Whois server that returned the information.
+
+=item B<${port}>
+
+Port used to query the whois server.
+
=back
If a macro is not defined, the corresponding reference expands to

Return to:

Send suggestions and report system problems to the System administrator.