Set default timeout for DNS lookup to 100ms, default value for DNSLookupTimeout is now 0.0001 second.

This commit is contained in:
Darold Gilles 2013-12-01 16:22:46 +01:00
parent c6163b817a
commit b1810b233b
4 changed files with 13 additions and 13 deletions

6
README
View File

@ -189,11 +189,11 @@ CONFIGURATION
DNS name instead. Note that you must have a working DNS resolution
and that it can really slow down the generation of reports.
DNSLookupTimeout 1
DNSLookupTimeout 0.0001
If you have enabled UseClientDNSName and have lot of ip addresses
that do not resolve you may want to increase the DNS lookup timeout.
By default SquidAnalyzer will stop to lookup a DNS name after one
second.
By default SquidAnalyzer will stop to lookup a DNS name after 0.0001
second (100 ms).
NetworkAlias network-aliases_file
Set path to the file containing network alias name. Network are show

View File

@ -19,6 +19,7 @@ BEGIN {
use POSIX qw/ strftime /;
use IO::File;
use Socket;
use Time::HiRes qw/ualarm/;
# Set all internal variable
$VERSION = '5.3';
@ -652,7 +653,8 @@ sub _init
$self->{TopUrlUser} = $options{TopUrlUser} || 0;
$self->{no_year_stat} = 0;
$self->{UseClientDNSName} = $options{UseClientDNSName} || 0;
$self->{DNSLookupTimeout} = $options{DNSLookupTimeout} || 1;
$self->{DNSLookupTimeout} = $options{DNSLookupTimeout} || 0.0001;
$self->{DNSLookupTimeout} = int($self->{DNSLookupTimeout} * 1000000);
if ($self->{Lang}) {
open(IN, "$self->{Lang}") or die "ERROR: can't open translation file $self->{Lang}, $!\n";
@ -807,15 +809,13 @@ sub _gethostbyaddr
{
my ($self, $ip) = @_;
return $ip unless $ip=~/\d+\.\d+\.\d+\.\d+/;
my $host = undef;
unless(exists $CACHE{$ip}) {
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm $self->{DNSLookupTimeout};
local $SIG{ALRM} = sub { die "DNS lookup timeout.\n"; };
ualarm $self->{DNSLookupTimeout};
$host = gethostbyaddr(inet_aton($ip), AF_INET);
alarm 0;
ualarm 0;
};
if ($@) {
$CACHE{$ip} = undef;

View File

@ -199,11 +199,11 @@ the client ip address, this allow you to use the DNS name instead.
Note that you must have a working DNS resolution and that it can really slow
down the generation of reports.
=item DNSLookupTimeout 1
=item DNSLookupTimeout 0.0001
If you have enabled UseClientDNSName and have lot of ip addresses that do not
resolve you may want to increase the DNS lookup timeout. By default SquidAnalyzer
will stop to lookup a DNS name after one second.
will stop to lookup a DNS name after 0.0001 second (100 ms).
=item NetworkAlias network-aliases_file

View File

@ -22,8 +22,8 @@ UseClientDNSName 0
# If you have enabled UseClientDNSName and have lot of ip addresses that do
# not resolve you may want to increase the DNS lookup timeout. By default
# SquidAnalyzer will stop to lookup a DNS name after one second.
DNSLookupTimeout 1
# SquidAnalyzer will stop to lookup a DNS name after 0.0001 second (100 ms).
DNSLookupTimeout 0.0001
# Set the file containing network alias name. Network are
# show as Ip addresses so if you want to display name instead