| 1 | package DJabberd::Stanza::DialbackVerify; | ||||||||||
| 2 | # remote servers asking to verify results that we sent them, from when | ||||||||||
| 3 | # we were trying to initiate outbound connections. | ||||||||||
| 4 | |||||||||||
| 5 | 20 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 20 | ▶ | use base qw(DJabberd::Stanza); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 20 | ▶ | use DJabberd::Log; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 20 | ▶ | use DJabberd::DialbackParams; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 20 | our $logger = DJabberd::Log->get_logger(); | |||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub on_recv_from_server { | ||||||||
|
Subroutine
on_recv_from_server: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | 0 | my ($self, $conn) = @_; | |||||||||
| 15 | 0 | $self->process($conn); | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub process { | ||||||||
|
Subroutine
process: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 19 | 0 | my ($self, $conn) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 0 | $logger->debug("Procesing dialback verify for connection $conn->{id}"); | |||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | my $fail = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 24 | 0 | $logger->debug("DialbackVerify failed: $_[0]"); | |||||||||
| 25 | 0 | return 0; | |||||||||
| 26 | 0 | }; | |||||||||
| 27 | |||||||||||
| 28 | # stream to parameter is optional on dialback, so this may be the first time | ||||||||||
| 29 | # we get to bind this connection to a vhost. | ||||||||||
| 30 | 0 | my $vhost = $conn->vhost; | |||||||||
| 31 | 0 | my $to_host = $self->dialback_to; | |||||||||
| 32 | 0 | ▶ | unless ($vhost) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | ▶ | $vhost = $conn->server->lookup_vhost($to_host) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | or return $fail->("no vhost for this connection"); | ||||||||||
| 35 | 0 | ▶ | $conn->set_vhost($vhost) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | or return $fail->("s2s disabled for this vhost"); | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | my $db_params = DJabberd::DialbackParams->new( | |||||||||
| 40 | id => $self->verify_stream_id, | ||||||||||
| 41 | orig => $to_host, | ||||||||||
| 42 | recv => $self->dialback_from, | ||||||||||
| 43 | vhost => $vhost, | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | $db_params->verify_callback( | ||||||||||
| 47 | result_text => $self->result_text, | ||||||||||
| 48 | 0 | ▶ | on_success => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | 0 | $logger->debug("Dialback verify success for connection $conn->{id}"); | |||||||||
| 50 | 0 | $conn->dialback_verify_valid(recv_server => $self->recv_server, | |||||||||
| 51 | orig_server => $self->orig_server, | ||||||||||
| 52 | id => $self->verify_stream_id); | ||||||||||
| 53 | }, | ||||||||||
| 54 | 0 | ▶ | on_failure => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | 0 | $logger->warn("Dialback verify success for connection $conn->{id}"); | |||||||||
| 56 | 0 | $conn->dialback_verify_invalid(recv_server => $self->recv_server, | |||||||||
| 57 | orig_server => $self->orig_server); | ||||||||||
| 58 | 0 | }); | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | # always acceptable | ||||||||||
| 62 | 0 | ▶ | sub acceptable_from_server { 1 } | ||||||||
|
Subroutine
acceptable_from_server: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub verify_stream_id { | ||||||||
|
Subroutine
verify_stream_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 65 | 0 | my $self = shift; | |||||||||
| 66 | 0 | return $self->attr("{}id"); | |||||||||
| 67 | } | ||||||||||
| 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; | |||||||||