| 1 | package DJabberd::Delivery::S2S; | ||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 20 | ▶ | use base 'DJabberd::Delivery'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 20 | ▶ | use DJabberd::Queue::ServerOut; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 20 | ▶ | use DJabberd::Log; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 20 | our $logger = DJabberd::Log->get_logger; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 0 | ▶ | sub run_after { ("DJabberd::Delivery::Local") } | ||||||||||||||||||
|
Subroutine
run_after: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 42 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 13 | 42 | my $class = shift; | |||||||||||||||||||
| 14 | 42 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||
| 15 | 42 | $self->{cache} = {}; # domain -> DJabberd::Queue::ServerOut | |||||||||||||||||||
| 16 | 42 | return $self; | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | sub deliver { | ||||||||||||||||||
|
Subroutine
deliver: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||
| 20 | 0 | my ($self, $vhost, $cb, $stanza) = @_; | |||||||||||||||||||
| 21 | 0 | ▶ | die unless $vhost == $self->{vhost}; # sanity check | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # don't do s2s if the vhost doesn't have it enabled | ||||||||||||||||||||
| 24 | 0 | ▶ | unless ($vhost->s2s) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | $cb->declined; | |||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | my $to = $stanza->to_jid | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | or return $cb->declined; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # don't initiate outgoing connections back to ourself | ||||||||||||||||||||
| 33 | 0 | my $domain = $to->domain; | |||||||||||||||||||
| 34 | 0 | ▶ | if ($vhost->handles_domain($domain)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 0 | return $cb->declined; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | $logger->debug("s2s delivery attempt for $to"); | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | # FIXME: let get_conn_for_domain return an error code or something | ||||||||||||||||||||
| 41 | # which we can then pass along smarter to the callback, so client gets | ||||||||||||||||||||
| 42 | # a good error? | ||||||||||||||||||||
| 43 | 0 | ▶ | my $out_queue = $self->get_queue_for_domain($domain) or | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | return $cb->declined; | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | $DJabberd::Stats::counter{deliver_s2s}++; | |||||||||||||||||||
| 47 | 0 | $out_queue->queue_stanza($stanza, $cb); | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub get_queue_for_domain { | ||||||||||||||||||
|
Subroutine
get_queue_for_domain: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 51 | 0 | my ($self, $domain) = @_; | |||||||||||||||||||
| 52 | # TODO: we need to clean this periodically, like when connections timeout or fail | ||||||||||||||||||||
| 53 | return $self->{cache}{$domain} ||= | ||||||||||||||||||||
| 54 | DJabberd::Queue::ServerOut->new(source => $self, | ||||||||||||||||||||
| 55 | domain => $domain, | ||||||||||||||||||||
| 56 | 0 | ▶ | vhost => $self->{vhost}); | ||||||||||||||||||
|
Condition0%0/3
$self->{"cache"}{$domain} ||= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
MC/DC0%0/2
$self->{"cache"}{$domain} ||= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
$self->{"cache"}{$domain}
"DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
Truth table0%0/3
A ||= B
A= $self->{"cache"}{$domain}B= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
| |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 20 | 1; | |||||||||||||||||||