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 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 17 ▶use base qw(DJabberd::Stanza);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 17 ▶use DJabberd::DNS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use DJabberd::Connection::DialbackVerify;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub on_recv_from_server {
9 0 ▶ my ($self, $conn) = @_;
Subroutine on_recv_from_server: not called CC=1 SCAR=6.9
Pod undocumented
10 0 $self->process($conn);
11 }
12  
13 sub process {
14 0 ▶ my ($self, $conn) = @_;
Subroutine process: not called CC=6 SCAR=37.4
Pod undocumented
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 pass => sub {
41 0 ▶ $conn->dialback_result_valid(orig_server => $orig_server,
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 recv_server => $recv_server);
43 },
44 fail => sub {
45 0 ▶ my ($self_cb, $reason) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 callback => sub {
55 0 ▶ my @endpts = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 sub dialback_to {
70 0 ▶ my $self = shift;
Subroutine dialback_to: not called CC=1 SCAR=6.9
Pod undocumented
71 0 return $self->attr("{}to");
72 }
73 17 *recv_server = \&dialback_to;
74  
75 sub dialback_from {
76 0 ▶ my $self = shift;
Subroutine dialback_from: not called CC=1 SCAR=6.9
Pod undocumented
77 0 return $self->attr("{}from");
78 }
79 17 *orig_server = \&dialback_from;
80  
81 sub result_text {
82 0 ▶ my $self = shift;
Subroutine result_text: not called CC=1 SCAR=6.9
Pod undocumented
83 0 return $self->first_child;
84 }
85  
86 17 1;
« DJabberd/Queue.pm ↑ Summary DJabberd/VHost.pm »