diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2005-05-09 20:38:03 +0200 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2005-05-09 20:38:03 +0200 |
commit | 4036ad2a9afa4417c670fc52eaf67da37b0f8e45 (patch) | |
tree | 72cb7177c8805ff9061138d86c3441886ed10016 | |
parent | e5123e033bdae8ceaf9ba847b929ec56d9dfa1e8 (diff) | |
download | smokeping-4036ad2a9afa4417c670fc52eaf67da37b0f8e45.tar.gz smokeping-4036ad2a9afa4417c670fc52eaf67da37b0f8e45.tar.xz |
Double check the answer from the dns server and optionally enforce a
NOERROR response code -- Christoph.Heine in HaDiKo.DE
-rw-r--r-- | lib/Smokeping/probes/AnotherDNS.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Smokeping/probes/AnotherDNS.pm b/lib/Smokeping/probes/AnotherDNS.pm index 65a1bd4..d4f0397 100644 --- a/lib/Smokeping/probes/AnotherDNS.pm +++ b/lib/Smokeping/probes/AnotherDNS.pm @@ -69,6 +69,7 @@ sub pingone ($) { my $recordtype = $target->{vars}{recordtype}; my $timeout = $target->{vars}{timeout}; my $port = $target->{vars}{port}; + my $require_noerror = $target->{vars}{require_noerror}; $lookuphost = $target->{addr} unless defined $lookuphost; my $packet = Net::DNS::Packet->new( $lookuphost, $recordtype )->data; @@ -93,9 +94,20 @@ sub pingone ($) { my $t1 = [gettimeofday]; $elapsed = tv_interval( $t0, $t1 ); if ( defined $ready ) { - push @times, $elapsed; my $buf = ''; $ready->recv( $buf, &Net::DNS::PACKETSZ ); + my ($recvPacket, $err) = Net::DNS::Packet->new(\$buf); + if (defined $recvPacket) { + if (not $require_noerror) { + push @times, $elapsed; + } else { + # Check the Response Code for the NOERROR. + my $recvHeader = $recvPacket->header(); + if ($recvHeader->rcode() eq "NOERROR") { + push @times, $elapsed; + } + } + } } } @times = @@ -127,6 +139,10 @@ DOC _default => .5, _re => '(\d*\.)?\d+', }, + require_noerror => { + _doc => 'Only Count Answers with Response Status NOERROR.', + _default => 0, + }, recordtype => { _doc => 'Record type to look up.', _default => 'A', |