| 1 | package AnyEvent::FTP::Client::Transfer::Passive; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 24 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 24 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 24 | ▶ | use AnyEvent::Socket qw( tcp_connect ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 24 | extends 'AnyEvent::FTP::Client::Transfer'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # ABSTRACT: Passive transfer class for asynchronous ftp client | ||||||||||||||||||||||||||||
| 12 | 24 | our $VERSION = '0.19'; # VERSION | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub BUILD | ||||||||||||||||||||||||||||
| 15 | { | ||||||||||||||||||||||||||||
| 16 | 41 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 41 | my $local = $self->convert_local($self->local); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | my $data_connection = sub { | ||||||||||||||||||||||||||||
| 21 | 41 | ▶ | my $res = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.4
| |||||||||||||||||||||||||||||
| 22 | 41 | ▶ | return if $res->is_preliminary; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 41 | my($ip, $port) = $res->get_address_and_port; | |||||||||||||||||||||||||||
| 24 | 41 | ▶ | if(defined $ip && defined $port) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ip and defined $port
MC/DC0%0/2
defined $ip and defined $port
defined $ip
defined $port
Truth table33%1/3
A and B
A= defined $ipB= defined $port
| |||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||
| 26 | tcp_connect $ip, $port, sub { | ||||||||||||||||||||||||||||
| 27 | 41 | ▶ | my($fh) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 28 | 41 | ▶ | unless($fh) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 0 | return "unable to connect to data port: $!"; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 41 | $self->xfer($fh,$local); | |||||||||||||||||||||||||||
| 34 | 41 | }; | |||||||||||||||||||||||||||
| 35 | 41 | return; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | else | ||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 0 | $res; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 41 | }; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 41 | ▶ | $self->push_command( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | [ 'PASV', undef, $data_connection ], | ||||||||||||||||||||||||||||
| 45 | ($self->restart > 0 ? ([ REST => $self->restart ]) : ()), | ||||||||||||||||||||||||||||
| 46 | $self->command, | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | $self->cv->cb(sub { | ||||||||||||||||||||||||||||
| 50 | 26 | ▶ | my $res = eval { shift->recv } // $@; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Condition33%1/3
eval {
do {
(shift())->recv
}
} // $@
MC/DC0%0/2
eval {
do {
(shift())->recv
}
} // $@
eval {
do {
(shift())->recv
}
}
$@
Truth table33%1/3
A // B
A= eval {
do {
(shift())->recv
}
}B= $@
| |||||||||||||||||||||||||||||
| 51 | 26 | $self->emit('close' => $res); | |||||||||||||||||||||||||||
| 52 | 41 | }); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | package AnyEvent::FTP::Client::Transfer::Passive::Fetch; | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 24 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 24 | extends 'AnyEvent::FTP::Client::Transfer::Passive'; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 24 | with 'AnyEvent::FTP::Client::Role::FetchTransfer'; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | package AnyEvent::FTP::Client::Transfer::Passive::Store; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 24 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 24 | extends 'AnyEvent::FTP::Client::Transfer::Passive'; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 24 | with 'AnyEvent::FTP::Client::Role::StoreTransfer'; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | package AnyEvent::FTP::Client::Transfer::Passive::List; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 24 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | 24 | extends 'AnyEvent::FTP::Client::Transfer::Passive'; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 24 | with 'AnyEvent::FTP::Client::Role::ListTransfer'; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 24 | 1; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||