ans.pl revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
#
# Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
use strict;
use warnings;
$pidf->close or die "cannot close pid file: $!";
my $count = 0;
my $send_response = 0;
sub getlimit {
if ( -e "ans.limit") {
chomp $line;
close FH;
if ($line =~ /^\d+$/) {
return $line;
}
}
return 0;
}
my $localaddr = "10.53.0.2";
my $localport = 5300;
my $verbose = 0;
sub reply_handler {
print ("request: $qname/$qtype\n");
$count += 1;
if ($qname eq "count" ) {
if ($qtype eq "TXT") {
print ("\tcount: $count\n");
}
$rcode = "NOERROR";
} elsif ($qname eq "reset" ) {
$count = 0;
$send_response = 0;
$rcode = "NOERROR";
print ("\tlimit: $limit\n");
} elsif ($qname eq "direct.example.org" ) {
if ($qtype eq "A") {
}
$rcode = "NOERROR";
} elsif ($qname eq "indirect1.example.org" ||
$qname eq "indirect2.example.org" ||
$qname eq "indirect3.example.org" ||
$qname eq "indirect4.example.org" ||
$qname eq "indirect5.example.org" ||
$qname eq "indirect6.example.org" ||
$qname eq "indirect7.example.org" ||
$qname eq "indirect8.example.org") {
if (! $send_response) {
} elsif ($qtype eq "A") {
}
$rcode = "NOERROR";
} else {
$send_response = 1;
if ($qtype eq "A") {
print("\tresponse: $qname $ttl $qclass $qtype $rdata\n");
}
}
$rcode = "NOERROR";
} else {
$rcode = "NXDOMAIN";
}
# mark the answer as authoritive (by setting the 'aa' flag
}
'port=i' => \$localport,
'verbose!' => \$verbose,
);
ReplyHandler => \&reply_handler,
);