| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DNSServer::Base; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1109
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
89
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
539
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Created before calling Net::DNSServer->run() |
|
7
|
|
|
|
|
|
|
sub new { |
|
8
|
0
|
|
0
|
0
|
1
|
|
my $class = shift || __PACKAGE__; |
|
9
|
0
|
|
0
|
|
|
|
my $self = shift || {}; |
|
10
|
0
|
|
|
|
|
|
return bless $self, $class; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Called once at configuration load time by Net::DNSServer. |
|
14
|
|
|
|
|
|
|
# Takes the Net::Server object as an argument. |
|
15
|
|
|
|
|
|
|
sub init { |
|
16
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
17
|
0
|
|
|
|
|
|
my $net_server = shift; |
|
18
|
0
|
0
|
0
|
|
|
|
unless ($net_server && (ref $net_server) && ($net_server->isa("Net::Server"))) { |
|
|
|
|
0
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
croak 'Usage> '.(__PACKAGE__).'->init($Net_Server_obj)'; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
0
|
|
|
|
|
|
$self -> {net_server} = $net_server, |
|
22
|
|
|
|
|
|
|
return 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Called immediately after incoming request |
|
26
|
|
|
|
|
|
|
# Takes the Net::DNS::Packet question as an argument |
|
27
|
|
|
|
|
|
|
sub pre { |
|
28
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
29
|
0
|
|
0
|
|
|
|
my $net_dns_packet = shift || croak 'Usage> $obj->resolve($Net_DNS_obj)'; |
|
30
|
0
|
|
|
|
|
|
$self -> {question} = $net_dns_packet; |
|
31
|
0
|
|
|
|
|
|
return 1; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Called after all pre methods have finished |
|
35
|
|
|
|
|
|
|
# Returns a Net::DNS::Packet object as the answer |
|
36
|
|
|
|
|
|
|
# or undef to pass to the next module to resolve |
|
37
|
|
|
|
|
|
|
sub resolve { |
|
38
|
0
|
|
|
0
|
1
|
|
die "virtual function not implemented"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Called after resolve. |
|
42
|
|
|
|
|
|
|
# Takes the Net::DNS::Packet question as an argument. |
|
43
|
|
|
|
|
|
|
# If may modify $self->{answer_packet} before |
|
44
|
|
|
|
|
|
|
# it is sent to the client. |
|
45
|
|
|
|
|
|
|
sub post { |
|
46
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
# my $net_dns_packet = shift || croak 'Usage> $obj->post($Net_DNS_obj)'; |
|
48
|
0
|
|
|
|
|
|
return 1; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Called once prior to server shutdown |
|
52
|
|
|
|
|
|
|
sub cleanup { |
|
53
|
0
|
|
|
0
|
1
|
|
return 1; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |