| 1 | # POE::Component::Client::FTP | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Author : Michael Ching | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Email : michaelc@wush.net | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Created : May 15, 2002 | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Description : An FTP client for POE | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | package POE::Component::Client::FTP; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | use POE qw(Wheel::SocketFactory Wheel::ReadWrite | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | Filter::Stream Filter::Line Driver::SysRW); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use vars qw(@ISA @EXPORT $VERSION $poe_kernel); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | $VERSION = '0.22'; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | @EXPORT = qw(FTP_PASSIVE FTP_ACTIVE FTP_MANUAL FTP_ASCII FTP_BINARY); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | eval 'sub DEBUG () { 0 }' unless defined &DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=15.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | eval 'sub DEBUG_COMMAND () { 0 }' unless defined &DEBUG_COMMAND; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | eval 'sub DEBUG_DATA () { 0 }' unless defined &DEBUG_DATA; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub EOL () { "\015\012" } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # connection modes | ||||||||||||||||||||||||||||||||||||||||||
| 37 | sub FTP_PASSIVE () { 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | sub FTP_ACTIVE () { 2 } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # transfer modes | ||||||||||||||||||||||||||||||||||||||||||
| 41 | sub FTP_MANUAL () { 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | sub FTP_ASCII () { 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | sub FTP_BINARY () { 2 } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # tells the dispatcher which states support which events | ||||||||||||||||||||||||||||||||||||||||||
| 46 | my $state_map = | ||||||||||||||||||||||||||||||||||||||||||
| 47 | { _init => { "_start" => \&do_init_start, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | "connect" => \&do_init_start, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | "cmd_connected" => \&handler_init_connected, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | "cmd_connect_error" => \&handler_init_error, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | "success" => \&handler_init_success, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | "timeout" => \&handler_init_error | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | stop => { "_start" => \&do_stop | ||||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | authtls => { "authtls" => \&do_send_authtls, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | "success" => \&handler_authtls_success, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | "failure" => \&handler_authtls_failure | ||||||||||||||||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | login => { "login" => \&do_login_send_username, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | "intermediate" => \&do_login_send_password, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | "success" => \&handler_login_success, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | "failure" => \&handler_login_failure | ||||||||||||||||||||||||||||||||||||||||||
| 67 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | pbsz_prot => { "pbsz" => \&do_send_pbsz, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | "prot" => \&do_send_prot, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | "success" => \&handler_pbsz_prot_success, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | "failure" => \&handler_pbsz_prot_failure | ||||||||||||||||||||||||||||||||||||||||||
| 73 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | global => { "cmd_input" => \&handler_cmd_input, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | "cmd_error" => \&handler_cmd_error | ||||||||||||||||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | ready => { "_start" => \&dequeue_event, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | rename => \&do_rename, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | put => \&do_put, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 14 | map ( { $_ => \&do_simple_command } | |||||||||||||||||||||||||||||||||||||||||
| 84 | qw{ cd cdup delete mdtm mkdir noop | ||||||||||||||||||||||||||||||||||||||||||
| 85 | pwd rmdir site size stat type quit quot } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | map ( { $_ => \&do_complex_command } | |||||||||||||||||||||||||||||||||||||||||
| 89 | qw{ dir ls get } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | map ( { $_ => \&do_set_attribute } | |||||||||||||||||||||||||||||||||||||||||
| 93 | qw{ trans_mode conn_mode blocksize timeout } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 95 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | put => { data_flush => \&handler_put_flushed, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | data_error => \&handler_put_data_error, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | put_data => \&do_put_data, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | put_close => \&do_put_close, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | data_connected => \&handler_complex_connected, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | data_connect_error => \&handler_complex_connect_error, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | preliminary => \&handler_complex_preliminary, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | success => \&handler_complex_success, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | failure => \&handler_complex_failure, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | rename => { "intermediate" => \&handler_rename_intermediate, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | "success" => \&handler_rename_success, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | "failure" => \&handler_rename_failure | ||||||||||||||||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | default_simple => { "success" => \&handler_simple_success, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | "failure" => \&handler_simple_failure | ||||||||||||||||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | default_complex => { data_connected => \&handler_complex_connected, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | data_connect_error => \&handler_complex_connect_error, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | data_flush => \&handler_complex_flushed, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | preliminary => \&handler_complex_preliminary, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | success => \&handler_complex_success, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | failure => \&handler_complex_failure, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | data_input => \&handler_complex_list_data, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | data_error => \&handler_complex_list_error | ||||||||||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # translation from posted signals to ftp commands | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my %command_map = ( CD => "CWD", | |||||||||||||||||||||||||||||||||||||||||
| 132 | MKDIR => "MKD", | ||||||||||||||||||||||||||||||||||||||||||
| 133 | RMDIR => "RMD", | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | LS => "LIST", | ||||||||||||||||||||||||||||||||||||||||||
| 136 | DIR => "NLST", | ||||||||||||||||||||||||||||||||||||||||||
| 137 | GET => "RETR", | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | PUT => "STOR", | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | DELETE => "DELE", | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | # create a new POE::Component::Client::FTP object | ||||||||||||||||||||||||||||||||||||||||||
| 145 | sub spawn { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $sender = $poe_kernel->get_active_session; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | croak "$class->spawn requires an event number of argument" if @_ & 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $alias = delete $params{Alias}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | croak "$class->spawn requires an alias to start" unless defined $alias; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $user = delete $params{Username}; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $pass = delete $params{Password}; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $local_addr = delete $params{LocalAddr}; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $local_addr = INADDR_ANY unless defined $local_addr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $local_port = delete $params{LocalPort}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $local_port = 0 unless defined $local_port; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $remote_addr = delete $params{RemoteAddr}; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | croak "$class->spawn requires a RemoteAddr parameter" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | unless defined $remote_addr; | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $remote_port = delete $params{RemotePort}; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $remote_port = 21 unless defined $remote_port; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $tlscmd = delete $params{TLS}; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $tlscmd = 0 unless defined $tlscmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $tlsdata = delete $params{TLSData}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $tlsdata = 0 unless defined $tlsdata; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $timeout = delete $params{Timeout}; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | $timeout = 120 unless defined $timeout; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $blocksize = delete $params{BlockSize}; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $blocksize = 10240 unless defined $blocksize; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $conn_mode = delete $params{ConnectionMode}; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $conn_mode = FTP_PASSIVE unless defined $conn_mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $trans_mode = delete $params{TransferMode}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $trans_mode = FTP_MANUAL unless defined $trans_mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $filters = delete $params{Filters}; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $filters->{dir} ||= new POE::Filter::Line( Literal => EOL ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$filters->{"dir"} ||= "POE::Filter::Line"->new("Literal", "\r\n")
MC/DC0%0/2
$filters->{"dir"} ||= "POE::Filter::Line"->new("Literal", "\r\n")
$filters->{"dir"}
"POE::Filter::Line"->new("Literal", "\r\n")
Truth table0%0/3
A ||= B
A= $filters->{"dir"}B= "POE::Filter::Line"->new("Literal", "\r\n")
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $filters->{ls} ||= new POE::Filter::Line( Literal => EOL ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$filters->{"ls"} ||= "POE::Filter::Line"->new("Literal", "\r\n")
MC/DC0%0/2
$filters->{"ls"} ||= "POE::Filter::Line"->new("Literal", "\r\n")
$filters->{"ls"}
"POE::Filter::Line"->new("Literal", "\r\n")
Truth table0%0/3
A ||= B
A= $filters->{"ls"}B= "POE::Filter::Line"->new("Literal", "\r\n")
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $filters->{get} ||= new POE::Filter::Stream(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$filters->{"get"} ||= "POE::Filter::Stream"->new
MC/DC0%0/2
$filters->{"get"} ||= "POE::Filter::Stream"->new
$filters->{"get"}
"POE::Filter::Stream"->new
Truth table0%0/3
A ||= B
A= $filters->{"get"}B= "POE::Filter::Stream"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $filters->{put} ||= new POE::Filter::Stream(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$filters->{"put"} ||= "POE::Filter::Stream"->new
MC/DC0%0/2
$filters->{"put"} ||= "POE::Filter::Stream"->new
$filters->{"put"}
"POE::Filter::Stream"->new
Truth table0%0/3
A ||= B
A= $filters->{"put"}B= "POE::Filter::Stream"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $events = delete $params{Events}; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $events = [] unless defined $events and ref( $events ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $events and ref $events eq "ARRAY"
MC/DC0%0/2
defined $events and ref $events eq "ARRAY"
defined $events
ref $events eq "ARRAY"
Truth table0%0/3
A and B
A= defined $eventsB= ref $events eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my %register; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | for my $opt ( @$events ) { | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( ref $opt eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | @register{keys %$opt} = values %$opt; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $register{$opt} = $opt; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # Make sure the user didn't make a typo on parameters | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | carp "Unknown parameters: ", join( ', ', sort keys %params ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | if keys %params; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( $tlscmd || $tlsdata ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tlscmd or $tlsdata
MC/DC0%0/2
$tlscmd or $tlsdata
$tlscmd
$tlsdata
Truth table0%0/3
A or B
A= $tlscmdB= $tlsdata
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | require POE::Component::SSLify; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | import POE::Component::SSLify qw( Client_SSLify ); | |||||||||||||||||||||||||||||||||||||||||
| 215 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | warn "TLS option specified, but there was a problem\n"; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $tlscmd = 0; $tlsdata = 0; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 224 | alias => $alias, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||
| 226 | pass => $pass, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | local_addr => $local_addr, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | local_port => $local_port, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | remote_addr => $remote_addr, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | remote_port => $remote_port, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | tlscmd => $tlscmd, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | tlsdata => $tlsdata, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | attr_trans_mode => $trans_mode, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | attr_conn_mode => $conn_mode, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | attr_timeout => $timeout, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | attr_blocksize => $blocksize, | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | cmd_sock_wheel => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | cmd_rw_wheel => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | data_sock_wheel => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | data_rw_wheel => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | data_sock_port => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | data_suicidal => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | filters => $filters, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | state => "_init", | ||||||||||||||||||||||||||||||||||||||||||
| 250 | queue => [ ], | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | stack => [ [ 'init' ] ], | ||||||||||||||||||||||||||||||||||||||||||
| 253 | event => [ ], | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | complex_stack => [ ], | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | events => { $sender => \%register } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->{session_id} = POE::Session->create ( | |||||||||||||||||||||||||||||||||||||||||
| 261 | inline_states => map_all($state_map, \&dispatch), | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | heap => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 264 | )->ID(); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # connect to address specified during spawn | ||||||||||||||||||||||||||||||||||||||||||
| 269 | sub do_init_start { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_init_start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $heap->{session_id} = $session->ID(); | |||||||||||||||||||||||||||||||||||||||||
| 272 | # set timeout for connection | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $kernel->delay( "timeout", $heap->{attr_timeout}, undef, undef, "Timeout ($heap->{attr_timeout} seconds)" ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | # connect to command port | ||||||||||||||||||||||||||||||||||||||||||
| 276 | $heap->{cmd_sock_wheel} = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||||||||||
| 277 | SocketDomain => AF_INET, | ||||||||||||||||||||||||||||||||||||||||||
| 278 | SocketType => SOCK_STREAM, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | SocketProtocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 280 | RemotePort => $heap->{remote_port}, | ||||||||||||||||||||||||||||||||||||||||||
| 281 | RemoteAddress => $heap->{remote_addr}, | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | SuccessEvent => 'cmd_connected', | |||||||||||||||||||||||||||||||||||||||||
| 283 | FailureEvent => 'cmd_connect_error' | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $kernel->alias_set( $heap->{alias} ); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # try to clean up | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # client responsibility to ensure things are all complete | ||||||||||||||||||||||||||||||||||||||||||
| 292 | sub do_stop { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $heap = $poe_kernel->get_active_session()->get_heap(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_stop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | warn "cleaning up" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | delete $heap->{cmd_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | delete $heap->{cmd_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $poe_kernel->alias_remove( $heap->{alias} ); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | # server responses on command connection | ||||||||||||||||||||||||||||||||||||||||||
| 307 | sub handler_cmd_input { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_cmd_input: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | warn "<<< $input\n" if DEBUG_COMMAND; | |||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $coderef; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $input =~ s/^(\d\d\d)(.?)//o; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($code, $more) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $input =~ s/^ // if defined $more && $more eq "-"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $more and $more eq "-"
MC/DC0%0/2
defined $more and $more eq "-"
defined $more
$more eq "-"
Truth table0%0/3
A and B
A= defined $moreB= $more eq "-"
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $heap->{ftp_message} .= "$input\n"; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return unless defined $code && defined $more && $more eq " "; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $code and defined $more and $more eq " "
defined $code and defined $more
MC/DC0%0/3
defined $code and defined $more and $more eq " "
defined $code
defined $more
$more eq " "
Truth table0%0/4
A and B and C
A= defined $codeB= defined $moreC= $more eq " "
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $heap->{ftp_message} =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $major = substr($code, 0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($major == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | # 1yz Positive Preliminary reply | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $coderef = $state_map->{ $heap->{state} }{preliminary}; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | elsif ($major == 2) { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | # 2yz Positive Completion reply | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $coderef = $state_map->{ $heap->{state} }{success}; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | $heap->{event} = pop( @{$heap->{stack}} ) || ['none', {}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
pop @{$$heap{'stack'};} || ['none', {}]
MC/DC0%0/1
pop @{$$heap{'stack'};} || ['none', {}]
pop @{$$heap{'stack'};}
Truth table0%0/2
A
A= pop @{$$heap{'stack'};}
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | elsif ($major == 3) { | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # 3yz Positive Intermediate reply | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $coderef = $state_map->{ $heap->{state} }{intermediate}; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $heap->{event} = pop( @{$heap->{stack}} ) || ['none', {}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
pop @{$$heap{'stack'};} || ['none', {}]
MC/DC0%0/1
pop @{$$heap{'stack'};} || ['none', {}]
pop @{$$heap{'stack'};}
Truth table0%0/2
A
A= pop @{$$heap{'stack'};}
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 345 | # 4yz Transient Negative Completion reply | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # 5yz Permanent Negative Completion reply | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $coderef = $state_map->{ $heap->{state} }{failure}; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $heap->{event} = pop( @{$heap->{stack}} ) || ['none', {}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
pop @{$$heap{'stack'};} || ['none', {}]
MC/DC0%0/1
pop @{$$heap{'stack'};} || ['none', {}]
pop @{$$heap{'stack'};}
Truth table0%0/2
A
A= pop @{$$heap{'stack'};}
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | &{ $coderef }(@_) if $coderef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | delete $heap->{ftp_message}; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | # command connection closed | ||||||||||||||||||||||||||||||||||||||||||
| 359 | sub handler_cmd_error { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_cmd_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | goto_state("stop"); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | ## state specific | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | ## rename state | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # initiate multipart rename command | ||||||||||||||||||||||||||||||||||||||||||
| 371 | # uses the complex_stack to remember what to do next | ||||||||||||||||||||||||||||||||||||||||||
| 372 | sub do_rename { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | my ($kernel, $heap, $event, $fr, $to) = @_[KERNEL, HEAP, STATE, ARG0, ARG1]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_rename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | goto_state("rename"); | |||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $heap->{complex_stack} = [ "RNTO", $to ]; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | command( [ "RNFR", $fr ] ); | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # successful RNFR | ||||||||||||||||||||||||||||||||||||||||||
| 383 | sub handler_rename_intermediate { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_rename_intermediate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | send_event( "rename_partial", | ||||||||||||||||||||||||||||||||||||||||||
| 390 | $status, $line, | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $heap->{event}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | command( $heap->{complex_stack} ); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | # successful RNTO | ||||||||||||||||||||||||||||||||||||||||||
| 398 | sub handler_rename_success { | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_rename_success: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | send_event( "rename", | ||||||||||||||||||||||||||||||||||||||||||
| 405 | $status, $line, | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $heap->{event}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | delete $heap->{complex_stack}; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | # failed RNFR or RNTO | ||||||||||||||||||||||||||||||||||||||||||
| 414 | sub handler_rename_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_rename_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | send_event( "rename_error", | ||||||||||||||||||||||||||||||||||||||||||
| 421 | $status, $line, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $heap->{event}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | delete $heap->{complex_stack}; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | # initiate a STOR command | ||||||||||||||||||||||||||||||||||||||||||
| 430 | sub do_put { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my ($kernel, $heap, $event) = @_[KERNEL, HEAP, STATE]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_put: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | goto_state("put"); | |||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $heap->{complex_stack} = { command => [$event, @_[ARG0..$#_]], | |||||||||||||||||||||||||||||||||||||||||
| 436 | sendq => [], | ||||||||||||||||||||||||||||||||||||||||||
| 437 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | establish_data_conn(); | |||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | # socket flushed, see if socket can be closed | ||||||||||||||||||||||||||||||||||||||||||
| 444 | sub handler_put_flushed { | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | my ($kernel, $heap, $session) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_put_flushed: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | warn "data flushed " . $heap->{complex_stack}->{last_length} if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | # if no packet was pending, this was simply to get things going or to | ||||||||||||||||||||||||||||||||||||||||||
| 450 | # check for suicide and thus will confuse the user if sent | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ($heap->{complex_stack}->{pending}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $heap->{complex_stack}->{pending} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | send_event( "put_flushed", | ||||||||||||||||||||||||||||||||||||||||||
| 455 | $heap->{complex_stack}->{last_length}, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | $heap->{complex_stack}->{command}->[1] ) | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if $heap->{complex_stack}->{last_length}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | warn "Q||: " . scalar @{$heap->{complex_stack}->{sendq}} if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | # we use an internal sendq and send lines as each line is sent | ||||||||||||||||||||||||||||||||||||||||||
| 463 | # this way we can give the user feedback as to the status of the upload | ||||||||||||||||||||||||||||||||||||||||||
| 464 | # so, whenever data is flushed send the next packet | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ( defined(my $line = shift @{$heap->{complex_stack}->{sendq}}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | warn "sending queued packet: " . length ($line) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $heap->{complex_stack}->{pending} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $heap->{data_rw_wheel}->put($line); | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $heap->{complex_stack}->{last_length} = length $line; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | elsif ($heap->{data_suicidal}) { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | warn "killing suicidal socket" . $heap->{data_rw_wheel}->get_driver_out_octets() if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $heap->{data_suicidal} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | send_event("put_closed", | ||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $heap->{complex_stack}->{command}->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | # remote end closed data connection | ||||||||||||||||||||||||||||||||||||||||||
| 487 | # in put this in an error, not a normal condition | ||||||||||||||||||||||||||||||||||||||||||
| 488 | sub handler_put_data_error { | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | my ($kernel, $heap, $error) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_put_data_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | send_event( "put_error", $error, | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | # client sending data for us to print to the STOR | ||||||||||||||||||||||||||||||||||||||||||
| 501 | sub do_put_data { | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_put_data: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | warn "put: " . length($input) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | # add to send queue | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $kernel->call('cmd_connected', @{$heap->{cmd_sock_wheel}}[0]); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | push @{ $heap->{complex_stack}->{sendq} }, $input; | |||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | # send the first flushed event if this was the first item | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | unless ( @{ $heap->{complex_stack}->{sendq} } > 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$heap->{"complex_stack"}{"sendq"};} > 1 or $heap->{"complex_stack"}{"pending"}
MC/DC0%0/2
@{$heap->{"complex_stack"}{"sendq"};} > 1 or $heap->{"complex_stack"}{"pending"}
@{$heap->{"complex_stack"}{"sendq"};} > 1
$heap->{"complex_stack"}{"pending"}
Truth table0%0/3
A or B
A= @{$heap->{"complex_stack"}{"sendq"};} > 1B= $heap->{"complex_stack"}{"pending"}
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | or $heap->{complex_stack}->{pending} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $kernel->yield('data_flush'); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # client request to end STOR command | ||||||||||||||||||||||||||||||||||||||||||
| 519 | sub do_put_close { | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_put_close: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | warn "setting suicidal on" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $heap->{data_suicidal} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | # if close is called when sendq is empty, we'll need to fake a flush | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | unless ( @{ $heap->{complex_stack}->{sendq} } > 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$heap->{"complex_stack"}{"sendq"};} > 0 or $heap->{"complex_stack"}{"pending"}
MC/DC0%0/2
@{$heap->{"complex_stack"}{"sendq"};} > 0 or $heap->{"complex_stack"}{"pending"}
@{$heap->{"complex_stack"}{"sendq"};} > 0
$heap->{"complex_stack"}{"pending"}
Truth table0%0/3
A or B
A= @{$heap->{"complex_stack"}{"sendq"};} > 0B= $heap->{"complex_stack"}{"pending"}
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | or $heap->{complex_stack}->{pending} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | warn "empty sendq, manually flushing" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $kernel->yield('data_flush'); | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | ## login state | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | # connection established, create a rw wheel | ||||||||||||||||||||||||||||||||||||||||||
| 537 | sub handler_init_connected { | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_init_connected: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | # clear the timeout | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $kernel->delay("timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $heap->{cmd_rw_wheel} = POE::Wheel::ReadWrite->new( | |||||||||||||||||||||||||||||||||||||||||
| 544 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 545 | Filter => POE::Filter::Line->new( Literal => EOL ), | ||||||||||||||||||||||||||||||||||||||||||
| 546 | Driver => POE::Driver::SysRW->new(), | ||||||||||||||||||||||||||||||||||||||||||
| 547 | InputEvent => 'cmd_input', | ||||||||||||||||||||||||||||||||||||||||||
| 548 | ErrorEvent => 'cmd_error' | ||||||||||||||||||||||||||||||||||||||||||
| 549 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | # connect to server failed, clean up | ||||||||||||||||||||||||||||||||||||||||||
| 554 | sub handler_init_error { | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | my ($kernel, $heap, $errnum, $errstr) = @_[KERNEL, HEAP, ARG1, ARG2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_init_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | # clear the timeout | ||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $kernel->delay("timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | delete $heap->{cmd_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | send_event( "connect_error", $errnum, $errstr ); | |||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | # wheel established, log in if we can | ||||||||||||||||||||||||||||||||||||||||||
| 566 | sub handler_init_success { | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_init_success: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | send_event( "connected", | |||||||||||||||||||||||||||||||||||||||||
| 573 | $status, $line ); | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ($heap->{tlscmd}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | goto_state("authtls"); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $kernel->yield("authtls"); | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | goto_state("login"); | |||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if ( defined $heap->{user} and defined $heap->{pass} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $heap->{"user"} and defined $heap->{"pass"}
MC/DC0%0/2
defined $heap->{"user"} and defined $heap->{"pass"}
defined $heap->{"user"}
defined $heap->{"pass"}
Truth table0%0/3
A and B
A= defined $heap->{"user"}B= defined $heap->{"pass"}
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $kernel->yield("login"); | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | # start the tls negotiation on the control connection by sending "AUTH TLS" | ||||||||||||||||||||||||||||||||||||||||||
| 591 | sub do_send_authtls { | ||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_send_authtls: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | command( [ 'AUTH', 'TLS'] ); | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | sub handler_authtls_success { | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_authtls_success: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $socket = $heap->{cmd_rw_wheel}->get_input_handle(); | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | delete $heap->{cmd_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | eval { $socket = Client_SSLify( $socket, 'tlsv1' )}; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | die "Unable to SSLify control connection: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | # set up the rw wheel again | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $heap->{cmd_rw_wheel} = POE::Wheel::ReadWrite->new( | |||||||||||||||||||||||||||||||||||||||||
| 611 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 612 | Filter => POE::Filter::Line->new( Literal => EOL ), | ||||||||||||||||||||||||||||||||||||||||||
| 613 | Driver => POE::Driver::SysRW->new(), | ||||||||||||||||||||||||||||||||||||||||||
| 614 | InputEvent => 'cmd_input', | ||||||||||||||||||||||||||||||||||||||||||
| 615 | ErrorEvent => 'cmd_error' | ||||||||||||||||||||||||||||||||||||||||||
| 616 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | goto_state("login"); | |||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | $kernel->yield("login"); | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | sub handler_authtls_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_authtls_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | send_event( "login_error", | |||||||||||||||||||||||||||||||||||||||||
| 630 | $status, $line ); | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | # login using parameters specified during spawn or passed in now | ||||||||||||||||||||||||||||||||||||||||||
| 635 | sub do_login_send_username { | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | my ($kernel, $heap, $user, $pass) = @_[KERNEL, HEAP, ARG0 .. ARG1]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_login_send_username: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | $heap->{user} = $user unless defined $heap->{user}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | croak "No username defined in login" unless defined $heap->{user}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | $heap->{pass} = $pass unless defined $heap->{pass}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | croak "No password defined in login" unless defined $heap->{pass}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | command( [ 'USER', $heap->{user} ] ); | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | delete $heap->{user}; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | # username accepted | ||||||||||||||||||||||||||||||||||||||||||
| 649 | sub do_login_send_password { | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_login_send_password: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | command( [ 'PASS', $heap->{pass} ] ); | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | delete $heap->{pass}; | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | sub handler_login_success { | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_login_success: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if ($heap->{tlsdata}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | goto_state("pbsz_prot"); | |||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $kernel->yield('pbsz'); | |||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 667 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | send_event( "authenticated", | |||||||||||||||||||||||||||||||||||||||||
| 669 | $status, $line ); | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | sub handler_login_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_login_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | send_event( "login_error", | |||||||||||||||||||||||||||||||||||||||||
| 683 | $status, $line ); | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | # PBSZ 0 and PROT P are needed to encrypt the data connection (specified with TLSData) | ||||||||||||||||||||||||||||||||||||||||||
| 689 | # this is done _before_ 'authenticated' is sent to the user session (even though the u/p is already accepted) | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | sub do_send_pbsz {# | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_send_pbsz: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | command( [ 'PBSZ', '0' ] ); | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | sub do_send_prot {# | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_send_prot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | command( [ 'PROT', 'P' ] ); | |||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | sub handler_pbsz_prot_success { | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_pbsz_prot_success: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | if ($heap->{event}->[0] eq "PBSZ") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $kernel->yield("prot"); | |||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | send_event( "authenticated", $status, $line ); | |||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | sub handler_pbsz_prot_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_pbsz_prot_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | send_event( "login_error", | |||||||||||||||||||||||||||||||||||||||||
| 727 | $status, $line ); | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | ## default_simple state | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | # simple commands simply involve a command and one or more responses | ||||||||||||||||||||||||||||||||||||||||||
| 734 | sub do_simple_command { | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | my ($kernel, $heap, $event) = @_[KERNEL, HEAP, STATE]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_simple_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | goto_state("default_simple"); | |||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | command( [ $event, @_[ARG0..$#_] ] ); | |||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | # end of response section will be marked by "\d{3} " whereas multipart | ||||||||||||||||||||||||||||||||||||||||||
| 744 | # messages will be "\d{3}-" | ||||||||||||||||||||||||||||||||||||||||||
| 745 | sub handler_simple_success { | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_simple_success: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | send_event( lc $heap->{event}->[0], | ||||||||||||||||||||||||||||||||||||||||||
| 751 | $status, $heap->{ftp_message}, | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $heap->{event}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | # server response for failure | ||||||||||||||||||||||||||||||||||||||||||
| 759 | sub handler_simple_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_simple_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | send_event( lc $heap->{event}->[0] . "_error", | ||||||||||||||||||||||||||||||||||||||||||
| 766 | $status, $line, | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $heap->{event}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | ## default_complex state | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | # complex commands are those which require a data connection | ||||||||||||||||||||||||||||||||||||||||||
| 776 | sub do_complex_command { | ||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | my ($kernel, $heap, $event) = @_[KERNEL, HEAP, STATE]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_complex_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | goto_state("default_complex"); | |||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $heap->{complex_stack} = { command => [ $event, @_[ARG0..$#_] ] }; | |||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | establish_data_conn(); | |||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | # use the server response only for data connection establishment | ||||||||||||||||||||||||||||||||||||||||||
| 788 | # we will know when the command is actually done when the server | ||||||||||||||||||||||||||||||||||||||||||
| 789 | # terminates the data connection | ||||||||||||||||||||||||||||||||||||||||||
| 790 | sub handler_complex_success { | ||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_success: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | if ($heap->{event}->[0] eq "PASV") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | my (@ip, @port); | |||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | (@ip[0..3], @port[0..1]) = $input =~ /(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/; | |||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my $ip = join '.', @ip; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | my $port = $port[0]*256 + $port[1]; | |||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $heap->{data_sock_wheel} = POE::Wheel::SocketFactory->new( | |||||||||||||||||||||||||||||||||||||||||
| 800 | SocketDomain => AF_INET, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | SocketType => SOCK_STREAM, | ||||||||||||||||||||||||||||||||||||||||||
| 802 | SocketProtocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 803 | RemotePort => $port, | ||||||||||||||||||||||||||||||||||||||||||
| 804 | RemoteAddress => $ip, | ||||||||||||||||||||||||||||||||||||||||||
| 805 | SuccessEvent => 'data_connected', | ||||||||||||||||||||||||||||||||||||||||||
| 806 | FailureEvent => 'data_connect_error' | ||||||||||||||||||||||||||||||||||||||||||
| 807 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||
| 809 | elsif ($heap->{event}->[0] =~ /^PORT/) { | ||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | command($heap->{complex_stack}->{command}); | |||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||
| 812 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 813 | send_event( $heap->{complex_stack}->{command}->[0] . "_done", | ||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | # server response for failure | ||||||||||||||||||||||||||||||||||||||||||
| 821 | sub handler_complex_failure { | ||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_failure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $status = substr($input, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my $line = substr($input, 4); | |||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | send_event( $heap->{complex_stack}->{command}->[0] . "_error", | ||||||||||||||||||||||||||||||||||||||||||
| 828 | $status, $line, | ||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | # connection announced by server | ||||||||||||||||||||||||||||||||||||||||||
| 839 | sub handler_complex_preliminary { | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_preliminary: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | # this message is pretty worthless since _connected is all that matters | ||||||||||||||||||||||||||||||||||||||||||
| 843 | send_event( $heap->{complex_stack}->{command}->[0] . "_server", | ||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | # sslify the data connection | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $socket = $heap->{data_rw_wheel}->get_input_handle(); | |||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | if ( $heap->{tlsdata} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | eval { $socket = Client_SSLify( $socket, 'tlsv1' )}; | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | die "Unable to SSLify data connection: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | # set up the rw wheel again | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | $heap->{data_rw_wheel} = POE::Wheel::ReadWrite->new( | ||||||||||||||||||||||||||||||||||||||||||
| 857 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 858 | Filter => $heap->{filters}->{ $heap->{complex_stack}->{command}->[0] }, | ||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | Driver => POE::Driver::SysRW->new( BlockSize => $heap->{attr_blocksize} ), | |||||||||||||||||||||||||||||||||||||||||
| 860 | InputEvent => 'data_input', | ||||||||||||||||||||||||||||||||||||||||||
| 861 | ErrorEvent => 'data_error', | ||||||||||||||||||||||||||||||||||||||||||
| 862 | FlushedEvent => 'data_flush' | ||||||||||||||||||||||||||||||||||||||||||
| 863 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | # data connection established | ||||||||||||||||||||||||||||||||||||||||||
| 869 | sub handler_complex_connected { | ||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_connected: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | $heap->{data_rw_wheel} = POE::Wheel::ReadWrite->new( | ||||||||||||||||||||||||||||||||||||||||||
| 873 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 874 | Filter => $heap->{filters}->{ $heap->{complex_stack}->{command}->[0] }, | ||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | Driver => POE::Driver::SysRW->new( BlockSize => $heap->{attr_blocksize} ), | |||||||||||||||||||||||||||||||||||||||||
| 876 | InputEvent => 'data_input', | ||||||||||||||||||||||||||||||||||||||||||
| 877 | ErrorEvent => 'data_error', | ||||||||||||||||||||||||||||||||||||||||||
| 878 | FlushedEvent => 'data_flush' | ||||||||||||||||||||||||||||||||||||||||||
| 879 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | send_event( $heap->{complex_stack}->{command}->[0] . "_connected", | ||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | if ($heap->{attr_conn_mode} == FTP_PASSIVE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | command($heap->{complex_stack}->{command}); | |||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | # data connection could not be established | ||||||||||||||||||||||||||||||||||||||||||
| 891 | sub handler_complex_connect_error { | ||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | my ($kernel, $heap, $error) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_connect_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | send_event( $heap->{complex_stack}->{command}->[0] . "_error", $error, | ||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | goto_state("ready"); | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | # getting actual data, so send it to the client | ||||||||||||||||||||||||||||||||||||||||||
| 903 | sub handler_complex_list_data { | ||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_list_data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | warn "<< $input\n" if DEBUG_DATA; | |||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | send_event( $heap->{complex_stack}->{command}->[0] . "_data", $input, | ||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $heap->{complex_stack}->{command}->[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | # connection was closed, clean up, and wait for a response from the server | ||||||||||||||||||||||||||||||||||||||||||
| 913 | sub handler_complex_list_error { | ||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_complex_list_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | warn "error: complex_list: $input" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | delete $heap->{data_sock_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | delete $heap->{data_rw_wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | ## utility functions | ||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | # maps all signal names to dispatcher | ||||||||||||||||||||||||||||||||||||||||||
| 925 | sub map_all { | ||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | my $map = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_all: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | my $coderef = shift; | |||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | my %signals; | |||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | foreach my $state (keys %$map) { | |||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | @signals{ keys %{ $map->{$state} } } = (); | |||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | map { $_ = $coderef } values %signals; | |||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | return \%signals; | |||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | # enqueues and incoming signal | ||||||||||||||||||||||||||||||||||||||||||
| 939 | sub enqueue_event { | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | my ($kernel, $heap, $state) = @_[KERNEL, HEAP, STATE]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueue_event: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | warn "|| enqueue $state" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | push @{$heap->{queue}}, [ @_ ]; | |||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | # dequeue and dispatch next event | ||||||||||||||||||||||||||||||||||||||||||
| 948 | # in a more general model, this could dequeue the first event | ||||||||||||||||||||||||||||||||||||||||||
| 949 | # that active session knows how to deal with | ||||||||||||||||||||||||||||||||||||||||||
| 950 | sub dequeue_event { | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | my $heap = $poe_kernel->get_active_session()->get_heap(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_event: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | return unless @{$heap->{queue}}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $state = $heap->{queue}->[0]->[STATE]; | |||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | warn "|| dequeue $state" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | dispatch( @{ shift @{$heap->{queue}} } ); | |||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | # if active session knows how to handle this event, dispatch it to them | ||||||||||||||||||||||||||||||||||||||||||
| 961 | # if not, enqueue the event | ||||||||||||||||||||||||||||||||||||||||||
| 962 | sub dispatch { | ||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | my ($kernel, $heap, $state) = @_[KERNEL, HEAP, STATE]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | my $coderef = ( $state_map->{ $heap->{state} }->{$state} || | ||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | $state_map->{global}->{$state} || | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$$state_map{$heap->{'state'}}{$state} || $state_map->{'global'}{$state} || \&POE::Component::Client::FTP::enqueue_event
$$state_map{$heap->{"state"}}{$state} or $state_map->{"global"}{$state}
MC/DC0%0/2
$$state_map{$heap->{'state'}}{$state} || $state_map->{'global'}{$state} || \&POE::Component::Client::FTP::enqueue_event
$$state_map{$heap->{"state"}}{$state}
$state_map->{"global"}{$state}
Truth table0%0/3
A or B
A= $$state_map{$heap->{"state"}}{$state}B= $state_map->{"global"}{$state}
| |||||||||||||||||||||||||||||||||||||||||||
| 967 | \&enqueue_event ); | ||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | warn "-> $heap->{state}\::$state" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | &{ $coderef }(@_); | |||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | # Send events to interested sessions | ||||||||||||||||||||||||||||||||||||||||||
| 976 | sub send_event { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | my ( $event, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_event: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | warn "<*> $event" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my $heap = $poe_kernel->get_active_session()->get_heap(); | |||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | for my $session ( keys %{$heap->{events}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $heap->{"events"}{$session}{$event} or exists $heap->{"events"}{$session}{"all"}
MC/DC0%0/2
exists $heap->{"events"}{$session}{$event} or exists $heap->{"events"}{$session}{"all"}
exists $heap->{"events"}{$session}{$event}
exists $heap->{"events"}{$session}{"all"}
Truth table0%0/3
A or B
A= exists $heap->{"events"}{$session}{$event}B= exists $heap->{"events"}{$session}{"all"}
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | exists $heap->{events}{$session}{$event} or | ||||||||||||||||||||||||||||||||||||||||||
| 985 | exists $heap->{events}{$session}{all} | ||||||||||||||||||||||||||||||||||||||||||
| 986 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 987 | { | ||||||||||||||||||||||||||||||||||||||||||
| 988 | $poe_kernel->post( | ||||||||||||||||||||||||||||||||||||||||||
| 989 | $session, | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | ( $heap->{events}{$session}{$event} || $event ), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$heap->{'events'}{$session}{$event} || $event
MC/DC0%0/2
$heap->{'events'}{$session}{$event} || $event
$heap->{'events'}{$session}{$event}
$event
Truth table0%0/3
A || B
A= $heap->{'events'}{$session}{$event}B= $event
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | @args | ||||||||||||||||||||||||||||||||||||||||||
| 992 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | # run a command and add its call information to the call stack | ||||||||||||||||||||||||||||||||||||||||||
| 999 | sub command { | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | my ($cmd_args, $state) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | $cmd_args = ref($cmd_args) eq "ARRAY" ? [ @$cmd_args ] : $cmd_args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my $heap = $poe_kernel->get_active_session()->get_heap(); | |||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | return unless defined $heap->{cmd_rw_wheel}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | $cmd_args = [$cmd_args] unless ref( $cmd_args ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $command = uc shift( @$cmd_args ); | |||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | $state = {} unless defined $state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | unshift @{$heap->{stack}}, [ $command, @$cmd_args ]; | |||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | $command = shift( @$cmd_args ) if $command eq "QUOT"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | $command = $command_map{$command} || $command; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$command_map{$command} || $command
MC/DC0%0/2
$command_map{$command} || $command
$command_map{$command}
$command
Truth table0%0/3
A || B
A= $command_map{$command}B= $command
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | my $cmdstr = join( ' ', $command, @$cmd_args ? @$cmd_args : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | warn ">>> $cmdstr\n" if DEBUG_COMMAND; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | $heap->{cmd_rw_wheel}->put($cmdstr); | |||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | # change active state | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | sub goto_state { | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | my $state = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
goto_state: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | warn "--> $state" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my $heap = $poe_kernel->get_active_session()->get_heap(); | |||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | $heap->{state} = $state; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | my $coderef = $state_map->{$state}->{_start}; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | &{$coderef} if $coderef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | # initiate start of data connection | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | sub establish_data_conn { | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | my $heap = $poe_kernel->get_active_session()->get_heap(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
establish_data_conn: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | if ($heap->{attr_conn_mode} == FTP_PASSIVE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | command("PASV"); | |||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | $heap->{data_sock_wheel} = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | SocketDomain => AF_INET, | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | SocketType => SOCK_STREAM, | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | SocketProtocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | BindAddress => $heap->{local_addr}, | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | BindPort => $heap->{local_port}, | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | SuccessEvent => 'data_connected', | |||||||||||||||||||||||||||||||||||||||||
| 1051 | FailureEvent => 'data_connect_error' | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $socket = $heap->{data_sock_wheel}->getsockname(); | |||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | my ($port, $addr) = sockaddr_in($socket); | |||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | $addr = inet_ntoa($addr); | |||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | $addr = "127.0.0.1" if $addr eq "0.0.0.0"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | my @addr = split /\./, $addr; | |||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | my @port = (int($port / 256), $port % 256); | |||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | command("PORT " . join ",", @addr, @port); | |||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||
| 1067 | __END__ | ||||||||||||||||||||||||||||||||||||||||||