Branch Coverage

blib/lib/Net/EasyTCP.pm
Criterion Covered Total %
branch 238 560 42.5


line true false branch
75 2 2 unless eval "require $$_[1];"
78 2 2 unless ($@)
91 22 0 unless eval "require $$_[1];"
94 0 22 unless ($@)
95 0 0 if ($$_[1] eq 'Crypt::CBC') { }
0 0 elsif ($hasCBC and $$_[2] or not $$_[2]) { }
114 2 0 unless eval "require $$_[1];"
117 0 2 unless ($@)
599 0 10 if ($_ ne lc $_)
604 1 2 if ($para{'mode'} =~ /^c/i) { }
2 0 elsif ($para{'mode'} =~ /^s/i) { }
631 0 0 if ($$self{'_mode'} ne 'server')
648 0 0 if ($$self{'_mode'} ne 'server')
666 0 2 if ($$self{'_mode'} ne 'server')
671 0 6 if (ref $para{$_} ne 'CODE')
687 0 1 if ($$self{'_mode'} ne 'server')
698 0 12 unless $self->do_one_loop
699 0 12 if ($callback and ref $callback eq 'CODE')
732 0 13 if ($$self{'_mode'} ne 'server')
739 1 12 if ($_ == $$self{'_sock'}) { }
745 0 1 unless ($clientsock)
753 0 1 unless $peername = getpeername $clientsock
754 0 1 unless ($remoteport, $remoteip) = sockaddr_in($peername)
755 0 1 unless $remoteip = inet_ntoa($remoteip)
761 0 1 if (scalar keys %{$$self{'_clientip'};} and not $$self{'_clientip'}{$remoteip}) { }
812 0 12 if (not defined $result) { }
1 11 elsif ($result == 0) { }
846 1 10 if ($$_{'realdata'}) { }
871 10 2 if ($$serverclient{'_negotiating'})
872 0 10 if (_serverclient_negotiate($serverclient)) { }
0 10 elsif (time - $$serverclient{'_negotiating'} > $negotiatingtimeout) { }
885 0 12 if (not $$self{'_donotencrypt'} || $$self{'_donotencryptwith'}{'B'} and time - $$self{'_lastglobalkeygentime'} >= 3600)
886 0 0 unless (_generateglobalkeypair('Crypt::RSA'))
902 0 0 if ($$self{'_mode'} ne 'server')
916 0 2 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
928 0 0 unless ($$self{'_serial'})
942 0 34 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
949 12 22 wantarray ? :
969 0 12 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
980 11 1 $timeout ? :
982 1 11 if (not @ready) { }
987 1 0 if (not $!) { }
0 0 elsif ($! =~ /interrupt/i) { }
992 1 0 if (not $timeout) { }
1028 0 11 if (not defined $result) { }
0 11 elsif ($result == 0) { }
1034 0 0 if (not $timeout) { }
1052 0 0 if (not $timeout) { }
1070 11 0 if ($timeout and $result != $Net::EasyTCP::PACKETSIZE and _extractdata($self))
1096 1 10 if ($realdata) { }
1108 10 0 if ($returninternaldata) { }
1124 0 1 if (defined($result = $self->data))
1135 1 0 if (not $timeout) { }
1140 0 1 if ($fatalerror) { }
1178 0 1 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
1182 0 1 if ($$self{'_selector'} and $$self{'_selector'}->exists($$self{'_sock'}))
1187 1 0 if defined $$self{'_sock'}
1199 0 0 if ($$self{'_mode'} ne 'server')
1211 0 0 $$self{'_mode'} eq 'server' ? :
1221 0 0 if ($$self{'_donotencrypt'} or not $modulekey)
1233 0 0 if ($$self{'_donotcompress'} or not $modulekey)
1244 0 0 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
1259 0 0 if ($$self{'_mode'} ne 'server')
1264 0 0 unless ($$_{'_negotiating'})
1268 0 0 if (@clients) { }
1269 0 0 wantarray ? :
1282 0 0 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
1295 0 0 if ($$self{'_mode'} ne 'client' and $$self{'_mode'} ne 'serverclient')
1325 0 18 if ($ref1 ne $ref2) { }
0 18 elsif (not $ref1 and $item1 ne $item2) { }
4 14 elsif ($ref1 eq 'ARRAY') { }
4 10 elsif ($ref1 eq 'HASH') { }
0 10 elsif ($ref1) { }
1338 0 4 if ($num1 != $num2) { }
1346 0 12 unless (_comparereferences($$item1[$temp], $$item2[$temp]))
1355 0 4 if (scalar @keys1 != scalar @keys2) { }
1363 0 4 if ($keys1[$temp] ne $keys2[$temp])
1367 0 4 unless (_comparereferences($$item1{$keys1[$temp]}, $$item2{$keys2[$temp]}))
1393 0 2 if ($_ ne '_order' and $Net::EasyTCP::_ENCRYPT_AVAILABLE{$_}{'name'} eq $module)
1395 0 0 unless ($Net::EasyTCP::_ENCRYPT_AVAILABLE{$_}{'localpublickey'}, $Net::EasyTCP::_ENCRYPT_AVAILABLE{$_}{'localprivatekey'}) = _genkey($_)
1436 4 2 if (defined $data and $$client{'_version'} == 0.07 || $$client{'_version'} == 0.08 || $$client{'_version'} >= 0.15) { }
1463 3 0 if (not $$client{'_negotiating'} and $$client{'_callbacks'}{$type})
1506 0 0 if (not $forcompat and $Net::EasyTCP::_ENCRYPT_AVAILABLE{$modulekey}{'localpublickey'} and $Net::EasyTCP::_ENCRYPT_AVAILABLE{$modulekey}{'localprivatekey'}) { }
0 0 elsif ($forcompat and $Net::EasyTCP::_ENCRYPT_AVAILABLE{$modulekey}{'localcompatpublickey'} and $Net::EasyTCP::_ENCRYPT_AVAILABLE{$modulekey}{'localcompatprivatekey'}) { }
0 0 elsif ($module eq 'Crypt::RSA') { }
0 0 elsif ($module eq 'Crypt::Rijndael') { }
0 0 elsif ($module eq 'Crypt::RC6') { }
0 0 elsif ($module eq 'Crypt::Blowfish') { }
0 0 elsif ($module eq 'Crypt::DES_EDE3') { }
0 0 elsif ($module eq 'Crypt::DES') { }
0 0 elsif ($module eq 'Crypt::Twofish2') { }
0 0 elsif ($module eq 'Crypt::Twofish') { }
0 0 elsif ($module eq 'Crypt::TEA') { }
0 0 elsif ($module eq 'Crypt::CipherSaber') { }
1517 0 0 unless ($key1, $key2) = $temp->keygen('Size', 512, 'Verbosity', 0)
1523 0 0 if ($key1 and $key2)
1528 0 0 if ($forcompat)
1574 0 0 if (not $key1 && $key2) { }
1599 7 0 if ($module eq 'Compress::Zlib') { }
0 0 elsif ($module eq 'Compress::LZF') { }
1612 7 0 if ($newdata) { }
1632 6 1 if ($module eq 'Compress::Zlib') { }
0 1 elsif ($module eq 'Compress::LZF') { }
1645 6 1 if ($newdata) { }
1672 0 0 if (defined $$client{'_password'}) { }
1684 0 0 if ($mergewithpassword and defined $cleanpassword and length $cleanpassword and $$client{'_authenticated'} and not $$client{'_negotiating'} and $$client{'_version'} >= 0.15)
1685 0 0 if (length $cleanpassword <= length $publickey) { }
0 0 elsif (length $cleanpassword > length $publickey) { }
1696 0 0 if ($publickey =~ /^(\%[0-9A-F]{2})+$/)
1708 0 0 if ($module eq 'Crypt::RSA') { }
0 0 elsif ($module eq 'Crypt::CipherSaber') { }
0 0 elsif ($cbc) { }
1711 0 0 unless $newdata = $temp->encrypt('Message', $$rdata, 'Key', $publickey, 'Armour', 0)
1734 0 0 if ($newdata) { }
1759 0 0 if (defined $$client{'_password'}) { }
1771 0 0 if ($mergewithpassword and defined $cleanpassword and length $cleanpassword and $$client{'_authenticated'} and not $$client{'_negotiating'} and $$client{'_version'} >= 0.15)
1772 0 0 if (length $cleanpassword <= length $privatekey) { }
0 0 elsif (length $cleanpassword > length $privatekey) { }
1783 0 0 if ($privatekey =~ /^(\%[0-9A-F]{2})+$/)
1794 0 0 if ($module eq 'Crypt::RSA') { }
0 0 elsif ($module eq 'Crypt::CipherSaber') { }
0 0 elsif ($cbc) { }
1796 0 0 unless (ref $privatekey)
1797 0 0 if ($privatekey =~ /bless/) { }
1800 0 0 unless $temp = 'Crypt::RSA::Key::Private'->new
1801 0 0 unless $privatekey = $temp->deserialize('String', [$privatekey])
1808 0 0 unless $newdata = $temp->decrypt('Cyphertext', $$rdata, 'Key', $privatekey, 'Armour', 0)
1831 0 0 if ($newdata) { }
1855 1 1 if ($lettersonly) { }
1874 0 0 if ($module eq 'Crypt::Random' and $version >= 0.34)
1916 0 10 unless (defined $reply)
1923 0 10 unless ($command)
1927 0 10 if ($command eq 'PF') { }
1 9 elsif ($command eq 'COS') { }
0 9 elsif ($command eq 'COF') { }
0 9 elsif ($command eq 'CVF' and not $$client{'_donotcheckversion'}) { }
0 9 elsif ($command eq 'EVF' and not $$client{'_donotcheckversion'}) { }
1 8 elsif ($command eq 'EN') { }
1 7 elsif ($command eq 'VE') { }
1 6 elsif ($command eq 'SVE') { }
0 6 elsif ($command eq 'SVF' and not $$client{'_donotcheckversion'}) { }
1 5 elsif ($command eq 'CS') { }
1 4 elsif ($command eq 'EK') { }
0 4 elsif ($command eq 'EM') { }
0 4 elsif ($command eq 'EU') { }
1 3 elsif ($command eq 'EA') { }
1 2 elsif ($command eq 'CM') { }
0 2 elsif ($command eq 'CU') { }
1 1 elsif ($command eq 'CA') { }
1995 1 0 if ($P[1])
2001 0 1 if (not $temp or $@)
2005 0 1 unless (_comparereferences($temp, $$client{'_compatabilityreference'}))
2011 1 0 if ($$client{'_compatabilityreference'})
2048 0 0 if ($$client{'_donotencryptwith'}{$P[0]}) { }
0 0 elsif (not $$client{'_donotencrypt'}) { }
2063 0 0 unless ($@)
2068 0 0 if (_decrypt($client, \$tempscalar) and $tempscalar eq $$client{'_compatabilityscalar'}) { }
2074 0 0 if ($temppublic and $tempprivate) { }
2080 0 0 if (_encrypt($client, \$tempscalar))
2081 0 0 ref $tempprivate ? :
2117 0 0 if ($$client{'_donotencryptwith'}{$P[0]}) { }
0 0 elsif (not $$client{'_donotencrypt'}) { }
2139 1 0 unless ($$client{'_donotencrypt'})
2141 0 0 if ($Net::EasyTCP::_ENCRYPT_AVAILABLE{$_})
2151 0 1 if ($temp2)
2163 0 1 if ($$client{'_donotcompresswith'}{$P[0]}) { }
1 0 elsif (not $$client{'_donotcompress'}) { }
2173 0 1 if (_decompress($client, \$tempscalar) and $tempscalar eq $$client{'_compatabilityscalar'}) { }
2178 0 0 if (_compress($client, \$tempscalar))
2204 0 0 if ($$client{'_donotcompresswith'}{$P[0]}) { }
0 0 elsif (not $$client{'_donotcompress'}) { }
2223 1 0 unless ($$client{'_donotcompress'})
2225 1 0 if ($Net::EasyTCP::_COMPRESS_AVAILABLE{$_})
2235 1 0 if ($temp2)
2246 0 10 if (defined $data and not _send($client, $data, 0))
2256 2 8 if (defined $evl)
2258 1 1 if ($evl =~ /^RETURN(.+)$/)
2259 1 0 $1 ? :
2285 0 20 unless ($$client{'_negotiating'})
2292 10 10 unless (defined $reply)
2293 1 19 unless (defined $$client{'_negotiating_lastevent'})
2295 10 10 if (length $reply) { }
10 0 elsif ($$client{'_negotiating_lastevent'} ne 'sent') { }
2302 0 10 unless ($command)
2307 1 9 if ($command eq 'EU') { }
0 9 elsif ($command eq 'EM') { }
1 8 elsif ($command eq 'CP') { }
1 7 elsif ($command eq 'COS') { }
1 6 elsif ($command eq 'VE') { }
1 5 elsif ($command eq 'SVE') { }
0 5 elsif ($command eq 'CM') { }
1 4 elsif ($command eq 'CU') { }
1 3 elsif ($command eq 'EK') { }
1 2 elsif ($command eq 'EN') { }
2313 0 1 if ($$client{'_encrypt'})
2315 0 0 if ($version ne $P[1] and not $$client{'_negotiatedencryptcompatability'})
2318 0 0 unless ($$client{'_localpublickey'}, $$client{'_localprivatekey'}) = _genkey($$client{'_encrypt'})
2329 0 0 if ($$client{'_donotencryptwith'}{$P[0]}) { }
0 0 elsif (not $$client{'_donotencrypt'}) { }
2347 0 0 unless ($@)
2352 0 0 if (_decrypt($client, \$tempscalar) and $tempscalar eq $$client{'_compatabilityscalar'})
2386 1 0 if (_munge($client, $P[0]) eq crypt($$client{'_password'}, $$client{'_cryptsalt'})) { }
2399 0 1 if ($$client{'_compatabilityscalar'} ne _asc2bin($P[0]))
2416 1 0 if ($P[1]) { }
0 0 elsif ($P[0] ne $Storable::VERSION) { }
2422 0 1 unless ($temp)
2425 0 1 unless (_comparereferences($temp, $$client{'_compatabilityreference'}))
2442 0 0 if ($$client{'_donotcompresswith'}{$P[0]}) { }
0 0 elsif (not $$client{'_donotcompress'}) { }
2453 0 0 if (_decompress($client, \$tempscalar) and $tempscalar eq $$client{'_compatabilityscalar'})
2487 1 0 if ($$client{'_compress'})
2489 0 1 if ($version ne $P[1] and not $$client{'_negotiatedcompresscompatability'})
2506 0 1 if (defined $$client{'_password'} and length $$client{'_password'} and not $$client{'_authenticated'}) { }
2544 1 9 unless (defined $$client{'_negotiating_commands'})
2554 0 1 if ($$client{'_welcome'})
2567 1 0 unless ($$client{'_donotencrypt'})
2575 0 0 if ($$client{'_donotencryptwith'}{$key})
2580 0 0 unless ($temppublic, $tempprivate) = _genkey($key, 1)
2584 0 0 if (_encrypt($client, \$tempscalar))
2586 0 0 ref $tempprivate ? :
2599 1 0 unless ($$client{'_donotcompress'})
2607 0 1 if ($$client{'_donotcompresswith'}{$key})
2614 1 0 if (_compress($client, \$tempscalar))
2628 1 0 if (defined $$client{'_password'})
2629 1 0 unless (exists $$client{'_cryptsalt'})
2639 0 10 if ($data =~ /^EA\x00/ and $$client{'_negotiatedencryptcompatability'} or $data =~ /^CA\x00/ and $$client{'_negotiatedcompresscompatability'})
2646 0 10 unless (defined $data)
2649 0 10 unless (_send($client, $data, 0))
2666 10 0 if ($$client{'_mode'} eq 'serverclient' and $$client{'_negotiating'}) { }
2669 1 9 if (_serverclient_negotiate($client))
2680 0 0 if (not defined $data)
2734 1 1 if (not $para{'_sock'}) { }
2735 0 1 if (not $para{'host'}) { }
0 1 elsif (not $para{'port'}) { }
2758 0 2 unless ($sock)
2763 1 1 if ($para{'_remoteport'} and $para{'_remoteip'}) { }
2768 0 1 unless ($temp = getpeername $sock)
2772 0 1 unless (($remoteport, $remoteip) = sockaddr_in($temp))
2776 0 1 unless ($$self{'_remoteip'} = inet_ntoa($remoteip))
2784 0 2 $para{'donotcompress'} ? :
2785 0 2 $para{'donotencrypt'} ? :
2786 0 2 $para{'donotcheckversion'} ? :
2794 2 0 if (ref $para{'donotcompresswith'} ne 'ARRAY')
2798 0 4 if ($key ne '_order' and grep {$Net::EasyTCP::_COMPRESS_AVAILABLE{$key}{'name'} eq $_;} @{$para{'donotcompresswith'};})
2807 2 0 if (ref $para{'donotencryptwith'} ne 'ARRAY')
2811 0 2 if ($key ne '_order' and grep {$Net::EasyTCP::_ENCRYPT_AVAILABLE{$key}{'name'} eq $_;} @{$para{'donotencryptwith'};})
2818 1 1 if ($$self{'_mode'} eq 'client')
2819 0 1 if (not _client_negotiate($self)) { }
2844 0 2 unless ($para{'port'})
2854 0 2 unless ($sock)
2865 0 2 $para{'donotcompress'} ? :
2866 0 2 $para{'donotencrypt'} ? :
2874 2 0 if (ref $para{'donotcompresswith'} ne 'ARRAY')
2878 0 4 if ($key ne '_order' and grep {$Net::EasyTCP::_COMPRESS_AVAILABLE{$key}{'name'} eq $_;} @{$para{'donotcompresswith'};})
2887 2 0 if (ref $para{'donotencryptwith'} ne 'ARRAY')
2891 0 2 if ($key ne '_order' and grep {$Net::EasyTCP::_ENCRYPT_AVAILABLE{$key}{'name'} eq $_;} @{$para{'donotencryptwith'};})
2899 2 0 unless ($$self{'_donotencrypt'} or $$self{'_donotencryptwith'}{'B'})
2900 0 2 unless (_generateglobalkeypair('Crypt::RSA'))
2921 56 0 defined $$client{'_databuffer'} ? :
2922 34 22 if (length $key != 2)
2935 0 22 unless ($alwayson)
2940 0 22 if (length $$client{'_databuffer'} < 2 + $lenlen + $lendata)
2944 0 22 if (length $data != $lendata)
2948 0 22 if ($encrypted)
2949 0 0 unless _decrypt($client, \$data)
2951 6 16 if ($compressed)
2952 0 6 unless _decompress($client, \$data)
2954 1 21 if ($complexstructure)
2956 0 1 unless ($data)
3007 0 22 if (not $sock) { }
0 22 elsif (not defined $data) { }
3015 1 21 if ($complexstructure)
3018 0 22 $$client{'_donotcompress'} ? :
3019 0 22 $$client{'_donotencrypt'} ? :
3032 1 21 $complexstructure ? :
3035 20 2 defined $realdata && !$realdata ? :
3038 0 22 $encrypted ? :
3041 6 16 $compressed ? :
3063 0 22 unless (defined $bytes_written)
3069 0 22 if ($temp != $len) { }