line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=pod |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Net::OSCAR::Connection::Server -- Net::OSCAR server connection |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=cut |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Net::OSCAR::Connection::Server; |
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
|
|
1
|
|
792
|
$Net::OSCAR::Connection::Server::VERSION = '1.928'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$REVISION = '$Revision$'; |
13
|
|
|
|
|
|
|
@ISA = qw(Net::OSCAR::Connection); |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
16
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
17
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
18
|
1
|
|
|
1
|
|
5
|
use Socket; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
715
|
|
19
|
1
|
|
|
1
|
|
7
|
use Symbol; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
use Net::OSCAR::Common qw(:all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
397
|
|
22
|
1
|
|
|
1
|
|
6
|
use Net::OSCAR::Constants; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
198
|
|
23
|
1
|
|
|
1
|
|
7
|
use Net::OSCAR::Connection; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
24
|
1
|
|
|
1
|
|
496
|
use Net::OSCAR::ServerCallbacks; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
469
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new($@) { |
27
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
28
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
29
|
0
|
0
|
|
|
|
|
$self->listen($self->{session}->{port}) unless exists($self->{socket}); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$self->{oscar_state} = "listening"; |
32
|
0
|
|
|
|
|
|
$self->{signon_done} = 0; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub process_one($;$$$) { |
38
|
0
|
|
|
0
|
0
|
|
my($self, $read, $write, $error) = @_; |
39
|
0
|
|
|
|
|
|
my $snac; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if($error) { |
42
|
0
|
|
|
|
|
|
$self->{sockerr} = 1; |
43
|
0
|
|
|
|
|
|
return $self->disconnect(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
0
|
|
|
|
if($write && $self->{outbuff}) { |
47
|
0
|
|
|
|
|
|
$self->log_print(OSCAR_DBG_DEBUG, "Flushing output buffer."); |
48
|
0
|
|
|
|
|
|
$self->flap_put(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
0
|
|
|
|
if($read && !$self->{connected}) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$self->log_print(OSCAR_DBG_NOTICE, "Incoming connection."); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $socket = gensym(); |
55
|
0
|
|
|
|
|
|
accept($socket, $self->{socket}); |
56
|
0
|
|
|
|
|
|
my $peer = $self->{session}->addconn(socket => $socket, conntype => CONNTYPE_SERVER, description => "new peer"); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$peer->set_blocking(0); |
59
|
0
|
|
|
|
|
|
$peer->{connected} = 1; |
60
|
0
|
|
|
|
|
|
$peer->{state} = "write"; |
61
|
0
|
|
|
|
|
|
$peer->{oscar_state} = "new"; |
62
|
0
|
|
|
|
|
|
$self->{session}->callback_connection_changed($peer, "write"); |
63
|
0
|
|
|
|
|
|
return 1; |
64
|
|
|
|
|
|
|
} elsif($write and $self->{oscar_state} eq "new") { |
65
|
0
|
|
|
|
|
|
$self->log_print(OSCAR_DBG_DEBUG, "Putting connack."); |
66
|
0
|
|
|
|
|
|
$self->flap_put(pack("N", 1), FLAP_CHAN_NEWCONN); |
67
|
0
|
|
|
|
|
|
$self->{state} = "readwrite"; |
68
|
0
|
|
|
|
|
|
$self->{session}->callback_connection_changed($self, "readwrite"); |
69
|
0
|
|
|
|
|
|
$self->{oscar_state} = "ready"; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$self->{families} = {}; |
72
|
0
|
|
|
|
|
|
$self->{families}->{$_} = 1 foreach (1..30); |
73
|
|
|
|
|
|
|
} elsif($read) { |
74
|
0
|
|
|
|
|
|
my $no_reread = 0; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
while(1) { |
77
|
0
|
0
|
|
|
|
|
my $flap = $self->flap_get($no_reread) or return 0; |
78
|
0
|
0
|
|
|
|
|
next if length($flap) == 4; |
79
|
0
|
0
|
|
|
|
|
my $snac = $self->snac_decode($flap) or return 0; |
80
|
0
|
|
|
|
|
|
Net::OSCAR::ServerCallbacks::process_snac($self, $snac); |
81
|
|
|
|
|
|
|
} continue { |
82
|
0
|
|
|
|
|
|
$no_reread = 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |