Branch Coverage

blib/lib/Net/DirectConnect.pm
Criterion Covered Total %
branch 2 582 0.3


line true false branch
22 0 0 if is_code $f
23 0 0 if ref $_[0]
24 0 0 unless is_object $c
0 0 if $r
27 0 0 if ref $_[0]
28 0 0 $_[0] < 3 ? :
0 0 $_[0] < 1 ? :
0 0 $_[0] < 8 && $_[0] - int($_[0]) ? :
35 0 0 unless m[/$]
36 0 0 @_ ? :
0 0 if length $`
40 0 0 if ref $_[0]
48 0 0 $port ? :
0 0 if (my $s = $$self{'socket_class'}->new('PeerAddr', $host, $port ? ('PeerPort', $port) : (), 'Proto', 'udp', 'Timeout', $$opt{'Timeout'}, ('Blocking', 0), %{{} unless $$opt{'socket_options'};})) { }
49 0 0 unless $$opt{'socket_options'}
77 0 0 wantarray ? :
107 0 0 if ref $every eq 'ARRAY'
108 0 0 if ref $every eq 'HASH'
109 0 0 unless ref $every
113 0 0 if not $schedule{$$p{'id'}}{'func'} or $$p{'update'}
114 0 0 if $$p{'wait'} and not $schedule{$$p{'id'}}{'last'}
116 0 0 if $schedule{$$p{'id'}}{'last'} + $$p{'every'} < time and !$$p{'runs'} || $schedule{$$p{'id'}}{'runs'} < $$p{'runs'} and !(ref $$p{'cond'} eq 'CODE') || $$p{'cond'}($p, $schedule{$$p{'id'}}, @_) and ref $schedule{$$p{'id'}}{'func'} eq 'CODE'
124 0 0 if $_
125 0 0 wantarray ? :
129 0 1 if ref $_[0]
132 0 1 if exists $tried{$module}
138 0 0 if ref $_[0]
140 0 0 unless length $_
142 0 0 if $$self{'module_loaded'}{$_}++
145 0 0 unless use_try $module
152 0 0 if $_ = $module->can('new') and $_ ne 'Net::DirectConnect'->can('new')
153 0 0 if $_ = $module->can('init')
165 0 0 if (ref $class eq 'Net::DirectConnect') { }
166 0 0 unless ref $class
175 0 0 unless $^O =~ /win/i
191 0 0 if ($class eq 'Net::DirectConnect')
198 0 0 if ($$self{'host'} ~~ qr"^(?:\w+://)?broadcast" or $$self{'host'} =~ /^(?:255\.|\[?ff)/i)
209 0 0 unless $$self{'host'} =~ /^(?:255\.|\[?ff)/i
217 0 0 if (not $$self{'protocol'} and $$self{'host'})
223 0 0 if $$self{'host'} =~ m[^(.+?)://]
226 0 0 if not $$self{'protocol'} or $$self{'protocol'} eq 'dchub'
237 0 0 if ($$self{'protocol'} eq 'nmdc')
238 0 0 $$self{'hub'} ? :
244 0 0 if ($$self{'dev_sctp'})
245 0 0 if (not $$self{'no_sctp_fallback'}) { }
267 0 0 if ref $$self{$_} eq 'ARRAY'
268 0 0 if ref $$self{$_} eq 'HASH'
269 0 0 unless ref $$self{$_}
281 0 0 if not $$self{'parent'} || $$self{'no_charset_console'} and $$self{'charset_internal'} and $$self{'charset_console'}
288 0 0 unless $$self{'parent'}{'parent'}
291 0 0 if ($$self{'auto_say'})
292 0 0 unless $$self{'auto_say_cmd'}
303 0 0 if ($$self{'auto_listen'}) { }
0 0 elsif ($$self{'auto_connect'}) { }
308 0 0 if $$self{'broadcast'}
313 0 0 unless $$self{'no_wait_connect'}
318 0 0 if ($$self{'auto_work'})
333 0 0 if ref $$self{'log'} eq 'CODE'
341 0 0 if $$self{'adc'} and length $_[0] == 1
348 0 0 if ($$self{'cmd'} and ref $$self{'cmd'}{$cmd} eq 'CODE') { }
0 0 elsif (ref $$self{$cmd} eq 'CODE') { }
0 0 elsif ($$self{'cmd'} and ref $$self{'cmd'}{$dst . $cmd} eq 'CODE') { }
0 0 elsif ($func = $self->can($cmd)) { }
351 0 0 if $dst
361 0 0 if ($$self{'min_cmd_delay'} and time - $$self{'last_cmd_time'} < $$self{'min_cmd_delay'})
370 0 0 if ($func) { }
0 0 elsif ($$self{'adc'} and length $dst == 1 and length $cmd == 3) { }
0 0 elsif (exists $$self{$cmd}) { }
384 0 0 unless grep {$cmd eq $_;} 'new', 'init'
386 0 0 if $$self{'cmd'}
388 0 0 scalar @ret > 1 ? :
390 0 0 if ($$self{'cmd'} and $$self{'cmd'}{$cmd})
391 0 0 if ($$self{'auto_wait'}) { }
0 0 elsif ($$self{'auto_recv'}) { }
395 0 0 wantarray ? :
419 0 0 if ref $_[0]
422 0 0 if $$self{'handler_int'} and ref $$self{'handler_int'}{$cmd} eq 'CODE'
425 0 0 if $$self{'handler'} and ref $$self{'handler'}{$cmd} eq 'CODE'
466 0 0 ref $_[0] ? :
467 0 0 if (ref $$self{'parent'}{'log'} eq 'CODE')
481 0 0 $^O eq 'MSWin32' ? :
0 0 $^O eq 'MSWin32' ? :
0 0 use_try('IO::Socket::IP') ? :
530 0 0 $$self{'parent'}{$_} ? :
545 0 0 unless $$self{'myport_base'} or $$self{'myport_random'}
548 0 0 if $_[0]
549 0 0 if $$self{'myport_inc'}
560 0 0 unless $$self{'socket'}
570 0 0 if $$self{'Proto'} eq 'udp' or $$self{'incoming'} or $$self{'listener'} or $$self{'socket'} or not $self->active
584 0 0 if ($$self{'reconnect_tries'}++ < $$self{'reconnects'}) { }
602 0 0 if ($_[0] or $$self{'host'} =~ /:/)
603 0 0 if $_[0]
606 0 0 if $p eq 'adcs'
609 0 0 if $$self{'host'} =~ /^\[(\S+)\]:(\d+)/
610 0 0 if $$self{'host'} =~ s/^([^:]+):(\d+)$//
619 0 0 if $$self{'socket'} and $$self{'socket'}->connected or grep {$$self{'status'} eq $_;} 'destroy'
620 0 0 unless $$self{'socket_options'}
645 0 0 $$self{'port'} ? :
0 0 $$self{'Proto'} ? :
649 0 0 unless $$self{'socket'}
658 0 0 if $$self{'Timeout'}
684 0 0 unless $$self{'myip'}
688 0 0 if $$self{'Timeout_connected'}
693 0 0 ref $_ eq 'ARRAY' ? :
700 0 0 if not $$self{'M'} and &$is_local_ip($$self{'myip'}) and not &$is_local_ip($$self{'hostip'})
724 0 0 unless $$self{'Listen'}
745 0 0 $$self{'Proto'} ? :
0 0 $$self{'Proto'} ne 'udp' ? :
749 0 0 if $$self{'socket'}
750 0 0 unless $$self{'socket'}
754 0 0 unless $$self{'socket'}
757 0 0 if $$self{'Proto'} ne 'udp'
768 0 0 if ($$self{'socket'})
770 0 0 if $$self{'select'}
771 0 0 if $$self{'select_send'}
781 0 0 if ($$self{'disconnect_recursive'})
794 0 0 if ref $$self{'clients'}{$client}
814 0 0 if ref $$self{$_}
824 0 0 if ($$self{'accept'})
830 0 0 if ($_) { }
832 0 0 unless $$self{'incomingclass'}
838 0 0 $$self{'allow'} ? :
843 0 0 if (my $allow = $$self{'allow'})
845 0 0 unless $host eq $allow
849 0 0 unless $$self{'incomingopt'}
866 0 0 $$_{'port'} ? :
877 0 0 if $client ne $$self{'socket'}
882 0 0 if (not defined($$self{'recv_addr'} = $client->$recv($$self{'databuf'}, 8192, $$self{'recv_flags'})) && length $$self{'databuf'} and $recv ~~ 'recv') { }
886 0 0 if ($self->active and not $$self{'incoming'}) { }
0 0 elsif ($$self{'status'} ne 'listening') { }
909 0 0 if ($$self{'filehandle'}) { }
0 0 elsif (length $$self{'databuf'}) { }
915 0 0 if not $$self{'adc'} and $$self{'recv_buf'} =~ /^[BCDEFHITU][A-Z]{,5} /
919 0 0 if $$self{'Proto'} eq 'udp' and $$self{'status'} eq 'listening'
924 0 0 if $$self{'status'} eq 'destroy'
926 0 0 unless length $_ and length $$self{'cmd_aft'}
927 0 0 unless length $_
928 0 0 if $$self{'broadcast'}
933 0 0 if $$self{'filehandle'}
935 0 0 if length $$self{'recv_buf'} and $$self{'filehandle'}
954 0 0 $nosend ? :
982 0 0 unless $$self{'sockets'}{$_} and $$self{'sockets'}{$_}{'socket'}
985 0 0 if $$self{'sockets'}{$_}{'status'} eq 'connecting_tcp'
995 0 0 if ($$self{'sockets'}{$_}{'filehandle_send'})
1002 0 0 if not ref $$self{'sockets'}{$_} or ref $$self{'sockets'}{$_} eq 'HASH'
1037 0 0 if $$self{'filebytes'} and $$self{'filetotal'} and $$self{'filebytes'} < $$self{'filetotal'} - 1
1044 0 0 if @_ = grep({not $$self{'clients'}{$_}->finished;} $self->clients_my)
1053 0 0 if grep {$$self{'status'} eq $_;} ('connected', 'transfer', 'disconnecting', 'disconnected', 'destroy'), ''
1065 0 0 if $self->finished
1077 0 0 if @_ = $self->clients_my
1088 0 0 if not $$self{'clients_max'} or $$self{'clients_max'} > (@_ = $self->clients_my)
1090 0 0 unless $_
1107 0 0 unless $self->active
1119 0 0 if is_object($$self{'parent'})
1129 0 0 unless $$self{'periodic'}
1138 0 0 if (not $$self{'clients'}{$_}{'socket'} && length $$self{'clients'}{$_}{'status'} or $$self{'clients'}{$_}{'status'} eq 'destroy' or $$self{'clients'}{$_}{'status'} ne 'listening' and $$self{'clients'}{$_}{'status'} ne 'working' and $$self{'clients'}{$_}{'inactive_timeout'} and time - $$self{'clients'}{$_}{'activity'} > $$self{'clients'}{$_}{'inactive_timeout'})
1168 0 0 if $$self{'sockets'}{$_} and %{$$self{'sockets'}{$_};}
1172 0 0 unless ($$self{'parent'} and $$self{'parent'}{'parent'})
1183 0 0 if $$self{'clients'}{$_}
1192 0 0 unless $self->active
1193 0 0 if $$self{'status'} eq 'listening'
1196 0 0 if ($$self{'downloading'}{$tth}{'connect_start'} and $$self{'downloading'}{$tth}{'connect_start'} < $time - 60)
1207 0 0 if ($$self{'queue_download'} and @{$$self{'queue_download'};})
1222 0 0 unless $$wdls{$a}{'tries'} <=> $$wdls{$b}{'tries'}
1230 0 0 if (my($fromk) = $_[0])
1236 0 0 if $$self{'charset_fs'}
1238 0 0 if (-s $partial)
1280 0 0 if $$self{'dev_auto_dump'}
1285 0 0 if @params
1296 0 0 unless open my $fh, '>', $file
1305 0 0 $$self{'recv_hostip'} ? :
1317 0 0 if (/^[<*]/)
1318 0 0 $$self{'status'} eq 'connected' ? :
1320 0 0 unless $cmd
1322 0 0 if ($$self{'adc'}) { }
1325 0 0 if ($dst eq 'B' or $dst eq 'F' or $dst eq 'U' or $$self{'broadcast'}) { }
0 0 elsif ($dst eq 'D' or $dst eq 'E') { }
1334 0 0 if ($dst eq 'F')
1348 0 0 if not exists $$self{'parse'}{$cmd} and exists $$self{'parse'}{$dst . $cmd}
1352 0 0 $$self{'status'} eq 'connected' ? :
0 0 if $$self{'nmdc'} and not exists $$self{'parse'}{$cmd}
1354 0 0 if ($cmd eq 'chatline' or $cmd eq 'welcome' or $cmd eq 'To') { }
1371 0 0 if (ref $$self{'parse'}{$cmd} eq 'CODE') { }
1372 0 0 if (not exists $$self{'no_print'}{$cmd}) { }
1376 0 0 unless $$self{'no_print'}
1380 0 0 unless $$self{'no_print'}
1382 0 0 if exists $$self{'no_print'}{$cmd}
1387 0 0 scalar @ret > 1 ? :
1405 0 0 @_ ? :
0 0 if $$self{'socket'}
1408 0 0 if $@
1415 0 0 if $$self{'listener'}
1438 0 0 if $self->connect_check
1439 0 0 if $$self{'listener'} and not $$self{'broadcast'}
1441 0 0 if $$self{'adc'} and length $_[0] == 1
1444 0 0 if @_
1447 0 0 unless $$self{'send_buffer'}
0 0 if ($$self{'sendbuf'} and @_ or not @{[] unless $$self{'send_buffer'};}) { }
1451 0 0 if ($$self{'broadcast'}) { }
1454 0 0 unless $$self{'socket'}
1490 0 0 if $nick =~ /^[A-Z0-9]{4}$/
1491 0 0 if $nick =~ /^[A-Z0-9]{39}$/
1494 0 0 if $$self{'broadcast'}
1495 0 0 if $tth
1497 0 0 unless $full =~ m([/\\])
1500 0 0 if ($sizenow)
1526 0 0 if ($$self{'adc'}) { }
1529 0 0 if ($$self{'M'} eq 'A' and $$self{'myip'} and not $$self{'passive_get'}) { }
1540 0 0 $$self{'M'} eq 'A' && $$self{'myip'} && !$$self{'passive_get'} ? :
1547 0 0 if length $$self{'filename'}
1554 0 0 unless defined $$self{'filename'}
1563 0 0 unless defined $$self{'filename'}
1564 0 0 unless ($$self{'filename'})
1565 0 0 if ($$self{'peers'}{$peerid}{'SUP'}{'BZIP'} or $$self{'NickList'}{$peerid}{'XmlBZList'}) { }
0 0 elsif ($$self{'adc'}) { }
0 0 elsif ($$self{'NickList'}{$peerid}{'BZList'}) { }
1580 0 0 if $$self{'fileas'}
1585 0 0 unless $$self{'file_recv_full'} =~ m([/\\])
1593 0 0 if $$self{'partial_prefix'}
1594 0 0 $$self{'file_recv_tth'} ? :
1596 0 0 unless $$self{'file_recv_partial'} =~ m([/\\])
1598 0 0 if $$self{'charset_fs'}
1601 0 0 if $$self{'file_recv_size'} and $$self{'file_recv_from'}
1615 0 0 $$self{'fileas'} eq '-' ? :
1619 0 0 unless open $$self{'filehandle'}, $oparam
1630 0 0 unless my $fh = $$self{'filehandle'}
1659 0 0 if $$self{'filebytes'} > $$self{'filetotal'}
1661 0 0 if $$self{'filebytes'} >= $$self{'filetotal'}
1682 0 0 if ($$self{'filehandle'})
1685 0 0 if ($$self{'filebytes'} == $$self{'filetotal'})
1686 0 0 if $$self{'download_to'}
1687 0 0 if (length $$self{'partial_ext'})
1688 0 0 if $$self{'charset_fs'}
1691 0 0 unless rename $$self{'file_recv_partial'}, $$self{'file_recv_full'}
1698 0 0 if ($$self{'downloading'}{$$self{'file_recv_tth'}})
1700 0 0 if ($$self{'filebytes'} <= $$self{'filetotal'} or $$self{'file_recv_size'})
1708 0 0 if $$self{'select_send'} and $$self{'filehandle_send'}
1712 0 0 if $$self{'status'} eq 'transfer'
1720 0 0 if ($$self{'share_full'}{$file}) { }
1742 0 0 if $size <= 0
1743 0 0 if not -e $file or -d $file
1746 0 0 if (open $$self{'filehandle_send'}, '<', $file) { }
1748 0 0 if $start
1756 0 0 if $start >= $$self{'file_send_total'}
1757 0 0 if ($$self{'adc'}) { }
1778 0 0 unless $$self{'socket'} and $$self{'socket'}->connected and $$self{'filehandle_send'} and $$self{'file_send_left'}
1783 0 0 if $$self{'file_send_by'} < $$self{'file_send_left'}
1786 0 0 if (do { $INC{'Sys/Sendfile.pm'} }) { }
0 0 elsif ($INC{'Sys/Sendfile/FreeBSD.pm'}) { }
1790 0 0 if $sent > 0
1799 0 0 if $sent > 0
1806 0 0 unless length $$self{'file_send_buf'}
1847 0 0 if ($$self{'file_send_left'} < 0)
1851 0 0 if ($$self{'file_send_left'} <= 0)
1873 0 0 if ref $_[0]
1876 0 0 if ($_[0] eq 'file') { }
0 0 elsif ($_[0] eq 'list') { }
0 0 elsif ($_[0] eq 'tthl') { }
1878 0 0 if ($file =~ s[^TTH/][]) { }
1893 0 0 if ($$self{'adc'}) { }
1907 0 0 if ref $_[0]
1917 0 0 if ref $_[0]
1919 0 0 unless $$self{'socket'}
1941 0 0 if ref $_[0]
1952 0 0 if ref $_[0]
1954 0 0 unless $$self{'socket'}
1976 0 0 if ref $_[0]
1992 0 0 unless $$self{'parent'}
2008 0 0 if ref $_[0]
2011 0 0 if grep {$$self{'status'} eq $_;} 'connecting_tcp', 'connecting', 'connected', 'reconnecting', 'listening', 'transfer', 'working'
2017 0 0 if ($$self{'every_list'}{$func} + $sec < time and ref $func eq 'CODE')
2026 0 0 if ref $_[0]
2028 0 0 ref $_ eq 'HASH' ? :
0 0 ref $_ eq 'ARRAY' ? :
2040 0 0 $dst eq 'C' || !length($$self{'INF'}{'SID'}) ? :
2112 0 0 if $peerid and exists $$self{'peers'}{$peerid}
2123 0 0 if $_[0] eq 'MSG'
2129 0 0 if ref $_[0]
2131 0 0 if length $_[0] == 39 and $_[0] =~ /^[0-9A-Z]+$/
2133 0 0 if length $_[0]
2137 0 0 if ref $_[0]
2138 0 0 if ref $$self{'search_last'} eq 'ARRAY'
2144 0 0 if ref $_[0]
2145 0 0 if @_
2146 0 0 unless $$self{'search_todo'}
0 0 unless @{return unless $$self{'search_todo'};}
2150 0 0 if time - $$self{'search_last_time'} < $$self{'search_every'} + 2
2152 0 0 unless @{$$self{'search_todo'};}
2162 0 0 if ref $_[0]
2168 0 0 if ref $_[0]
2169 0 0 if $$self{'clients'}{$_}