Condition Coverage

blib/lib/Net/DirectConnect/adc.pm
Criterion Covered Total %
condition 0 255 0.0


and 3 conditions

line !l l&&!r l&&r condition
147 0 0 0 $$self{'peers'}{$peerid}{'INF'}{'I4'} and $$self{'peers'}{$peerid}{'INF'}{'U4'}
375 0 0 0 $dst ne 'B' and $peerid ||= $$params{'ID'}
383 0 0 0 $$self{'parent'}{'hub'} and $dst eq 'B'
392 0 0 0 $dst eq 'B' and $$self{'parent'}{'hub'}
0 0 0 $dst eq 'B' and $$self{'parent'}{'hub'} and $$params{"I$v"}
0 0 0 $dst eq 'B' and $$self{'parent'}{'hub'} and $$params{"I$v"} and $$params{"I$v"} ne $$self{'hostip'}
409 0 0 0 $peerid eq $$self{'INF'}{'SID'} and not $$self{'myip'}
446 0 0 0 $$self{'broadcast'} and $peerid ne $$self{'INF'}{'SID'}
0 0 0 $$self{'broadcast'} and $peerid ne $$self{'INF'}{'SID'} and $dst eq 'B'
479 0 0 0 $code ~~ '20' and $_[0] =~ /^Reconnecting too fast, you have to wait (\d+) seconds before reconnecting./
0 0 0 $code ~~ '30' and $_[0] =~ /^You are disconnected because: You are disconnected for hammering the hub with connect attempts, stop or you'll be kicked !!!/
521 0 0 0 $$self{'peers'}{$peerid}{'INF'}{'I4'} and $$self{'peers'}{$peerid}{'INF'}{'U4'}
550 0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'}
0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}
584 0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'}
0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}
610 0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'}
0 0 0 $dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}
986 0 0 0 $$self{'hub'} and $$self{'dev_sctp'}
1008 0 0 0 $$self{'parent'}{'hub'} and $$self{'peerid'}

or 2 conditions

line l !l condition
117 0 0 $$self{'base_encode'} ||= sub { shift() if ref $_[0]; MIME::Base32::encode_rfc3548(@_); }
121 0 0 $$self{'base_decode'} ||= sub { shift() if ref $_[0]; MIME::Base32::decode_rfc3548(@_); }
127 0 0 $$self{'hash'} ||= sub { shift() if ref $_[0]; Net::DirectConnect::TigerHash::tthbin($_[0]); }
130 0 0 $$self{'hash_file'} ||= sub { shift() if ref $_[0]; Net::DirectConnect::TigerHash::tthfile($_[0]); }
134 0 0 $$self{'base_encode'} ||= sub { shift() if ref $_[0]; Net::DirectConnect::TigerHash::toBase32($_[0]); }
138 0 0 $$self{'base_decode'} ||= sub { shift() if ref $_[0]; Net::DirectConnect::TigerHash::fromBase32($_[0]); }
142 0 0 $$self{'hash_base'} ||= sub { shift() if ref $_[0]; $self->base_encode($self->hash($_[0])); }
150 0 0 $$self{'cmd_direct'} ||= sub { my $self = shift() if ref $_[0]; my $peerid = shift(); local $$self{'host'} = $$self{'peers'}{$peerid}{'INF'}{'I4'}, local $$self{'port'} = $$self{'peers'}{$peerid}{'INF'}{'U4'} if $$self{'peers'}{$peerid}{'INF'}{'I4'} and $$self{'peers'}{$peerid}{'INF'}{'U4'}; $self->cmd(@_); }
165 0 0 $$self{'ID_get'} ||= sub { my $self = shift() if ref $_[0]; if (-s $$self{'ID_file'}) { $$self{'ID'} ||= &psmisc::file_read($$self{'ID_file'}); } ; unless ($$self{'ID'}) { $$self{'ID'} ||= join(' ', 'perl', $$self{'myip'}, $VERSION, $0, $$self{'INF'}{'NI'}, time, '$Id: adc.pm 1001 2014-05-07 13:08:30Z pro $'); &psmisc::file_rewrite($$self{'ID_file'}, $$self{'ID'}); } ; $$self{'PID'} ||= $self->hash($$self{'ID'}); $$self{'CID'} ||= $self->hash($$self{'PID'}); $$self{'INF'}{'PD'} ||= $self->base_encode($$self{'PID'}); $$self{'INF'}{'ID'} ||= $self->base_encode($$self{'CID'}); return $$self{'ID'}; }
171 0 0 $$self{'Nick'} || 'perlAdcDev'
178 0 0 $$self{'S'} || '2'
179 0 0 $$self{'sharesize'} || 20025693588
180 0 0 $$self{'INF'}{'SF'} ||= 30999
181 0 0 $$self{'H'} || 1
182 0 0 $$self{'R'} || 0
183 0 0 $$self{'O'} || 0
188 0 0 $$self{'INF'}{'US'} ||= 10000
207 0 0 $$self{'INF_generate'} ||= sub { my $self = shift() if ref $_[0]; $$self{'INF'}{'NI'} ||= $$self{'Nick'} || 'perlAdcDev'; $$self{'PID'} ||= $self->MIME::Base32::decode->{'INF'}{'PD'} if $$self{'INF'}{'PD'}; $$self{'CID'} ||= $self->MIME::Base32::decode->{'INF'}{'ID'} if $$self{'INF'}{'ID'}; $self->ID_get; $$self{'INF'}{'SID'} ||= $$self{'broadcast'} ? $$self{'INF'}{'ID'} : substr($$self{'INF'}{'ID'}, 0, 4); $$self{'INF'}{'SL'} ||= $$self{'S'} || '2'; $$self{'INF'}{'SS'} ||= $$self{'sharesize'} || 20025693588; $$self{'INF'}{'SF'} ||= 30999; $$self{'INF'}{'HN'} ||= $$self{'H'} || 1; $$self{'INF'}{'HR'} ||= $$self{'R'} || 0; $$self{'INF'}{'HO'} ||= $$self{'O'} || 0; $$self{'INF'}{'VE'} ||= $$self{'client'} . $$self{'V'} || 'perl' . $Net::DirectConnect::VERSION . '_' . $VERSION; $$self{'INF'}{'US'} ||= 10000; my $domaindel = '4'; foreach my $domain ($$self{'dev_ipv6'} || $$self{'myip'} =~ /:/ ? ('4', '6') : 4) { $$self{'INF'}{'U' . $domain} = $$self{'myport_udp'} || $$self{'myport'}; $$self{'INF'}{'I' . $domain} = $$self{'myip'}; $$self{'INF'}{'S' . $domain} = $$self{'myport_sctp'}; } ; delete $$self{'INF'}{$_ . $domaindel} foreach ('I'); if ($$self{'ipv6_only'}) { delete $$self{'INF'}{$_ . $domaindel} foreach ('U', 'S'); } ; $$self{'INF'}{'SU'} ||= join(',', keys %{{} unless $$self{'SU'};}); return $$self{'INF'}; }
325 0 0 $peerid ||= ''
513 0 0 -s $found || -1
636 0 0 $$self{'protocol_supported'}{$proto} || 'adc'
669 0 0 $$self{'parse'} ||= {'SUP', sub { my $self = shift() if ref $_[0]; my($dst, $peerid) = @{shift();}; if ($dst eq 'H') { $self->cmd('I', 'SUP'); $peerid ||= $self->base_encode(pack('S', $$self{'number'})); $peerid = 'A' x (4 - length($peerid)) . $peerid; $$self{'peerid'} ||= $peerid; $self->cmd('I', 'SID', $peerid); $self->cmd('I', 'INF'); $$self{'status'} = 'connected'; } elsif ($dst eq 'C') { $self->cmd($dst, 'SUP'); $self->cmd($dst, 'INF') unless $$self{'count_sendcmd'}{'CINF'}; } ; $peerid ||= ''; foreach $_ ($self->adc_strings_decode(@_)) { if ((s/^(AD|RM)//)[0] eq 'RM') { delete $$self{'peers'}{$peerid}{'SUP'}{$_}; } else { $$self{'peers'}{$peerid}{'SUP'}{$_} = 1; } ; } ; return $$self{'peers'}{$peerid}{'SUP'}; } , 'SID', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; return $$self{'INF'}{'SID'} unless $dst eq 'I'; $$self{'INF'}{'SID'} = $_[0]; if ($dst eq 'I') { $self->cmd('B', 'INF'); $$self{'status'} = 'connected'; } ; return $$self{'INF'}{'SID'}; } , 'INF', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; my $params = $self->adc_parse_named(@_); my $peersid = $peerid; if ($dst ne 'B' and $peerid ||= $$params{'ID'}) { $self->log('adcdev', 'INF:', "moving peer '' to $peerid"); $$self{'peerid'} ||= $peerid; $$self{'peers'}{$peerid}{$_} = $$self{'peers'}{''}{$_} foreach (keys %{{} unless $$self{'peers'}{''};}); delete $$self{'peers'}{''}; } ; my $sendbinf; if ($$self{'parent'}{'hub'} and $dst eq 'B') { unless (keys %{$$self{'peers'}{$peerid}{'INF'};}) { $self->cmd('B', 'INF', $_, $$self{'peers_sid'}{$_}{'INF'}) foreach (keys %{$$self{'peers_sid'};}); } ; } ; my $v = $$self{'hostip'} =~ /:/ ? '6' : '4'; $self->log('adcdev', qq[ip change from [$$params{"I$v"}] to [$$self{'hostip'}] ]), $$params{"I$v"} = $$self{'hostip'} if $dst eq 'B' and $$self{'parent'}{'hub'} and $$params{"I$v"} and $$params{"I$v"} ne $$self{'hostip'}; $v = $$self{'recv_hostip'} =~ /:/ ? '6' : '4'; if ($$self{'broadcast'}) { $self->log('adcdev', qq[ip change from [$$params{"I$v"}] to [$$self{'recv_hostip'}:$$self{'recv_port'}] ($$self{'recv_hostip'}:$$self{'port'})]); $$params{"U$v"} ||= $$self{'port'}; $$params{"I$v"} ||= $$self{'recv_hostip'}; } ; if ($peerid eq $$self{'INF'}{'SID'} and not $$self{'myip'}) { $$self{'myip'} ||= $$params{'I4'}; $$self{'INF'}{'I4'} ||= $$params{'I4'}; $self->log('adcdev', "ip detected: [$$self{'myip'}:$$self{'myport'}]"); } ; $$self{'peers'}{$peerid}{'INF'}{$_} = $$params{$_} foreach (keys %$params); $$self{'peers'}{$peerid}{'object'} = $self; $$self{'peers'}{$$params{'ID'}} ||= $$self{'peers'}{$peerid}; $$self{'peers'}{$peerid}{'SID'} ||= $peersid; $$self{'peers_sid'}{$peersid} ||= $$self{'peers'}{$peerid}; $$self{'peers_cid'}{$$self{'peers'}{$peerid}{'INF'}{'ID'}} ||= $$self{'peers'}{$peerid}; if ($dst eq 'C') { $$self{'status'} = 'connected'; $self->cmd($dst, 'INF') unless $$self{'count_sendcmd'}{'CINF'}; if ($$params{'TO'}) { (); } else { (); } ; $self->file_select; $self->cmd($dst, 'GET'); } ; if ($$self{'parent'}{'hub'}) { my $params_send = \%$params; delete $$params_send{'PD'}; $self->cmd_all($dst, 'INF', $peerid, $self->adc_make_string($params_send)); } ; if ($$self{'broadcast'} and $peerid ne $$self{'INF'}{'SID'} and $dst eq 'B') { $self->cmd('D', 'INF') if $$self{'broadcast'}; } ; return $params; } , 'QUI', sub { my $self = shift() if ref $_[0]; my($dst, $peerid) = @{shift();}; delete $$self{'peers_cid'}{$$self{'peers'}{$peerid}{'INF'}{'ID'}}; delete $$self{'peers_sid'}{$peerid}; delete $$self{'peers'}{$peerid}; undef; } , 'STA', sub { my $self = shift() if ref $_[0]; my($dst, $peerid) = @{shift();}; my $code = shift(); $code =~ s/^(.)//; my $severity = $1; @_ = $self->adc_strings_decode(@_); if ($code ~~ '20' and $_[0] =~ /^Reconnecting too fast, you have to wait (\d+) seconds before reconnecting./) { $self->work($1 + 10); } elsif ($code ~~ '30' and $_[0] =~ /^You are disconnected because: You are disconnected for hammering the hub with connect attempts, stop or you'll be kicked !!!/) { $self->work(30); } ; return $severity, $code, $codesSTA{$code}, @_; } , 'SCH', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, @feature) = @{shift();}; $self->cmd_all($dst, 'SCH', $peerid, @feature, @_); my $params = $self->adc_parse_named(@_); my $found = $$self{'share_full'}{$$params{'TR'}} || $$self{'share_full'}{$$params{'AN'}}; my $tth = $$self{'share_tth'}{$found}; if ($found) { my $foundshow = ($found =~ m[^/] ? () : '/') . &Encode::encode($$self{'charset_protocol'}, &Encode::decode($$self{'charset_fs'}, $found, &Encode::FB_WARN()), &Encode::FB_WARN()); $self->log('adcdev', 'SCH', ($dst, $peerid, 'F=>', @feature), $found, -s $found, -e $found, 'c=', $$self{'chrarset_fs'}); local(@_) = {'SI', -s $found || -1, 'SL', $$self{'INF'}{'SL'}, 'FN', $self->adc_path_encode($foundshow), 'TO', $$params{'TO'} || $self->make_token($peerid), 'TR', $$params{'TR'} || $tth}; if ($$self{'peers'}{$peerid}{'INF'}{'I4'} and $$self{'peers'}{$peerid}{'INF'}{'U4'}) { $self->log('dcdev', 'SCH', 'i=', $$self{'peers'}{$peerid}{'INF'}{'I4'}, 'u=', $$self{'peers'}{$peerid}{'INF'}{'U4'}, 'T==>', 'URES ' . $self->adc_make_string($$self{'INF'}{'ID'}, @_)); $self->send_udp($$self{'peers'}{$peerid}{'INF'}{'I4'}, $$self{'peers'}{$peerid}{'INF'}{'U4'}, 'URES ' . $self->adc_make_string($$self{'INF'}{'ID'}, @_)); } else { $self->cmd('D', 'RES', $self->adc_make_string($peerid, @_)); } ; } ; return $params; } , 'RES', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; my $params = $self->adc_parse_named(@_); if ($dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}) { $$self{'peers'}{$toid}{'object'}->cmd('D', 'RES', $peerid, $toid, @_); } else { $$params{'CID'} = $peerid; ($$params{'filename'}) = $$params{'FN'} =~ m[([^\\/]+)$]; my $wdl = $$self{'want_download'}{$$params{'TR'}} || $$self{'want_download'}{$$params{'filename'}}; if ($wdl) { $$wdl{$peerid} = $params; if ($$params{'filename'}) { ++$$self{'want_download_filename'}{$$params{'TR'}}{$$params{'filename'}}; } ; $$self{'want_download'}{$$params{'TR'}}{$peerid} = $params; } ; } ; $params; } , 'MSG', sub { my $self = shift() if ref $_[0]; my($dst, $peerid) = @{shift();}; $self->cmd_all($dst, 'MSG', $peerid, @_); @_ = $self->adc_strings_decode(@_); $self->log('adcdev', $dst, 'MSG', $peerid, '<' . $$self{'peers'}{$peerid}{'INF'}{'NI'} . '>', @_); @_; } , 'RCM', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; $toid ||= shift(); $self->cmd($dst, 'CTM', $peerid, $$self{'protocol_supported'}{$_[0]} || $$self{'protocol_connect'}, $$self{'myport'}, $_[1]) if $toid eq $$self{'INF'}{'SID'}; if ($dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}) { $$self{'peers'}{$toid}{'object'}->cmd('D', 'RCM', $peerid, $toid, @_); } ; } , 'CTM', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; $toid ||= shift(); if ($dst eq 'D' and $$self{'parent'}{'hub'} and ref $$self{'peers'}{$toid}{'object'}) { return $$self{'peers'}{$toid}{'object'}->cmd('D', 'CTM', $peerid, $toid, @_); } ; my($proto, $port, $token) = @_; my $host = $$self{'peers'}{$peerid}{'INF'}{'I4'}; $self->log('dcdev', "( $dst, CTM, $peerid, $toid ) - ($proto, $port, $token) me=$$self{'INF'}{'SID'} p=", $$self{'protocol_supported'}{$proto}); $self->log('dcerr', 'CTM: unknown host', "( $dst, CTM, $peerid, $toid ) - ($proto, $port, $token)") unless $host; $$self{'clients'}{$$self{'peers'}{$peerid}{'INF'}{'ID'} or $host . ':' . $port} = 'Net::DirectConnect::adc'->new('protocol', $$self{'protocol_supported'}{$proto} || 'adc', 'parent', $self, 'host', $host, 'port', $port, 'INF', {%{$$self{'INF'};}, 'TO', $token}, 'message_type', 'C', 'auto_connect', 1, 'reconnects', 0, 'no_listen', 1) if $toid eq $$self{'INF'}{'SID'}; } , 'SND', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; $$self{'filetotal'} //= $_[2] + $_[3]; return $self->file_open; } , 'GET', sub { my $self = shift() if ref $_[0]; my($dst, $peerid, $toid) = @{shift();}; $self->file_send_parse(@_); } }
718 0 0 $$self{'nick_random'} || 100
825 0 0 $$self{'file_recv_from'} || '0'
0 0 $$self{'file_recv_to'} || '-1'
957 0 0 &Net::DirectConnect::notone($$self{'dev_http'}) || 8000
0 0 &Net::DirectConnect::notone($$self{'dev_http'}) || 8000

or 3 conditions

line l !l&&r !l&&!r condition
102 0 0 0 $$self{$_} //= $_{$_}
154 0 0 0 $$self{'ID'} ||= &psmisc::file_read($$self{'ID_file'})
156 0 0 0 $$self{'ID'} ||= join(' ', 'perl', $$self{'myip'}, $VERSION, $0, $$self{'INF'}{'NI'}, time, '$Id: adc.pm 1001 2014-05-07 13:08:30Z pro $')
160 0 0 0 $$self{'PID'} ||= $self->hash($$self{'ID'})
161 0 0 0 $$self{'CID'} ||= $self->hash($$self{'PID'})
162 0 0 0 $$self{'INF'}{'PD'} ||= $self->base_encode($$self{'PID'})
163 0 0 0 $$self{'INF'}{'ID'} ||= $self->base_encode($$self{'CID'})
171 0 0 0 $$self{'INF'}{'NI'} ||= $$self{'Nick'} || 'perlAdcDev'
172 0 0 0 $$self{'PID'} ||= $self->MIME::Base32::decode->{'INF'}{'PD'}
173 0 0 0 $$self{'CID'} ||= $self->MIME::Base32::decode->{'INF'}{'ID'}
175 0 0 0 $$self{'INF'}{'SID'} ||= $$self{'broadcast'} ? $$self{'INF'}{'ID'} : substr($$self{'INF'}{'ID'}, 0, 4)
178 0 0 0 $$self{'INF'}{'SL'} ||= $$self{'S'} || '2'
179 0 0 0 $$self{'INF'}{'SS'} ||= $$self{'sharesize'} || 20025693588
181 0 0 0 $$self{'INF'}{'HN'} ||= $$self{'H'} || 1
182 0 0 0 $$self{'INF'}{'HR'} ||= $$self{'R'} || 0
183 0 0 0 $$self{'INF'}{'HO'} ||= $$self{'O'} || 0
184 0 0 0 $$self{'client'} . $$self{'V'} || 'perl' . $Net::DirectConnect::VERSION . '_' . $VERSION
0 0 0 $$self{'INF'}{'VE'} ||= $$self{'client'} . $$self{'V'} || 'perl' . $Net::DirectConnect::VERSION . '_' . $VERSION
196 0 0 0 $$self{'dev_ipv6'} || $$self{'myip'} =~ /:/
197 0 0 0 $$self{'myport_udp'} || $$self{'myport'}
205 0 0 0 $$self{'INF'}{'SU'} ||= join(',', keys %{{} unless $$self{'SU'};})
241 0 0 0 $$self{$_} //= $_{$_}
275 0 0 0 $$self{$_} ||= $$self{'parent'}{$_}
309 0 0 0 $peerid ||= $self->base_encode(pack('S', $$self{'number'}))
315 0 0 0 $$self{'peerid'} ||= $peerid
375 0 0 0 $peerid ||= $$params{'ID'}
377 0 0 0 $$self{'peerid'} ||= $peerid
406 0 0 0 $$params{"U$v"} ||= $$self{'port'}
407 0 0 0 $$params{"I$v"} ||= $$self{'recv_hostip'}
410 0 0 0 $$self{'myip'} ||= $$params{'I4'}
411 0 0 0 $$self{'INF'}{'I4'} ||= $$params{'I4'}
419 0 0 0 $$self{'peers'}{$$params{'ID'}} ||= $$self{'peers'}{$peerid}
420 0 0 0 $$self{'peers'}{$peerid}{'SID'} ||= $peersid
421 0 0 0 $$self{'peers_sid'}{$peersid} ||= $$self{'peers'}{$peerid}
422 0 0 0 $$self{'peers_cid'}{$$self{'peers'}{$peerid}{'INF'}{'ID'}} ||= $$self{'peers'}{$peerid}
497 0 0 0 $$self{'share_full'}{$$params{'TR'}} || $$self{'share_full'}{$$params{'AN'}}
513 0 0 0 $$params{'TO'} || $self->make_token($peerid)
0 0 0 $$params{'TR'} || $tth
557 0 0 0 $$self{'want_download'}{$$params{'TR'}} || $$self{'want_download'}{$$params{'filename'}}
579 0 0 0 $toid ||= shift()
581 0 0 0 $$self{'protocol_supported'}{$_[0]} || $$self{'protocol_connect'}
609 0 0 0 $toid ||= shift()
636 0 0 0 $$self{'peers'}{$peerid}{'INF'}{'ID'} or $host . ':' . $port
647 0 0 0 $$self{'filetotal'} //= $_[2] + $_[3]
717 0 0 0 $$self{'nick_base'} ||= $$self{'Nick'}
777 0 0 0 $_[0] || $$self{'peerid'}
867 0 0 0 $$self{'incoming'} or $$self{'auto_listen'}