| 1 | package DJabberd::Connection::ClientIn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 20 | ▶ | use fields ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # {=server-needs-client-wanted-roster-state} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 20 | 'requested_roster', # bool: if user has requested their roster, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 'got_initial_presence', # bool: if user has already sent their initial presence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 'is_available', # bool: is an "available resource" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 'directed_presence', # the jids we have sent directed presence too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 'pend_in_subscriptions', # undef or arrayref of presence type='subscribe' packets to be redelivered when we become available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub note_pend_in_subscription { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note_pend_in_subscription: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my ($self, $pres_packet) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | if ($self->is_available) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # can send it now if we're online | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $pres_packet->deliver($self->vhost); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # keep it on a list and deliver it later, when we get initial presence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | push @{$self->{pend_in_subscriptions} ||= []}, $pres_packet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"pend_in_subscriptions"} ||= []
MC/DC0%0/1
$self->{"pend_in_subscriptions"} ||= []
$self->{"pend_in_subscriptions"}
Truth table0%0/2
A
A= $self->{"pend_in_subscriptions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub directed_presence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
directed_presence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return keys %{$self->{directed_presence}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub add_directed_presence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_directed_presence: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my ($self, $to_jid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | ($self->{directed_presence} ||= {})->{$to_jid} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"directed_presence"} ||= {}
MC/DC0%0/1
$self->{"directed_presence"} ||= {}
$self->{"directed_presence"}
Truth table0%0/2
A
A= $self->{"directed_presence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub clear_directed_presence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_directed_presence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | delete $self->{directed_presence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub requested_roster { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
requested_roster: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return $self->{requested_roster}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub set_requested_roster { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_requested_roster: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->{requested_roster} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub set_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_available: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->{is_available} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub is_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_available: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return $self->{is_available}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # called when a presence broadcast is received. on first time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # returns tru. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub is_initial_presence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_initial_presence: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return 0 if $self->{got_initial_presence}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return $self->{got_initial_presence} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub on_initial_presence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_initial_presence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->send_resource_presences; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->send_presence_probes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->send_pending_sub_requests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->vhost->hook_chain_fast('OnInitialPresence', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | [ $self ], {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub send_resource_presences { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_resource_presences: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $vhost = $self->vhost; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $my_jid = $self->bound_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $vhost->check_presence($my_jid, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $map = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | foreach my $from_jid_str (keys %$map) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | next if $from_jid_str eq $my_jid->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $stanza = $map->{$from_jid_str}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $to_send = $stanza->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | #$to_send->set_from($from_jid_str); # set_from is happy to recieve a string instead of a JID object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $to_send->set_to($my_jid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $to_send->deliver($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub send_presence_probes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_presence_probes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $send_probes = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $roster = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # go through rosteritems who we're subscribed to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $from_jid = $self->bound_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | foreach my $it ($roster->to_items) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $probe = DJabberd::Presence->probe(to => $it->jid, from => $from_jid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # if we know the other side trusts us, let's avoid us internally not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # trusting ourselves and doing more work in Presence.pm than we need to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # reloading lots of roster items and such. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($it->subscription->sub_from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $probe->{dont_load_rosteritem} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $probe->procdeliver($self->vhost); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->vhost->get_roster($self->bound_jid, on_success => $send_probes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub send_pending_sub_requests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_pending_sub_requests: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return unless $self->{pend_in_subscriptions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | foreach my $pkt (@{ $self->{pend_in_subscriptions} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $pkt->deliver($self->vhost); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->{pend_in_subscriptions} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # send an unavailable presence broadcast if we've gone away | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ($self->is_available) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # set unavailable here, BEFORE we sent out unavailable stanzas, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # so if the stanzas 'bounce' or otherwise write back to our full JID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # they'll either drop/bounce instead of writing to what will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # soon be a dead full JID. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->set_available(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $unavail = DJabberd::Presence->unavailable_stanza; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $unavail->broadcast_from($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if (my $jid = $self->bound_jid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->vhost->unregister_jid($jid, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | DJabberd::Presence->forget_last_presence($jid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ($self->vhost && $self->vhost->are_hooks("ConnectionClosing")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->vhost and $self->vhost->are_hooks("ConnectionClosing")
MC/DC0%0/2
$self->vhost and $self->vhost->are_hooks("ConnectionClosing")
$self->vhost
$self->vhost->are_hooks("ConnectionClosing")
Truth table0%0/3
A and B
A= $self->vhostB= $self->vhost->are_hooks("ConnectionClosing")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $self->vhost->run_hook_chain(phase => "ConnectionClosing", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | args => [ $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | methods => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | fallback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->SUPER::close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return "jabber:client"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub on_stream_start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_stream_start: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my DJabberd::Connection $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $ss = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return $self->close unless $ss->xmlns eq $self->namespace; # FIXME: should be stream error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->{in_stream} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $to_host = $ss->to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | DJabberd::Log->get_logger->info($to_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $vhost = $self->server->lookup_vhost($to_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return $self->close_no_vhost($to_host) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | unless ($vhost); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->set_vhost($vhost); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # FIXME: bitch if we're starting a stream when we already have one, and we aren't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # expecting a new stream to start (like after SSL or SASL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my %opts = ( namespace => 'jabber:client' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ## If sasl successfully completed, we shouldn't propose deprecated iq-auth method anymore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($self->sasl && $self->sasl->authenticated_jid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->sasl and $self->sasl->authenticated_jid
MC/DC0%0/2
$self->sasl and $self->sasl->authenticated_jid
$self->sasl
$self->sasl->authenticated_jid
Truth table0%0/3
A and B
A= $self->saslB= $self->sasl->authenticated_jid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $opts{features} = qq{<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # The protocol for session establishment was determined to be unnecessary and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # therefore the content previously defined in Section 3 of RFC 3921 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # was removed. However, for the sake of backward-compatibility server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # implementations are encouraged to advertise support for the feature, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # even though session establishment is a "no-op". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $opts{features} .= qq{<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $opts{features} = qq{<auth xmlns='http://jabber.org/features/iq-auth'/>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->start_stream_back($ss, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub is_server { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_server: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 20 | my %element2class = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | "{jabber:client}iq" => 'DJabberd::IQ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | "{jabber:client}message" => 'DJabberd::Message', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | "{jabber:client}presence" => 'DJabberd::Presence', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | "{urn:ietf:params:xml:ns:xmpp-tls}starttls" => 'DJabberd::Stanza::StartTLS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub on_stanza_received { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_stanza_received: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ($self->xmllog->is_info) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->log_incoming_data($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $class = $element2class{$node->element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->log->debug("node is " . $node->as_xml); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | #warn $node->as_xml; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $self->vhost->hook_chain_fast("HandleStanza", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | [ $node, $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | handle => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($self, $handling_class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $class = $handling_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | ) unless $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | return $self->stream_error("unsupported-stanza-type") unless $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $DJabberd::Stats::counter{"ClientIn:$class"}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # same variable as $node, but down(specific)-classed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $stanza = $class->downbless($node, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $self->vhost->hook_chain_fast("filter_incoming_client", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | [ $stanza, $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | reject => sub { }, # just stops the chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | \&filter_incoming_client_builtin, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub is_authenticated_jid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_authenticated_jid: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my ($self, $jid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $bj = $self->bound_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | return 0 unless $jid && $bj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$jid and $bj
MC/DC0%0/2
$jid and $bj
$jid
$bj
Truth table0%0/3
A and B
A= $jidB= $bj
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | return $bj->as_bare_string eq $jid->as_bare_string if $jid->is_bare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return $bj->as_string eq $jid->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # This is not really a method, but gets invoked as a hookchain item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # so if you subclass this class, this will still get called | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub filter_incoming_client_builtin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_incoming_client_builtin: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($vhost, $cb, $stanza, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # <invalid-from/> -- the JID or hostname provided in a 'from' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # address does not match an authorized JID or validated domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # negotiated between servers via SASL or dialback, or between a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # client and a server via authentication and resource binding. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | #{=clientin-invalid-from} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $from = $stanza->from_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ($from && ! $self->is_authenticated_jid($from)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$from and not $self->is_authenticated_jid($from)
MC/DC0%0/2
$from and not $self->is_authenticated_jid($from)
$from
not $self->is_authenticated_jid($from)
Truth table0%0/3
A and not(B)
A= $fromB= not $self->is_authenticated_jid($from)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # make sure it is from them, if they care to tell us who they are. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # (otherwise further processing should assume it's them anyway) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # libgaim quirks bug. libgaim sends bogus from on IQ errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # see doc/quirksmode.txt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ($vhost->quirksmode && $stanza->isa("DJabberd::IQ") && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$vhost->quirksmode and $stanza->isa("DJabberd::IQ") and $stanza->type eq "error" and $stanza->from eq $stanza->to
$vhost->quirksmode and $stanza->isa("DJabberd::IQ") and $stanza->type eq "error"
$vhost->quirksmode and $stanza->isa("DJabberd::IQ")
MC/DC0%0/4
$vhost->quirksmode and $stanza->isa("DJabberd::IQ") and $stanza->type eq "error" and $stanza->from eq $stanza->to
$vhost->quirksmode
$stanza->isa("DJabberd::IQ")
$stanza->type eq "error"
$stanza->from eq $stanza->to
Truth table0%0/5
A and B and C and D
A= $vhost->quirksmodeB= $stanza->isa("DJabberd::IQ")C= $stanza->type eq "error"D= $stanza->from eq $stanza->to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $stanza->type eq "error" && $stanza->from eq $stanza->to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # fix up from address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $from = $self->bound_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $stanza->set_from($from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return $self->stream_error('invalid-from'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # if no from, we set our own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if (! $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $bj = $self->bound_jid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | $stanza->set_from($bj->as_string) if $bj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | $vhost->hook_chain_fast("switch_incoming_client", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | [ $stanza ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | process => sub { $stanza->process($self) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | deliver => sub { $stanza->deliver($self) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $stanza->on_recv_from_client($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||