| 1 | package Net::IPMessenger::CommandLine; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw( Net::IPMessenger ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | __PACKAGE__->mk_accessors( qw( use_secret ) ); | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # sort by IP address | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub by_addr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
by_addr: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my( $ipa1, $ipa2, $ipa3, $ipa4 ) = split( /\./, $a->peeraddr, 4 ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my( $ipb1, $ipb2, $ipb3, $ipb4 ) = split( /\./, $b->peeraddr, 4 ); | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $ipa1 <=> $ipb1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ipa1 <=> $ipb1 or $ipa2 <=> $ipb2 or $ipa3 <=> $ipb3
$ipa1 <=> $ipb1 or $ipa2 <=> $ipb2
MC/DC0%0/3
$ipa1 <=> $ipb1 or $ipa2 <=> $ipb2 or $ipa3 <=> $ipb3
$ipa1 <=> $ipb1
$ipa2 <=> $ipb2
$ipa3 <=> $ipb3
Truth table0%0/4
A or B or C
A= $ipa1 <=> $ipb1B= $ipa2 <=> $ipb2C= $ipa3 <=> $ipb3
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | || $ipa2 <=> $ipb2 | ||||||||||||||||||||||||||||||||||||||||||
| 19 | || $ipa3 <=> $ipb3 | ||||||||||||||||||||||||||||||||||||||||||
| 20 | || $ipa4 <=> $ipb4; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub dumper { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumper: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | import Data::Dumper qw(Dumper); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $output = Dumper($self) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub debuguserbyaddr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debuguserbyaddr: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $addr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | for my $key ( keys %{ $self->user } ) { | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $hashref = $self->user->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ( $hashref->addr eq $addr ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $output .= $key . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | for my $item ( sort keys %{$hashref} ) { | |||||||||||||||||||||||||||||||||||||||||
| 43 | $output .= sprintf "\t%-12s : %s\n", $item, $hashref->{$item} | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if defined $hashref->{$item}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub socktest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socktest: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return sprintf "socktest %s\n", inet_ntoa( $self->socket->peeraddr ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # Command | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $name = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $name =~ s/.*://; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return "$name is not the command"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub join { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->user( {} ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $command = $self->messagecommand('BR_ENTRY')->set_broadcast; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $self->encrypt ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $command->set_encrypt; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | $self->send( | ||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | command => $command, | |||||||||||||||||||||||||||||||||||||||||
| 77 | option => $self->my_info, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub quit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $command = $self->messagecommand('BR_EXIT')->set_broadcast; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $self->send( { command => $command, } ); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return 'exiting'; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | print " ip address : port : nickname\n"; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | print "-----------------:------:---------\n"; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( $self->user ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | for my $val ( sort by_addr values %{ $self->user } ) { | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $output .= sprintf "%16s : %s : %s\n", $val->peeraddr, | |||||||||||||||||||||||||||||||||||||||||
| 101 | $val->peerport, $val->nickname; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $output .= sprintf "%s users listed\n", $i; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub messages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messages: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||
| 112 | my $j; | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( $self->message and @{ $self->message } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->message and @{$self->message;}
MC/DC0%0/2
$self->message and @{$self->message;}
$self->message
@{$self->message;}
Truth table0%0/3
A and B
A= $self->messageB= @{$self->message;}
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | for my $message ( @{ $self->message } ) { | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $output .= sprintf "%03d : %s : %s\n", ++$j, $message->time, | |||||||||||||||||||||||||||||||||||||||||
| 116 | $message->nickname; | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $output = "no message arrived"; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $self->message and @{ $self->message } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->message and @{$self->message;}
MC/DC0%0/2
$self->message and @{$self->message;}
$self->message
@{$self->message;}
Truth table0%0/3
A and B
A= $self->messageB= @{$self->message;}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $message = shift @{ $self->message }; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $output = sprintf "%s: %s\n%s\n", $message->time, $message->nickname, | |||||||||||||||||||||||||||||||||||||||||
| 133 | $message->get_message; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $command = $self->messagecommand( $message->command ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( $command->get_secret ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->send( | |||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | command => $self->messagecommand('READMSG'), | ||||||||||||||||||||||||||||||||||||||||||
| 140 | option => $message->packet_num, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | peeraddr => $message->peeraddr, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | peerport => $message->peerport | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $output = "no message arrived"; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $sendto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | unless ( defined $sendto ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return ("Usage: write nickname_to_send"); | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $target; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | for my $user ( values %{ $self->user } ) { | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ( $user->nickname eq $sendto ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ( $user->encrypt and $self->encrypt and not $user->pubkey ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$user->encrypt and $self->encrypt and not $user->pubkey
$user->encrypt and $self->encrypt
MC/DC0%0/3
$user->encrypt and $self->encrypt and not $user->pubkey
$user->encrypt
$self->encrypt
not $user->pubkey
Truth table0%0/4
A and B and not(C)
A= $user->encryptB= $self->encryptC= not $user->pubkey
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $option = sprintf "%x", | |||||||||||||||||||||||||||||||||||||||||
| 166 | $self->encrypt->support_encryption; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->send( | |||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | command => $self->messagecommand('GETPUBKEY'), | ||||||||||||||||||||||||||||||||||||||||||
| 170 | option => $option, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | peeraddr => $user->peeraddr, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | peerport => $user->peerport, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $target = $user; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return "no target found" unless defined $target; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{_target} = $target; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->{_write_buffer} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return <<__MESSAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 186 | writing message to '$sendto' is ready | ||||||||||||||||||||||||||||||||||||||||||
| 187 | input message then '.' to finish and send it. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | __MESSAGE__ | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub writing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writing: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ( $data eq '.' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $target = $self->{_target}; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $peeraddr = $target->peeraddr; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $peerport = $target->peerport; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ( $peeraddr and $peerport ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$peeraddr and $peerport
MC/DC0%0/2
$peeraddr and $peerport
$peeraddr
$peerport
Truth table0%0/3
A and B
A= $peeraddrB= $peerport
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $command = $self->messagecommand('SENDMSG'); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $command->set_sendcheck; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $command->set_secret if $self->use_secret; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | # encrypt message | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( $target->encrypt and $self->encrypt ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target->encrypt and $self->encrypt
MC/DC0%0/2
$target->encrypt and $self->encrypt
$target->encrypt
$self->encrypt
Truth table0%0/3
A and B
A= $target->encryptB= $self->encrypt
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $command->set_encrypt; | |||||||||||||||||||||||||||||||||||||||||
| 209 | my $encrypted = $self->encrypt->encrypt_message( | ||||||||||||||||||||||||||||||||||||||||||
| 210 | $self->{_write_buffer}, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $target->pubkey, | |||||||||||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->{_write_buffer} = $encrypted; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | $self->send( | ||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | command => $command, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | option => $self->{_write_buffer}, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | peeraddr => $peeraddr, | |||||||||||||||||||||||||||||||||||||||||
| 221 | peerport => $peerport | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | delete $self->{_write_buffer}; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | delete $self->{_target}; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->{_write_buffer} .= $data . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub is_writing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_writing: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( exists $self->{_write_buffer} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $output = "It's Your information\n"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $output .= sprintf "nickname : %s\n", $self->nickname; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $output .= sprintf "groupname : %s\n", $self->groupname; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $output .= sprintf "username : %s\n", $self->username; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $output .= sprintf "hostname : %s\n", $self->hostname; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $output .= sprintf "server addr : %s\n", $self->serveraddr; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $output .= sprintf "broadcast addr : %s\n", @{ $self->broadcast } || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
@{$self->broadcast;} || ''
MC/DC0%0/1
@{$self->broadcast;} || ''
@{$self->broadcast;}
Truth table0%0/2
A
A= @{$self->broadcast;}
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $output = <<__OUTPUT__; | |||||||||||||||||||||||||||||||||||||||||
| 258 | Text IP Messenger Client Help: | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | This is just another IP messenger client for text console. | ||||||||||||||||||||||||||||||||||||||||||
| 261 | These commands are available. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | Command list (shortcut) : | ||||||||||||||||||||||||||||||||||||||||||
| 264 | join (j) : send entry packet (BR_ENTRY) to the broad cast address | ||||||||||||||||||||||||||||||||||||||||||
| 265 | info (i) : show information of yourself | ||||||||||||||||||||||||||||||||||||||||||
| 266 | list (l) : list users | ||||||||||||||||||||||||||||||||||||||||||
| 267 | message (m) : show message list | ||||||||||||||||||||||||||||||||||||||||||
| 268 | read (r) : read 1 oldest message and delete | ||||||||||||||||||||||||||||||||||||||||||
| 269 | write (w) : write message to the nickname user | ||||||||||||||||||||||||||||||||||||||||||
| 270 | quit (q) : send exit packet (BR_EXIT) to the broad cast address | ||||||||||||||||||||||||||||||||||||||||||
| 271 | help (h) : show this help | ||||||||||||||||||||||||||||||||||||||||||
| 272 | __OUTPUT__ | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # regist some shortcuts | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub j { shift->join(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
j: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | sub q { shift->quit(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
q: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub l { shift->list(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
l: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub m { shift->messages(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
m: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub r { shift->read(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
r: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub w { shift->write(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
w: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub i { shift->info(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
i: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub h { shift->help(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
h: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 288 | __END__ | ||||||||||||||||||||||||||||||||||||||||||