aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-10-19 14:36:36 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2014-10-19 14:36:36 +0300
commit03c30147c1c6149af9f8070b7a92b8d0c8d18c42 (patch)
tree777c7d16d53bc2c6bb9aee06c7b70594c158db9d
parent014b0852e307a32cbb6bf27a71d3541f89cc1e84 (diff)
downloaddnstools-03c30147c1c6149af9f8070b7a92b8d0c8d18c42.tar.gz
dnstools-03c30147c1c6149af9f8070b7a92b8d0c8d18c42.tar.bz2
whoseip: minor changes
-rw-r--r--whoseip/Whoseip/DB.pm3
-rw-r--r--whoseip/whoseip.pl35
2 files changed, 25 insertions, 13 deletions
diff --git a/whoseip/Whoseip/DB.pm b/whoseip/Whoseip/DB.pm
index 0e63cdf..fed7cd9 100644
--- a/whoseip/Whoseip/DB.pm
+++ b/whoseip/Whoseip/DB.pm
@@ -774,9 +774,10 @@ sub ipdb_lookup_unlocked($$) {
network => inet_ntoa(pack('N', $r->[0])),
netmask => inet_ntoa(pack('N', $r->[1])),
timestamp => $r->[2],
- ttl => time - $r->[2],
package => 'whoseip',
version => $VERSION );
+ $res{ttl} = $dbf->{ttl} - (time - $r->[2])
+ if (defined($dbf->{ttl}));
@res{keys %{$r->[4]}} = values %{$r->[4]}
if (defined($r->[4]) and ref($r->[4]) eq 'HASH');
return %res;
diff --git a/whoseip/whoseip.pl b/whoseip/whoseip.pl
index 625f441..8070fb8 100644
--- a/whoseip/whoseip.pl
+++ b/whoseip/whoseip.pl
@@ -481,7 +481,7 @@ sub serve {
}
$res{range} = cidr_to_range($res{cidr});
$res{count} = range2count($res{range});
- $res{term} = $term;
+ $res{term} = $term;
$res{source} = 'CACHE';
return %res;
}
@@ -525,6 +525,9 @@ sub serve {
$res{diag} = 'invalid input';
}
$res{source} = 'QUERY';
+ $res{package} = 'whoseip';
+ $res{version} = $Whoseip::DB::VERSION;
+ $res{term} = $term;
return %res;
}
@@ -743,7 +746,7 @@ GetOptions("h" => sub {
) or exit(EX_USAGE);
if (defined($dbfile)) {
- $dbfile .= "whoseip.db" if (-d $dbfile);
+ $dbfile .= "/whoseip.db" if (-d $dbfile);
$dbopt{debug} = $debug;
eval {
$dbf = ipdb_open($dbfile, %dbopt);
@@ -884,15 +887,16 @@ For each IP address, B<whoseip> returns the country it is located in
(a ISO 3166-1 code), the network it belongs to and the number of addresses
in the network.
-The program can operate in several modes.
+The program can operate in several modes: as a standalone command line tool,
+or as a B<CGI> or B<Fast CGI> process.
If the program name ends in B<.fcgi> the B<Fast CGI> mode is enabled.
This mode is also enabled if the command line option B<--fastcgi> is
given without arguments, or if the program name ends in one of the
suffixes supplied in the argument to this option (a whitespace-separated
-list). In this mode, the the IP address to look for is taken from the
+list). In this mode, the IP address to look for is taken from the B<URI>
parameter B<ip>. Additional parameter B<fmt> can be used to supply the
-name of the desired output format. The format must be either one of
+name of the desired output format. Its value must be either a name of one of
the built-in formats, or must be defined using the B<--define-format>
option (see below). As a shortcut, the invocation command line containing
an IP alone is also recognized.
@@ -993,7 +997,14 @@ The following example illustrates the reply if the IP is not found:
See the section B<FORMAT> below for a discussion on how to customize
output formats.
-
+
+=head2 Caching
+
+To minimize number of queries to external B<whois> servers, it is recommended
+to use a cache database. It is enabled by using the B<--cache-file=I<FILENAME>>
+option (or B<cache-file> configuration file statement). A B<time to live>
+for the cached records can be set using the B<--cache-ttl> option.
+
=head1 OPTIONS
=over 4
@@ -1024,21 +1035,21 @@ in inetd mode. See the section B<FORMAT>, for a detailed discussion.
=item B<--export>
-Export the IP database into portable ASCII dump file. If a singe argument
-is supplied, it gives the name of the output file. In the absense of
-arguments, the output goes to the standard output.
+Export the IP database into portable ASCII dump file. If a single argument
+is supplied, it gives the name of the output file. In the absence of
+arguments, standard output is used.
The created file can be transmitted over the network to hosts of another
-architecture and used there to recreate the database, using the
+architecture and used there to recreate the database via
B<whoseip --import>.
=item B<--fastcgi=>[I<SUFFIX...>]
-When used without argument, forces FastCGI mode. If an argument is given,
+When used without argument, forces B<FastCGI> mode. If an argument is given,
it is treated as a whitespace-separated list of suffixes. In this case,
FastCGI mode is enabled if the program name ends in one of these suffixes.
-If this option is not give, FastCGI is enabled if the program name ends
+If this option is not given, FastCGI is enabled if the program name ends
in B<.fcgi>.
=item B<-f>, B<--format=>I<STRING>

Return to:

Send suggestions and report system problems to the System administrator.