DJabberd/Stanza/DialbackResult.pm

filter: Statementstmt 31.9% 15 / 47 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 30.7% 4 / 13 Podpod 0.0% 0 / 6 totaltotal 23.4% 19 / 81 CC 7 SCAR 27.0
CC
7
Cov
25%
process
42.0
__ANON__
6.0
on_recv_from_server
2.0
CRAP 14.8
« DJabberd/Queue.pm ↑ Summary DJabberd/VHost.pm »
1 package DJabberd::Stanza::DialbackResult;
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use base qw(DJabberd::Stanza);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 20 ▶use DJabberd::DNS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use DJabberd::Connection::DialbackVerify;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub on_recv_from_server {
Subroutine on_recv_from_server: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ($self, $conn) = @_;
10 0 $self->process($conn);
11 }
12  
13 0 ▶sub process {
Subroutine process: not called CC=6 SCAR=37.4
Pod undocumented
14 0 my ($self, $conn) = @_;
15  
16 0 my $recv_server = $self->recv_server;
17 0 my $orig_server = $self->orig_server;
18  
19 0 $conn->log->debug("Got a dialback result, orig: $orig_server, recv: $recv_server");
20  
21 0 my $vhost = $conn->vhost;
22 0 ▶ unless ($vhost) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vhost) 0 0 0
23 0 $vhost = $conn->server->lookup_vhost($recv_server);
24 0 ▶ if ($vhost) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vhost) 0 0 0
25 0 ▶ return unless $conn->set_vhost($vhost);
Branch: 1 branch
BranchTrueFalseTotal
unless $conn->set_vhost($vhost) 0 0 0
26 }
27 }
28  
29 0 ▶ if (!$vhost || !$vhost->handles_domain($recv_server) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vhost and $vhost->handles_domain($recv_server)) 0 0 0
Condition0%0/3
$vhost and $vhost->handles_domain($recv_server)
!ll&&!rl&&r
000
MC/DC0%0/2
$vhost and $vhost->handles_domain($recv_server)
$vhost $vhost->handles_domain($recv_server)
Truth table0%0/3
A and B
A= $vhostB= $vhost->handles_domain($recv_server)
ABresult
0X0
100
111
30 # If the value of the 'to' address does not match a hostname
31 # recognized by the Receiving Server, then the Receiving
32 # Server MUST generate a <host-unknown/> stream error
33 # condition and terminate both the XML stream and the
34 # underlying TCP connection.
35 0 $conn->stream_error("host-unknown");
36 0 return;
37 }
38  
39 my $final_cb = DJabberd::Callback->new({
40 0 ▶ pass => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 $conn->dialback_result_valid(orig_server => $orig_server,
42 recv_server => $recv_server);
43 },
44 0 ▶ fail => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 my ($self_cb, $reason) = @_;
46 0 $conn->dialback_result_invalid(reason => $reason,
47 orig_server => $orig_server,
48 recv_server => $recv_server);
49 },
50 0 });
51 # async DNS lookup
52 DJabberd::DNS->srv(service => "_xmpp-server._tcp",
53 domain => $orig_server,
54 0 ▶ callback => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
55 0 my @endpts = @_;
56 0 ▶ unless (@endpts) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@endpts) 0 0 0
57 0 $final_cb->fail("no resolved IP");
58 0 return;
59 }
60  
61 0 my $endpt = shift @endpts;
62 0 DJabberd::Connection::DialbackVerify->new($endpt, $conn, $self, $final_cb);
63 0 });
64 }
65  
66 # always acceptable
67 0 ▶sub acceptable_from_server { 1 }
Subroutine acceptable_from_server: not called CC=1 SCAR=6.9
Pod undocumented
68  
69 0 ▶sub dialback_to {
Subroutine dialback_to: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my $self = shift;
71 0 return $self->attr("{}to");
72 }
73 20 *recv_server = \&dialback_to;
74  
75 0 ▶sub dialback_from {
Subroutine dialback_from: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my $self = shift;
77 0 return $self->attr("{}from");
78 }
79 20 *orig_server = \&dialback_from;
80  
81 0 ▶sub result_text {
Subroutine result_text: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my $self = shift;
83 0 return $self->first_child;
84 }
85  
86 20 1;
« DJabberd/Queue.pm ↑ Summary DJabberd/VHost.pm »