| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::IPMessenger::RecvEventHandler; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
72
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
79
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use IO::Socket; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
16
|
|
|
6
|
2
|
|
|
2
|
|
1793
|
use base qw( Net::IPMessenger::EventHandler ); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1272
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub BR_ENTRY { |
|
9
|
1
|
|
|
1
|
1
|
8
|
my( $self, $ipmsg, $user ) = @_; |
|
10
|
1
|
|
|
|
|
5
|
my $command = $ipmsg->messagecommand('ANSENTRY'); |
|
11
|
1
|
50
|
|
|
|
6
|
$command->set_encrypt if $ipmsg->encrypt; |
|
12
|
1
|
|
|
|
|
10
|
$ipmsg->send( |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
|
|
|
|
|
|
command => $command, |
|
15
|
|
|
|
|
|
|
option => $ipmsg->my_info, |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub ANSLIST { |
|
21
|
0
|
|
|
0
|
1
|
0
|
my( $self, $ipmsg, $user ) = @_; |
|
22
|
0
|
|
|
|
|
0
|
my $key = $user->key; |
|
23
|
0
|
|
|
|
|
0
|
my $peeraddr = inet_ntoa( $ipmsg->socket->peeraddr ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$ipmsg->parse_anslist( $user, $peeraddr ); |
|
26
|
0
|
|
|
|
|
0
|
delete $ipmsg->user->{$key}; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub SENDMSG { |
|
30
|
1
|
|
|
1
|
1
|
4
|
my( $self, $ipmsg, $user ) = @_; |
|
31
|
1
|
|
|
|
|
5
|
my $command = $ipmsg->messagecommand( $user->command ); |
|
32
|
1
|
50
|
|
|
|
8
|
if ( $command->get_sendcheck ) { |
|
33
|
1
|
|
|
|
|
5
|
$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
|
50
|
33
|
|
|
82
|
if ( $command->get_encrypt and $ipmsg->encrypt ) { |
|
|
|
50
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
my $encrypt = $ipmsg->encrypt; |
|
45
|
0
|
|
|
|
|
0
|
my $decrypted = $encrypt->decrypt_message( $user->get_message ); |
|
46
|
0
|
|
|
|
|
0
|
$user->option($decrypted); |
|
47
|
0
|
0
|
|
|
|
0
|
if ( $command->get_fileattach ) { |
|
48
|
0
|
|
|
|
|
0
|
$user->attach( $encrypt->attach ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
elsif ( $command->get_fileattach ) { |
|
52
|
0
|
|
|
|
|
0
|
my( $option, $attach ) = split /\0/, $user->get_message; |
|
53
|
0
|
|
|
|
|
0
|
$user->option($option); |
|
54
|
0
|
|
|
|
|
0
|
$user->attach($attach); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
1
|
|
|
|
|
3
|
push @{ $ipmsg->message }, $user; |
|
|
1
|
|
|
|
|
6
|
|
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub RECVMSG { |
|
60
|
1
|
|
|
1
|
1
|
3
|
my( $self, $ipmsg, $user ) = @_; |
|
61
|
1
|
|
|
|
|
5
|
my $option = $user->option; |
|
62
|
1
|
|
|
|
|
9
|
$option =~ s/\0//g; |
|
63
|
1
|
50
|
|
|
|
5
|
if ( exists $ipmsg->sending_packet->{$option} ) { |
|
64
|
1
|
|
|
|
|
12
|
delete $ipmsg->sending_packet->{$option}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub READMSG { |
|
69
|
0
|
|
|
0
|
1
|
|
my( $self, $ipmsg, $user ) = @_; |
|
70
|
0
|
|
|
|
|
|
my $command = $ipmsg->messagecommand( $user->command ); |
|
71
|
0
|
0
|
|
|
|
|
if ( $command->get_readcheck ) { |
|
72
|
0
|
|
|
|
|
|
$ipmsg->send( |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
|
|
|
|
|
|
command => $ipmsg->messagecommand('ANSREADMSG'), |
|
75
|
|
|
|
|
|
|
option => $user->packet_num, |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub GETINFO { |
|
82
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub GETPUBKEY { |
|
92
|
0
|
|
|
0
|
1
|
|
my( $self, $ipmsg, $user ) = @_; |
|
93
|
0
|
0
|
|
|
|
|
return unless $ipmsg->encrypt; |
|
94
|
0
|
|
|
|
|
|
$ipmsg->send( |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
|
|
|
|
|
|
command => $ipmsg->messagecommand('ANSPUBKEY'), |
|
97
|
|
|
|
|
|
|
option => $ipmsg->encrypt->public_key_string, |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub ANSPUBKEY { |
|
103
|
0
|
|
|
0
|
1
|
|
my( $self, $ipmsg, $user ) = @_; |
|
104
|
0
|
0
|
|
|
|
|
return unless $ipmsg->encrypt; |
|
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
|
|
|
|
|
|
|
1; |
|
119
|
|
|
|
|
|
|
__END__ |