| 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>'
MC/DC0%0/1
$self->peer_ip_string || '<undef>'
$self->peer_ip_string
Truth table0%0/2
A
A= $self->peer_ip_string
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 33 | or return $self->close; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $self->{buf} .= $$bref; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | while ($self->{buf} =~ /^DJAB(....)/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | my $len = unpack("N", $1); | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | die "packet too big" if $len > 5 * 1024 * 1024; # arbitrary | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return unless length($self->{buf}) >= $len + 8; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
not $cmsg and $payload =~ /^vhost=(.+)/
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=(.+)/
| |||||||||||||||||||||||||||||
| 46 | 0 | my $hostname = $1; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $vhost = $self->server->lookup_vhost($hostname) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ($cmsg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | $cmsg->process($self->{vhost}); | |||||||||||||||||||||||||||
| 58 | } else { | ||||||||||||||||||||||||||||
| 59 | 0 | print "Got payload text: [$payload]\n"; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 20 | 1; | |||||||||||||||||||||||||||