Branch Coverage

blib/lib/Net/BitTorrent/DHT.pm
Criterion Covered Total %
branch 79 144 54.8


line true false branch
23 0 47 if (not $args or ref $args ne 'HASH')
28 0 47 unless ($$args{'Client'} and blessed($$args{'Client'}) and $$args{'Client'}->isa('Net::BitTorrent'))
70 0 0 if defined $_[1]
76 115 18 unless $tracking{refaddr $self}{$info_hash}
83 0 3 if defined $_[1]
88 0 2 if defined $_[1]
95 0 0 unless defined $_[1]
102 0 358 unless $_client{refaddr $self}->_use_dht
103 0 358 if scalar keys %{$nodes{refaddr $self};} >= 300
104 0 358 if ref $args ne 'HASH'
105 0 358 unless $$args{'port'}
106 0 358 unless $$args{'ip'}
109 0 358 if (defined $ok and $ok == 0)
111 0 358 unless $_resolved
113 55 303 unless $nodes{refaddr $self}{$paddr}
135 6 31 unless $_client{refaddr $self}->_use_dht
147 58 0 unless not defined $nodes{refaddr $self}{$_}{'seen'} or $nodes{refaddr $self}{$_}{'seen'} < time - 900
159 0 58 if $nodes{refaddr $self}{$_}{'ping'} > $nodes{refaddr $self}{$_}{'seen'}
174 0 11 if $tracking{refaddr $self}{$info_hash}{'touch'} < time - 1800
190 0 198 unless $_client{refaddr $self}->_use_dht
193 198 0 if (defined $packet and ref $packet eq 'HASH' and $$packet{'y'}) { }
196 99 99 if ($$packet{'y'} eq 'q') { }
99 0 elsif ($$packet{'y'} eq 'r') { }
0 0 elsif ($$packet{'y'} eq 'e') { }
197 0 99 if ($$packet{'q'} eq 'ping') { }
47 52 elsif ($$packet{'q'} eq 'find_node') { }
34 18 elsif ($$packet{'q'} eq 'get_peers') { }
18 0 elsif ($$packet{'q'} eq 'announce_peer') { }
199 0 0 unless ($nodes{refaddr $self}{$paddr})
205 0 0 if (defined $ok and $ok == 0)
208 0 0 unless $new_node
210 0 0 if (defined $nodes{refaddr $self}{$paddr})
225 0 47 if (defined $ok and $ok == 0)
247 23 11 unless ($nodes{refaddr $self}{$paddr})
251 0 23 unless $nodes{refaddr $self}{$paddr}
259 8 26 if ($tracking{refaddr $self}{$$packet{'a'}{'info_hash'}}) { }
293 0 18 unless ($nodes{refaddr $self}{$paddr})
304 0 18 if (not $$node{'token_o'} or $$packet{'a'}{'token'} ne $$node{'token_o'}) { }
0 18 elsif (not $tracking{refaddr $self}{$$packet{'a'}{'info_hash'}} and scalar keys %{$tracking{refaddr $self};} > 64) { }
323 0 18 if (scalar @current_peers > 128)
353 0 99 unless ($original_packet)
360 0 99 unless $nodes{refaddr $self}{$paddr}
362 0 99 if ($$original_packet{'paddr'} ne $paddr)
382 74 25 $$node{'id'} ? :
386 34 65 $$packet{'r'}{'token'} ? :
394 69 30 if ($$packet{'r'}{'nodes'})
399 0 323 unless $new_node
407 217 106 $$_data{'a'}{'target'} ? :
416 8 91 if ($$packet{'r'}{'values'})
425 8 0 if ($torrent)
469 0 8 unless $_client{refaddr $self}->_use_dht
470 8 0 if $$node{'seen'} > time - 120
485 0 18 unless $_client{refaddr $self}->_use_dht
494 0 26 unless $_client{refaddr $self}->_use_dht
495 0 26 if $$node{'prev_ann'} > time - 900
497 8 18 unless $$node{'token_i'}
519 0 68 unless $_client{refaddr $self}->_use_dht
520 21 47 if $$node{'prev_find'} > time - 300
538 0 47 unless $_client{refaddr $self}->_use_dht
547 0 349 unless $_client{refaddr $self}->_use_dht
548 315 34 if $$node{'prev_get'} > time - 600
566 0 110 unless $_client{refaddr $self}->_use_dht
577 0 375 if scalar @nodes == 8
585 0 25 unless $_client{refaddr $self}->_use_dht
586 0 25 unless ($torrent and blessed $torrent and $torrent->isa('Net::BitTorrent::Torrent'))
593 0 25 if ($torrent->private)
607 0 12 unless $_client{refaddr $self}->_use_dht
608 0 12 unless ($torrent and blessed $torrent and $torrent->isa('Net::BitTorrent::Torrent'))
615 0 12 if ($torrent->private)
631 0 141 unless $_client{refaddr $self}->_use_dht
637 0 0 !$advanced ? :
643 0 0 defined wantarray ? :