Check/Config.pm

filter: Statementstmt 18.5% 13 / 70 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 100% 3 / 3 totaltotal 21.0% 20 / 95 CC 7 SCAR 20.1
CC
7
Cov
16%
test_conf
20.0
test_level
6.0
__ANON__
6.0
CRAP 7.5
« Check/Test/soa_serial_syntax.pm ↑ Summary Check/Test/host_ip_private.pm »
1 package Net::DNS::Check::Config;
2  
3 1 ▶use vars qw($VERSION $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
9 0 my ($pkg, %param) = @_;
10  
11 0 my $self = {};
12  
13 0 bless $self, $pkg;
14  
15 # Definizione rootnameservers
16 0 $self->{rootservers} = [ qw(
17 198.41.0.4
18 128.9.0.107
19 192.33.4.12
20 128.8.10.90
21 192.203.230.10
22 192.5.5.241
23 192.112.36.4
24 128.63.2.53
25 192.36.148.17
26 192.58.128.30
27 193.0.14.129
28 198.32.64.12
29 202.12.27.33 )
30 ];
31  
32  
33 0 $self->{debug_default} = 0;
34  
35  
36 # Intervallo di tempo per la ritrasmissione delle query
37 0 $self->{query_retrans} = 5;
38  
39 # Numero di tentativi nelle fare le query
40 0 $self->{query_retry} = 2;
41  
42 # Time out delle connessioni di tipo TCP (default a 120)
43 0 $self->{query_tcp_timeout} = 30;
44  
45 # Time out delle connessioni di tipo UDP (default undef)
46 0 $self->{query_udp_timeout} = undef;
47  
48 # Abilita disabilita le query per i RR::AAAA
49 0 $self->{query_AAAA} = undef;
50  
51 # $self->{predefined_hosts}->{'dns.nic.it'} = ['193.205.245.5'];
52 # $self->{predefined_hosts}->{'dns2.nic.it'} = ['193.205.245.8'];
53 # $self->{predefined_hosts}->{'dns3.nic.it'} = ['193.205.245.66'];
54  
55 # list of all available Check (test)
56 # if you add a new Check you should add it to this list
57 0 $self->{test_list} = [ qw(
58 mx_compare
59 mx_present
60 ns_compare
61 ns_vs_delegated
62 ns_count
63 soa_expire_compare
64 soa_expire_range
65 soa_refresh_compare
66 soa_refresh_range
67 soa_retry_compare
68 soa_retry_range
69 soa_serial_compare
70 soa_serial_syntax
71 soa_master_compare
72 soa_master_in_ns
73 host_syntax
74 host_not_cname
75 host_ip_vs_ip_orig
76 host_ip_private
77 ) ];
78  
79  
80  
81 0 $self->{test_level}->{OK} = 'OK';
82 0 $self->{test_level}->{E} = 'Error';
83 0 $self->{test_level}->{W} = 'Warning';
84 0 $self->{test_level}->{I} = 'Ignore';
85 0 $self->{test_level}->{F} = 'Fatal';
86  
87 0 $self->{ok_status} = 'OK';
88 0 $self->{error_status} = [qw{E F}];
89 0 $self->{default_status} = 'E';
90  
91 # List of all configured test. This is an hash ref containg
92 # all test used. Default use all available tests.
93 # Default level E (Error)
94 0 $self->{test_configured} = { map { $_ => 'E' } @{ $self->{test_list} } };
95  
96 # $self->{test_configured}->{soa_serial_syntax} = 'W';
97 # $self->{test_configured}->{soa_serial_compare} = 'W';
98 # $self->{test_configured}->{soa_refresh_range} = 'W';
99 # $self->{test_configured}->{soa_refresh_compare} = 'W';
100 # $self->{test_configured}->{soa_retry_range} = 'W';
101 # $self->{test_configured}->{soa_retry_compare} = 'W';
102  
103  
104 # If value is '0'
105 0 $self->{ns_min_count} = 2;
106 0 $self->{ns_max_count} = 0; # no max limit
107  
108 0 $self->{soa_min_retry} = 1800;
109 0 $self->{soa_max_retry} = 28800;
110  
111 0 $self->{soa_min_refresh} = 1800;
112 0 $self->{soa_max_refresh} = 86400;
113  
114 0 $self->{soa_min_expire} = 86400;
115 0 $self->{soa_max_expire} = 0; # no max limit
116  
117 0 $self->{ip_private} = [ qw(
118 10
119 127
120 172.16
121 172.17
122 172.18
123 172.19
124 172.20
125 172.21
126 172.22
127 172.23
128 172.24
129 172.25
130 172.26
131 172.27
132 172.28
133 172.29
134 172.30
135 172.31
136 192.168 )
137 ];
138  
139 0 return $self;
140 }
141  
142 0 ▶sub test_level {
Subroutine test_level: not called CC=2 SCAR=17.9
Pod documented
143 0 my ($self) = shift;
144 0 my ($level) = shift;;
145  
146 0 ▶ if ( $level ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level) { } 0 0 0
147 0 return $self->{test_level}->{$level};
148 } else {
149 0 return $self->{test_level};
150 }
151 }
152  
153  
154 0 ▶sub test_conf {
Subroutine test_conf: not called CC=4 SCAR=30.0
Pod documented
155 0 my ($self) = shift;
156 0 my (%param) = @_;
157  
158 0 ▶ return unless $param{test};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"test"} 0 0 0
159  
160 # We should verify if test exists and if level is one of that supported
161 0 ▶ if ($param{level}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"level"}) 0 0 0
162 0 $self->{test_configured}->{$param{test}} = uc $param{level};
163 }
164  
165 0 ▶ if (defined $self->{test_configured}->{$param{test}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"test_configured"}{$param{"test"}}) 0 0 0
166 0 return $self->{test_configured}->{$param{test}};
167 }
168 }
169  
170  
171 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=14.9
172 0 my ($self) = @_;
173  
174 0 my ($name) = $AUTOLOAD =~ m/^.*::(.*)$/;
175  
176 0 ▶ unless (exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{$name}) 0 0 0
177 0 Carp::carp(<<"AMEN");
178  
179 ***
180 *** WARNING!!! Param Doesn't exist
181 *** $AUTOLOAD
182 ***
183  
184 AMEN
185 0 return;
186 }
187  
188 1 ▶ no strict q/refs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
189  
190 # Build a method in the class.
191 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
192 0 my ($self, $new_val) = @_;
193  
194 0 ▶ if (defined $new_val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_val) 0 0 0
195 0 $self->{$name} = $new_val;
196 }
197  
198 0 return $self->{$name};
199 0 };
200  
201 # And jump over to it.
202 0 goto &{$AUTOLOAD};
203 }
204  
205  
206 0 ▶sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
207 1 1;
208  
209 __END__
« Check/Test/soa_serial_syntax.pm ↑ Summary Check/Test/host_ip_private.pm »