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