| 1 | package Net::DNS::Check::NSQuery; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Net::DNS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Net::DNS::Check::Host; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Net::DNS::Check::HostsList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Net::DNS::Check::Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my ($class, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return 0 if (!$param{domain} || ! $param{nserver}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param{"domain"} and $param{"nserver"}
MC/DC0%0/2
$param{"domain"} and $param{"nserver"}
$param{"domain"}
$param{"nserver"}
Truth table0%0/3
A and B
A= $param{"domain"}B= $param{"nserver"}
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Nome del dominio | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | $self->{domain} = $param{domain}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $self->{qdomain} = $param{domain}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $self->{qdomain} =~ s/\./\\./g; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # Nome del namserver da interrogare | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->{nserver} = $param{nserver}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $fatal = 0; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $msg_error =<<ERROR; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | FATAL ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 32 | =============== | ||||||||||||||||||||||||||||||||||||||||||
| 33 | Wrong call of constructor: $class | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | unless ( $self->{domain} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $fatal = 1; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $msg_error .= "\ndomain param not found!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless ( $self->{nserver} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $fatal = 1; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $msg_error .= "\nnserver param not found!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ( $fatal ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | confess($msg_error . "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | # IP del namserver da interrogare | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # il parametro e' facoltativo. Se non viene passato | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # viene utilizzata la ricorsione per determinare | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # l'IP. Ovviamente per i nameserver appartenenti al dominio | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # sul quale staimo operando DOVREBBE essere passato l'IP. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # Se non viene passato l'IP per quest'ultimi si utilizza | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # la ricorsione che funzionera' solo se il dominio e' gia' | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # esistente | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->{ip} = $param{ip}; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->{config} = $param{config} || new Net::DNS::Check::Config; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'config'} || 'Net::DNS::Check::Config'->new
MC/DC0%0/2
$param{'config'} || 'Net::DNS::Check::Config'->new
$param{'config'}
'Net::DNS::Check::Config'->new
Truth table0%0/3
A || B
A= $param{'config'}B= 'Net::DNS::Check::Config'->new
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( defined $param{debug} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->{debug} = $param{debug}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{debug} = $self->{config}->debug_default(); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # External/General Hostslist. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | $self->{hostslist} = $param{hostslist} || new Net::DNS::Check::HostsList( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | domain => $self->{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | debug => ($self->{debug} > 2), | ||||||||||||||||||||||||||||||||||||||||||
| 78 | config => $self->{config} | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'hostslist'} || 'Net::DNS::Check::HostsList'->new('domain', $self->{'domain'}, 'debug', $self->{'debug'} > 2, 'config', $self->{'config'})
MC/DC0%0/2
$param{'hostslist'} || 'Net::DNS::Check::HostsList'->new('domain', $self->{'domain'}, 'debug', $self->{'debug'} > 2, 'config', $self->{'config'})
$param{'hostslist'}
'Net::DNS::Check::HostsList'->new('domain', $self->{'domain'}, 'debug', $self->{'debug'} > 2, 'config', $self->{'config'})
Truth table0%0/3
A || B
A= $param{'hostslist'}B= 'Net::DNS::Check::HostsList'->new('domain', $self->{'domain'}, 'debug', $self->{'debug'} > 2, 'config', $self->{'config'})
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # Internal HostsList | ||||||||||||||||||||||||||||||||||||||||||
| 82 | $self->{myhostslist} = new Net::DNS::Check::HostsList( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | domain => $self->{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | debug => ($self->{debug} > 2), | ||||||||||||||||||||||||||||||||||||||||||
| 85 | config => $self->{config} | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # Array of NS or MX hostnames | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->{result}->{NS} = []; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->{result}->{MX} = []; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | Query for RR ANY for $self->{domain} to $self->{nserver} | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ======================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 103 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | # Creiamo l'oggetto resolver usando il resolver di sistema | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $self->{res} = Net::DNS::Resolver->new( | ||||||||||||||||||||||||||||||||||||||||||
| 110 | recurse => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | debug => ($self->{debug} > 2), | ||||||||||||||||||||||||||||||||||||||||||
| 112 | retrans => $self->{config}->query_retrans, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | retry => $self->{config}->query_retry, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | tcp_timeout => $self->{config}->query_tcp_timeout | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # La add_host crea un oggetto host e lo aggiunge alla lista se non esiste | ||||||||||||||||||||||||||||||||||||||||||
| 119 | # o ritorna l'oggetto host gia' presente nella hostslist | ||||||||||||||||||||||||||||||||||||||||||
| 120 | # $self->{host} = $self->{hostslist}->add_host( $self->{nserver}, $self->{ip} ); | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # if an ip doesn't exist we try to find it using add_host function | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # (that it uses hostslist object functions) | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | unless ( @{$self->{ip}} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $ips = join(' ', @{$self->{ip}}); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 130 | Search for $self->{nserver} IP | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->{host} = $self->_add_host( $self->{nserver} ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->{ip} = $self->{host}->get_ip(); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # We found an IP address to query so we make query | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # .... otherwise we have an error | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( @{$self->{ip}} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | # $self->{type} = $type; | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $ips = join(' ', @{$self->{ip}}); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 148 | $self->{nserver} IP : $ips | ||||||||||||||||||||||||||||||||||||||||||
| 149 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | # We set resolver to the ip found | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->{res}->nameservers(@{ $self->{ip} }); | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ($self->{debug} > 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | print "\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->{res}->print; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # Query of type ANY for $self->{domain} to $self->{ip} | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->_queryANY(); | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->{error} = 'NOIP'; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $ips = join(' ', @{$self->{ip}}); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 170 | $self->{nserver} IP : Not Found | ||||||||||||||||||||||||||||||||||||||||||
| 171 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub _queryANY() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queryANY: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # Creazione query per il dominio | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $packet = $self->{res}->send($self->{domain},'ANY'); | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ($packet) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->{result}->{header} = $packet->header; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 190 | Getting query answer | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($self->{debug} > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $result = $packet->string; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 198 | $result | ||||||||||||||||||||||||||||||||||||||||||
| 199 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ( $self->header_aa() && scalar $packet->answer() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->header_aa and scalar $packet->answer
MC/DC0%0/1
$self->header_aa and scalar $packet->answer
$self->header_aa
Truth table0%0/2
A
A= $self->header_aa
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | foreach my $rr ( $packet->answer ) { | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($rr->type eq 'SOA') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->{result}->{SOA} = $rr; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($rr->type eq 'NS') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | push (@{$self->{result}->{NS}}, lc($rr->{nsdname})); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->_add_host( lc($rr->{nsdname}) ); | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($rr->type eq 'MX') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | push (@{$self->{result}->{MX}}, lc($rr->{exchange})); | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->_add_host( lc($rr->{exchange}) ); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->{error} = 'NOAUTH'; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # Query Error... no answer (time out) | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $self->{error} = 'NOANSWER'; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ($self->{debug} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $qerror = $self->{res}->errorstring; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | print <<DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 234 | Query Error: $qerror | ||||||||||||||||||||||||||||||||||||||||||
| 235 | DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub _add_host() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_host: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ($hostname) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | unless ($hostname) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | confess("hostname parm not found!\n"); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my ($host, @temp); | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | @temp = split('\.', $self->{domain}); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $domcount = scalar @temp; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | @temp = split('\.', $hostname); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $hostcount = (scalar @temp)-1; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # Questo e' da rivedere. | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( ($hostname eq $self->{domain}) || $hostname =~ /.*$self->{qdomain}$/ && $domcount == $hostcount ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hostname eq $self->{"domain"} or $hostname =~ /.*$self->{"qdomain"}$/ and $domcount == $hostcount
$hostname =~ /.*$self->{"qdomain"}$/ and $domcount == $hostcount
MC/DC0%0/3
$hostname eq $self->{"domain"} or $hostname =~ /.*$self->{"qdomain"}$/ and $domcount == $hostcount
$hostname eq $self->{"domain"}
$hostname =~ /.*$self->{"qdomain"}$/
$domcount == $hostcount
Truth table0%0/4
A or B and C
A= $hostname eq $self->{"domain"}B= $hostname =~ /.*$self->{"qdomain"}$/C= $domcount == $hostcount
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | # Se l'hostname fa parte del dominio lo aggiungiamo alla hostslist | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # locale e usiamo per la risluzione l'ip del namserver | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # con cui abbiamo creato l'oggetto NSQuery | ||||||||||||||||||||||||||||||||||||||||||
| 265 | #print "inside "; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $host = $self->{myhostslist}->add_host( hostname => $hostname, ip => $self->{ip} ); | |||||||||||||||||||||||||||||||||||||||||
| 267 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # Se l'hostname non fa parte del dominio lo aggiungiamo alla | ||||||||||||||||||||||||||||||||||||||||||
| 269 | # hostslist globale | ||||||||||||||||||||||||||||||||||||||||||
| 270 | #print "outside "; | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $host = $self->{hostslist}->add_host( hostname => $hostname ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $host; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # Riporta 1 se le risposte del dns sono autoritativo | ||||||||||||||||||||||||||||||||||||||||||
| 279 | # Riporta 0 se la risposta non e' autoritativa | ||||||||||||||||||||||||||||||||||||||||||
| 280 | # Riporta -1 se non c'e' nessun header | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub header_aa() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_aa: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return undef if (! defined $self->{result}->{header}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $self->{result}->{header}->aa(); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # Riporta l'oggetto Net::DNS::Header oppure false se non c'e' l'oggetto | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub header() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | return 0 if (! defined $self->{result}->{header}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $self->{result}->{header}; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | # Riporta un array vuoto se non ci sono record NS altrimenti riporta | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # l'array contenente la lista dei DNS autoritativi | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub ns_list() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ns_list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | return () unless defined $self->{result}->{NS}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return @{ $self->{result}->{NS} }; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | # Riporta un array vuoto se non ci sono record MX altrimenti | ||||||||||||||||||||||||||||||||||||||||||
| 312 | # Altrimenti riporta l'array dei contenente la lista degli | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # exchange server | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub mx_list() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mx_list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return () unless defined $self->{result}->{MX}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return @{ $self->{result}->{MX} }; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | # Riporta undef se non esiste un'oggetto SOA o non esiste un master altrimenti riporta il master nameserver che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub soa_mname() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_mname: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | return if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | return lc($self->{result}->{SOA}->mname()); | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | # Riporta undef se non esiste un'oggetto SOA altrimenti | ||||||||||||||||||||||||||||||||||||||||||
| 332 | # Riporta il serial che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | sub soa_serial() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_serial: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return $self->{result}->{SOA}->serial(); | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | # Riporta 0 se non esiste un'oggetto SOA o non esiste un refresh | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # Riporta il refresh che che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub soa_refresh() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_refresh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return 0 if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return $self->{result}->{SOA}->refresh(); | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | # Riporta 0 se non esiste un'oggetto SOA o non esiste un retry | ||||||||||||||||||||||||||||||||||||||||||
| 354 | # Riporta il retry che che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub soa_retry() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_retry: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | return 0 if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return $self->{result}->{SOA}->retry(); | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # Riporta 0 se non esiste un'oggetto SOA o non esiste un expire | ||||||||||||||||||||||||||||||||||||||||||
| 364 | # Riporta il expire che che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub soa_expire() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_expire: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return 0 if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $self->{result}->{SOA}->expire(); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | # Riporta 0 se non esiste un'oggetto SOA o non esiste un minimum | ||||||||||||||||||||||||||||||||||||||||||
| 374 | # Riporta il minimum che che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub soa_minimum() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_minimum: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | return 0 if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return $self->{result}->{SOA}->minimum(); | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | # Riporta 0 se non esiste un'oggetto SOA o non esiste un minimum | ||||||||||||||||||||||||||||||||||||||||||
| 384 | # Riporta il minimum che che appare nel SOA | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub soa_mail() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_mail: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | return 0 if (! defined $self->{result}->{SOA} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return $self->{result}->{SOA}->rname(); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | # Riporta il nome del nameserver che stiamo interrogando | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub ns_name() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ns_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return $self->{nserver}; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub error() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return $self->{error}; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub hostslist() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hostslist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return $self->{myhostslist}; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | __END__ | ||||||||||||||||||||||||||||||||||||||||||