| 1 | package Net::IPMessenger::RecvEventHandler; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw( Net::IPMessenger::EventHandler ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | sub BR_ENTRY { | ||||||||||||||||||||||||||||||
|
Subroutine
BR_ENTRY: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 9 | 1 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 10 | 1 | my $command = $ipmsg->messagecommand('ANSENTRY'); | |||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | $command->set_encrypt if $ipmsg->encrypt; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 12 | 1 | $ipmsg->send( | |||||||||||||||||||||||||||||||
| 13 | { | ||||||||||||||||||||||||||||||||
| 14 | command => $command, | ||||||||||||||||||||||||||||||||
| 15 | option => $ipmsg->my_info, | ||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub ANSLIST { | ||||||||||||||||||||||||||||||
|
Subroutine
ANSLIST: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 21 | 0 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 22 | 0 | my $key = $user->key; | |||||||||||||||||||||||||||||||
| 23 | 0 | my $peeraddr = inet_ntoa( $ipmsg->socket->peeraddr ); | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 0 | $ipmsg->parse_anslist( $user, $peeraddr ); | |||||||||||||||||||||||||||||||
| 26 | 0 | delete $ipmsg->user->{$key}; | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | sub SENDMSG { | ||||||||||||||||||||||||||||||
|
Subroutine
SENDMSG: called CC=6 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 1 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 31 | 1 | my $command = $ipmsg->messagecommand( $user->command ); | |||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if ( $command->get_sendcheck ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 1 | $ipmsg->send( | |||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||
| 35 | command => $ipmsg->messagecommand('RECVMSG'), | ||||||||||||||||||||||||||||||||
| 36 | option => $user->packet_num, | ||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | # decrypt message if the message is encrypted | ||||||||||||||||||||||||||||||||
| 42 | # and encryption support is available | ||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | if ( $command->get_encrypt and $ipmsg->encrypt ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$command->get_encrypt and $ipmsg->encrypt
MC/DC0%0/2
$command->get_encrypt and $ipmsg->encrypt
$command->get_encrypt
$ipmsg->encrypt
Truth table33%1/3
A and B
A= $command->get_encryptB= $ipmsg->encrypt
| |||||||||||||||||||||||||||||||||
| 44 | 0 | my $encrypt = $ipmsg->encrypt; | |||||||||||||||||||||||||||||||
| 45 | 0 | my $decrypted = $encrypt->decrypt_message( $user->get_message ); | |||||||||||||||||||||||||||||||
| 46 | 0 | $user->option($decrypted); | |||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ( $command->get_fileattach ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 0 | $user->attach( $encrypt->attach ); | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | elsif ( $command->get_fileattach ) { | ||||||||||||||||||||||||||||||||
| 52 | 0 | my( $option, $attach ) = split /\0/, $user->get_message; | |||||||||||||||||||||||||||||||
| 53 | 0 | $user->option($option); | |||||||||||||||||||||||||||||||
| 54 | 0 | $user->attach($attach); | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | 1 | push @{ $ipmsg->message }, $user; | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub RECVMSG { | ||||||||||||||||||||||||||||||
|
Subroutine
RECVMSG: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 60 | 1 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 61 | 1 | my $option = $user->option; | |||||||||||||||||||||||||||||||
| 62 | 1 | $option =~ s/\0//g; | |||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | if ( exists $ipmsg->sending_packet->{$option} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | 1 | delete $ipmsg->sending_packet->{$option}; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub READMSG { | ||||||||||||||||||||||||||||||
|
Subroutine
READMSG: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 69 | 0 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 70 | 0 | my $command = $ipmsg->messagecommand( $user->command ); | |||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $command->get_readcheck ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 72 | 0 | $ipmsg->send( | |||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||
| 74 | command => $ipmsg->messagecommand('ANSREADMSG'), | ||||||||||||||||||||||||||||||||
| 75 | option => $user->packet_num, | ||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub GETINFO { | ||||||||||||||||||||||||||||||
|
Subroutine
GETINFO: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 82 | 0 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 83 | 0 | $ipmsg->send( | |||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||
| 85 | command => $ipmsg->messagecommand('SENDINFO'), | ||||||||||||||||||||||||||||||||
| 86 | option => sprintf( "Net::IPMessenger-%s", $ipmsg->VERSION ), | ||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub GETPUBKEY { | ||||||||||||||||||||||||||||||
|
Subroutine
GETPUBKEY: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 92 | 0 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | return unless $ipmsg->encrypt; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | 0 | $ipmsg->send( | |||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||
| 96 | command => $ipmsg->messagecommand('ANSPUBKEY'), | ||||||||||||||||||||||||||||||||
| 97 | option => $ipmsg->encrypt->public_key_string, | ||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub ANSPUBKEY { | ||||||||||||||||||||||||||||||
|
Subroutine
ANSPUBKEY: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 103 | 0 | my( $self, $ipmsg, $user ) = @_; | |||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | return unless $ipmsg->encrypt; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | 0 | my $key = $user->key; | |||||||||||||||||||||||||||||||
| 106 | 0 | my $message = $user->get_message; | |||||||||||||||||||||||||||||||
| 107 | 0 | my( $option, $public_key ) = split /:/, $message; | |||||||||||||||||||||||||||||||
| 108 | 0 | my( $exponent, $modulus ) = split /\-/, $public_key; | |||||||||||||||||||||||||||||||
| 109 | 0 | $ipmsg->user->{$key}->pubkey( | |||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||
| 111 | option => $option, | ||||||||||||||||||||||||||||||||
| 112 | exponent => $exponent, | ||||||||||||||||||||||||||||||||
| 113 | modulus => $modulus, | ||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 2 | 1; | |||||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||||||