DJabberd/Connection/ClusterIn.pm

filter: Statementstmt 37.2% 19 / 51 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 6 / 9 Podpod 66.6% 2 / 3 totaltotal 30.3% 27 / 89 CC 12 SCAR 40.3
CC
12
Cov
26%
event_read
110.0
new
6.0
set_vhost
6.0
CRAP 56.5
« DJabberd/RosterItem.pm ↑ Summary DJabberd/DNS.pm »
1 package DJabberd::Connection::ClusterIn;
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use base 'DJabberd::Connection';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use DJabberd::ClusterMessage;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use DJabberd::ClusterMessage::DeliverStanza;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use fields (
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 'buf',
8 20 );
9 20 ▶use DJabberd::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
12 0 my ($class, $sock, $server) = @_;
13 0 my $self = Danga::Socket::new($class, $sock);
14  
15 0 $self->{id} = fileno($sock);
16 0 $self->{vhost} = undef; # set once we get a stream start header from them
17 0 $self->{server} = $server;
18 0 $self->{buf} = '';
19 0 $self->{log} = DJabberd::Log->get_logger($class);
20 0 ▶ $self->log->debug("New clusterid connection '$self->{id}' from " . ($self->peer_ip_string || "<undef>"));
Condition0%0/2
$self->peer_ip_string || '<undef>'
l!l
00
MC/DC0%0/1
$self->peer_ip_string || '<undef>'
$self->peer_ip_string
Truth table0%0/2
A
A= $self->peer_ip_string
Aresult
11
00
21 0 return $self;
22 }
23  
24 0 ▶sub set_vhost {
Subroutine set_vhost: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my ($self, $vhost) = @_;
26 0 ▶ return 0 unless $vhost->{s2s};
Branch: 1 branch
BranchTrueFalseTotal
unless $vhost->{"s2s"} 0 0 0
27 0 return $self->SUPER::set_vhost($vhost);
28 }
29  
30 0 ▶sub event_read {
Subroutine event_read: not called CC=10 SCAR=47.0
Pod documented
31 0 my $self = shift;
32 0 ▶ my $bref = $self->read(20_000)
Branch: 1 branch
BranchTrueFalseTotal
my $bref = $self->read(20000) or return $self->close 0 0 0
33 or return $self->close;
34  
35 0 $self->{buf} .= $$bref;
36 0 ▶ while ($self->{buf} =~ /^DJAB(....)/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"buf"} =~ /^DJAB(....)/s) 0 0 0
37 0 my $len = unpack("N", $1);
38 0 ▶ die "packet too big" if $len > 5 * 1024 * 1024; # arbitrary
Branch: 1 branch
BranchTrueFalseTotal
if $len > 5242880 0 0 0
39 0 ▶ return unless length($self->{buf}) >= $len + 8;
Branch: 1 branch
BranchTrueFalseTotal
unless length $self->{"buf"} >= $len + 8 0 0 0
40  
41 0 $self->{buf} =~ s/^DJAB....//s;
42 0 my $payload = substr($self->{buf}, 0, $len, '');
43 0 my $cmsg = eval { DJabberd::ClusterMessage->thaw(\$payload) };
44  
45 0 ▶ if (! $cmsg && $payload =~ /^vhost=(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $cmsg and $payload =~ /^vhost=(.+)/) 0 0 0
Condition0%0/3
not $cmsg and $payload =~ /^vhost=(.+)/
!ll&&!rl&&r
000
MC/DC0%0/2
not $cmsg and $payload =~ /^vhost=(.+)/
not $cmsg $payload =~ /^vhost=(.+)/
Truth table0%0/3
not(A) and B
A= not $cmsgB= $payload =~ /^vhost=(.+)/
ABresult
0X0
100
111
46 0 my $hostname = $1;
47 0 ▶ my $vhost = $self->server->lookup_vhost($hostname)
Branch: 1 branch
BranchTrueFalseTotal
my $vhost = $self->server->lookup_vhost($hostname) or $self->close 0 0 0
48 or $self->close;
49 0 $self->{vhost} = $vhost;
50 0 next;
51 }
52  
53 # need a vhost past this point
54 0 ▶ return $self->close unless $self->{vhost};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"vhost"} 0 0 0
55  
56 0 ▶ if ($cmsg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmsg) { } 0 0 0
57 0 $cmsg->process($self->{vhost});
58 } else {
59 0 print "Got payload text: [$payload]\n";
60 }
61 }
62 }
63  
64  
65 20 1;
« DJabberd/RosterItem.pm ↑ Summary DJabberd/DNS.pm »