lib/Net/BitTorrent/Protocol/BEP06.pm

filter: Statementstmt 83.8% 26 / 31 Branchbran 68.7% 11 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 100% 5 / 5 totaltotal 79.3% 50 / 63 CC 9 SCAR 17.4
CC
9
Cov
79%
_handle_message
10.6
send_have_all
2.0
send_suggest
2.0
CRAP 5.7
« lib/Net/BitTorrent/DHT/Security.pm ↑ Summary lib/Net/BitTorrent/Tracker/Base.pm »
1 25 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 25 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 25 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶class Net::BitTorrent::Protocol::BEP06 v2.1.1 : isa(Net::BitTorrent::Protocol::BEP55) {
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # BEP 06 Message IDs
7 25 ▶ use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 25 HAVE_ALL => 0x0E, # 14
9 HAVE_NONE => 0x0F, # 15
10 SUGGEST_PIECE => 0x0D, # 13
11 REJECT_REQUEST => 0x10, # 16
12 ALLOWED_FAST => 0x11, # 17
13 25 };
14 0 ▶ method send_have_all () { $self->send_message(HAVE_ALL) }
Subroutine send_have_all: not called CC=1 SCAR=6.9
Pod documented
15 2 ▶ method send_have_none () { $self->send_message(HAVE_NONE) }
Subroutine send_have_none: called CC=1 SCAR=0.0
Pod documented
16  
17 0 ▶ method send_suggest ($index) {
Subroutine send_suggest: not called CC=1 SCAR=6.9
Pod documented
18 0 $self->send_message( SUGGEST_PIECE, pack( 'N', $index ) );
19 }
20  
21 0 ▶ method send_reject ( $index, $begin, $length ) {
Subroutine send_reject: not called CC=1 SCAR=6.9
Pod documented
22 0 $self->send_message( REJECT_REQUEST, pack( 'N N N', $index, $begin, $length ) );
23 }
24  
25 8 ▶ method send_allowed_fast ($index) {
Subroutine send_allowed_fast: called CC=1 SCAR=0.0
Pod documented
26 8 $self->send_message( ALLOWED_FAST, pack( 'N', $index ) );
27 }
28  
29 72 ▶ method _handle_message ( $id, $payload ) {
Subroutine _handle_message: called CC=9 SCAR=23.6
30 72 ▶ if ( $id == HAVE_ALL ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($id == 14) { } 1 71 72
elsif ($id == 15) { } 2 69 71
elsif ($id == 13) { } 1 68 69
elsif ($id == 16) { } 0 68 68
elsif ($id == 17) { } 6 62 68
31 1 $self->_emit('have_all');
32 }
33 elsif ( $id == HAVE_NONE ) {
34 2 $self->_emit('have_none');
35 }
36 elsif ( $id == SUGGEST_PIECE ) {
37 1 ▶ return $self->_emit_log( 'warn', 'SUGGEST_PIECE payload too short' ) if length($payload) != 4;
Branch: 1 branch
BranchTrueFalseTotal
if length $payload != 4 0 1 1
38 1 $self->_emit( suggest => unpack( 'N', $payload ) );
39 }
40 elsif ( $id == REJECT_REQUEST ) {
41 0 ▶ return $self->_emit_log( 'warn', 'REJECT payload too short' ) if length($payload) != 12;
Branch: 1 branch
BranchTrueFalseTotal
if length $payload != 12 0 0 0
42 0 $self->_emit( reject => unpack( 'N N N', $payload ) );
43 }
44 elsif ( $id == ALLOWED_FAST ) {
45 6 ▶ return $self->_emit_log( 'warn', 'ALLOWED_FAST payload too short' ) if length($payload) != 4;
Branch: 1 branch
BranchTrueFalseTotal
if length $payload != 4 0 6 6
46 6 $self->_emit( allowed_fast => unpack( 'N', $payload ) );
47 }
48 else {
49 62 $self->SUPER::_handle_message( $id, $payload );
50 }
51 }
52 25 } 1;
« lib/Net/BitTorrent/DHT/Security.pm ↑ Summary lib/Net/BitTorrent/Tracker/Base.pm »