FTPTLS.pm

filter: Statementstmt 13.6% 60 / 439 Branchbran 0.0% 0 / 250 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 23.2% 13 / 56 Podpod 0.0% 0 / 45 totaltotal 8.8% 73 / 822 CC 133 SCAR 62.2
CC
133
Cov
8%
getslurp
1406.0
putblat
870.0
nlst
380.0
CRAP 501.0
↑ Summary example.pl »
1 package Net::FTPTLS;
2  
3  
4 1 ▶use 5.006000;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 #use IO::Compress::Deflate qw(deflate $DeflateError);
9 #use IO::Uncompress::Inflate qw(inflate $InflateError);
10 1 ▶use Compress::Raw::Zlib;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Errno;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET SOL_SOCKET IPPROTO_IP SO_ERROR IPPROTO_IP IP_TOS IP_TTL
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 inet_aton sockaddr_in SO_SNDTIMEO SO_RCVTIMEO SO_KEEPALIVE);
14  
15  
16 1 require Exporter;
17 1 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 our @ISA = qw(Exporter);
20 # Items to export into callers namespace by default. Note: do not export
21 # names by default without a very good reason. Use EXPORT_OK instead.
22 # Do not simply export all your public functions/methods/constants.
23  
24 # This allows declaration use Net::FTPTLS ':all';
25 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
26 # will save memory.
27 1 our %EXPORT_TAGS = ( 'all' => [ qw(
28  
29 ) ] );
30  
31 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
32  
33 1 our @EXPORT = qw(
34  
35 );
36  
37 1 our $VERSION = '0.84';
38 # Preloaded methods go here.
39 # Autoload methods go after =cut, and are processed by the autosplit program.
40 1 ▶use constant BUFSIZE => 4096;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 BEGIN {
42 1 ▶ use Net::SSLeay::Handle qw/shutdown/;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 # You only need this if your FTP server requires client certs:
44 #Net::SSLeay::Handle::_set_cert("/home/eyck/my.pem");
45 #Net::SSLeay::Handle::_set_key("/home/eyck/my.pem");
46 # but if you want this, you need to patch your Net::SSLeay,
47 };
48  
49 1 ▶sub new($$) {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
50 1 my $class=shift;
51 1 my $self={};
52 1 bless $self,$class;
53 # $self->{'DBHandle'}=$dbh;
54 1 $self->{"CreationTime"}=time;
55 1 $self->{"Connected"}=0;
56 1 $self->{"EncryptData"}=1;
57 1 $self->{"Encrypt"}=1;
58 1 $self->{"Debug"}=0;
59 1 $self->{"ErrMSG"}=undef;
60 #$self->{"ForcePASSVIP"}=undef;
61 1 $self->{"GetUpdateCallback"} = undef;
62 1 $self->{"GetDoneCallback"} = undef;
63 1 $self->{"PutUpdateCallback"} = undef;
64 1 $self->{"PutDoneCallback"} = undef;
65 1 $self->{"CompressionLevel"}=1;
66 1 $self->{"CompressionWindowBits"}=8;
67 1 $self->{"CompressionBufsize"}=8192;
68 1 $self->{"CompressionStrategy"}=4;
69 #define Z_FILTERED 1
70 #define Z_HUFFMAN_ONLY 2
71 #define Z_RLE 3
72 #define Z_FIXED 4
73 #define Z_DEFAULT_STRATEGY 0
74 1 return $self;
75 };
76  
77 0 ▶sub user($$) {
Subroutine user: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my ($self,$user)=@_;
79 0 $self->command("USER $user");
80 }
81 0 ▶sub pass($$) {
Subroutine pass: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my ($self,$pass)=@_;
83 0 $self->command("PASS $pass");
84 }
85 0 ▶sub login($$$) {
Subroutine login: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my ($self,$user,$pass)=@_;
87 0 $self->command("USER $user");
88 0 $self->command("PASS $pass");
89 }
90  
91 0 ▶sub cwd ($$) {
Subroutine cwd: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my ($self,$data)=@_;
93 0 $self->command("CWD $data");
94 }
95 0 ▶sub mkdir ($$) {
Subroutine mkdir: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my ($self,$data)=@_;
97 0 $self->command("MKD $data");
98 }
99 0 ▶sub rmdir ($$) {
Subroutine rmdir: not called CC=1 SCAR=6.9
Pod undocumented
100 0 my ($self,$data)=@_;
101 0 $self->command("RMD $data");
102 }
103  
104 0 ▶sub bin ($) {
Subroutine bin: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my ($self)=@_;
106 0 $self->command("TYPE I");
107 }
108 0 ▶sub ascii ($) {
Subroutine ascii: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my ($self)=@_;
110 0 $self->command("TYPE A");
111 }
112  
113 0 ▶sub size ($$) {
Subroutine size: not called CC=2 SCAR=17.9
Pod undocumented
114 0 my ($self,$filename)=@_;
115 0 ▶ my $size=$self->command("SIZE $filename");chop $size if defined($size);
Branch: 1 branch
BranchTrueFalseTotal
if defined $size 0 0 0
116 0 return $size;
117 }
118 0 ▶sub cdup ($$) {
Subroutine cdup: not called CC=1 SCAR=6.9
Pod undocumented
119 0 my ($self,$data)=@_;
120 0 $self->command("CDUP");
121 }
122 0 ▶sub dele {
Subroutine dele: not called CC=2 SCAR=17.9
Pod undocumented
123 0 my ($self,$pathname)=@_;
124 0 ▶ return undef unless defined($pathname);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pathname 0 0 0
125 0 $self->command("DELE $pathname");
126 }
127 0 ▶sub rm {dele(@_);};
Subroutine rm: not called CC=1 SCAR=6.9
Pod undocumented
128 0 ▶sub delete {dele(@_);};
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
129 0 ▶sub del { shift->del(@_) };
Subroutine del: not called CC=1 SCAR=6.9
Pod undocumented
130  
131 0 ▶sub rawmessage ($) {
Subroutine rawmessage: not called CC=1 SCAR=6.9
Pod undocumented
132 0 my ($self)=@_;
133 0 return $self->{'FTPRAWMSG'};
134 };
135 0 ▶sub message ($) {
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
136 0 my ($self)=@_;
137 0 return $self->{'FTPMSG'};
138 };
139 0 ▶sub msgcode ($) {
Subroutine msgcode: not called CC=1 SCAR=6.9
Pod undocumented
140 0 my ($self)=@_;
141 0 return $self->{'FTPCODE'};
142 };
143  
144 0 ▶sub readln {
Subroutine readln: not called CC=4 SCAR=30.0
Pod undocumented
145 0 my ($sock)=@_;
146 0 my ($data,$ln);
147 0 ▶ if (sysread($sock,$data,BUFSIZE)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $sock, $data, 4096) 0 0 0
148 0 $ln=$data;
149 0 ▶ while ($data!~/\n/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data =~ /\n/) 0 0 0
150 0 ▶ if (sysread($sock,$data,BUFSIZE)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $sock, $data, 4096) 0 0 0
151 #print "OPEN..Received: {$data}\n";# if $self->{Debug};
152 0 $ln.=$data;
153 };
154 };
155 };
156 0 return $ln;
157 };
158  
159 #sub SOL_IP { 0; };
160 #sub IP_TOS { 1; };
161  
162 0 ▶sub open($$$) {
Subroutine open: not called CC=18 SCAR=58.3
Pod undocumented
163 0 my ($self,$host,$port)=@_;
164 0 my ($data);
165 my $sock;
166 0 $sock = Net::SSLeay::Handle->make_socket($host, $port);
167 0 $self->{'Sock'}=$sock;
168 0 $self->{'Host'}=$host;
169 0 $self->{'Port'}=$port;
170 #tmp
171
172 #setsockopt($sock,&SOL_SOCKET,&SO_KEEPALIVE,undef,undef) || warn "setsockopt: $!";
173 0 ▶ setsockopt($sock, SOL_SOCKET, SO_SNDTIMEO, pack('L!L!', 15, 0) ) or warn "setsockopt SNDTIMEO unset: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $sock, 1, 21, "\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or warn 'setsockopt SNDTIMEO unset: ' . $! 0 0 0
174 0 ▶ setsockopt($sock, SOL_SOCKET, SO_RCVTIMEO, pack('L!L!', 15, 0) ) or warn "setsockopt RCVTIMEO unset: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $sock, 1, 20, "\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or warn 'setsockopt RCVTIMEO unset: ' . $! 0 0 0
175 0 ▶ setsockopt($sock, SOL_SOCKET, SO_KEEPALIVE, 1 ) or warn "setsockopt KEEPALIVE unset: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $sock, 1, 9, 1 or warn 'setsockopt KEEPALIVE unset: ' . $! 0 0 0
176 #setsockopt($sock, SOL_SOCKET, IP_TOS, IPTOS_LOWDELAY ) or die "setsockopt".$!;
177 #/usr/share/perl/5.8.4/Net/Ping.pm: setsockopt($self->{"fh"}, SOL_IP, IP_TOS(), pack("I*", $self->{'tos'}))
178 #setsockopt($sock, SOL_IP, IP_TOS(), pack("I*",0x10 ));
179 #LOWLATENCY
180 0 ▶ setsockopt($sock, IPPROTO_IP, IP_TOS, pack("I*", 0x10))
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $sock, 0, 1, "\20\0\0\0" or warn qq[error configuring tos LOW LATENCY to $self->{"fh"} $!] 0 0 0
181 or warn "error configuring tos LOW LATENCY to $self->{'fh'} $!";
182  
183  
184 #/usr/include/linux/ip.h:#define IPTOS_LOWDELAY 0x10
185 ##define IPTOS_THROUGHPUT 0x08
186 #define IPTOS_MINCOST 0x02
187 #/usr/share/perl/5.8.4/Net/Ping.pm: setsockopt($self->{"fh"}, SOL_IP, IP_TOS(), pack("I*", $self->{'tos'}))
188 #end tmp 2008-11-04
189  
190 #FTPS EXPLICIT:
191 0 ▶ if ($self->{'FTPS'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"FTPS"}) 0 0 0
192 #{tie(*S, "Net::SSLeay::Handle", $sock);$sock = \*S;};
193 # Unique glob?
194 0 {my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $sock);$sock = \*$io;};
195 }
196  
197  
198  
199 0 ▶ if ($data=readln($sock)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data = readln($sock)) 0 0 0
200 0 ▶ print STDERR "OPEN.Received: $data" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
201 0 $data=$self->responserest($data);
202 0 ▶ print STDERR "OPEN..Received: $data" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
203 }
204  
205 0 ▶ if ($self->{'Encrypt'} && (! $self->{'FTPS'} )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Encrypt"} and not $self->{"FTPS"}) 0 0 0
Condition0%0/3
$self->{"Encrypt"} and not $self->{"FTPS"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"Encrypt"} and not $self->{"FTPS"}
$self->{"Encrypt"} not $self->{"FTPS"}
Truth table0%0/3
A and not(B)
A= $self->{"Encrypt"}B= not $self->{"FTPS"}
ABresult
0X0
100
111
206 0 $data="AUTH TLS\r\n";
207 0 syswrite($sock,$data);
208 0 ▶ if ($data=readln($sock)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data = readln($sock)) 0 0 0
209 0 ▶ print STDERR "Received: $data" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
210 }
211 }
212  
213 0 ▶ if ($self->{'Integrity'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Integrity"}) 0 0 0
214 0 $self->command("INTEGRITY H");# TODO
215 };
216  
217 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Compress"}) 0 0 0
218 0 $self->command("MODE Z");# TODO
219 };
220 0 $self->{'RAWSock'}=$sock;
221  
222 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Compress"}) 0 0 0
223 # IO::Compress::Deflate
224 # IO::Uncompress::Inflate
225 };
226  
227 0 ▶ if ($self->{'Encrypt'} && (! $self->{'FTPS'} )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Encrypt"} and not $self->{"FTPS"}) 0 0 0
Condition0%0/3
$self->{"Encrypt"} and not $self->{"FTPS"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"Encrypt"} and not $self->{"FTPS"}
$self->{"Encrypt"} not $self->{"FTPS"}
Truth table0%0/3
A and not(B)
A= $self->{"Encrypt"}B= not $self->{"FTPS"}
ABresult
0X0
100
111
228 #{tie(*S, "Net::SSLeay::Handle", $sock);$sock = \*S;};
229 # Unique glob?
230 0 {my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $sock);$sock = \*$io;};
231 }
232  
233 0 $self->{'Sock'}=$sock;
234 0 {select($sock);$|=1;select(STDOUT);};#unbuffer socket
235  
236 0 $self->setup_protection();
237  
238 #
239 0 return 1;
240 }
241  
242 0 ▶sub quit {
Subroutine quit: not called CC=1 SCAR=6.9
Pod undocumented
243 0 my ($self)=@_;
244 0 return $self->command("QUIT");
245 }
246 0 ▶sub noop {
Subroutine noop: not called CC=1 SCAR=6.9
Pod undocumented
247 0 my ($self)=@_;
248 0 return $self->command("NOOP");
249 }
250 0 ▶sub rename ($$$) {
Subroutine rename: not called CC=2 SCAR=17.9
Pod undocumented
251 0 my ($self,$from,$to)=@_;
252 #"RNFR plik1"
253 #"RNTO plik2"
254 0 ▶ if ($self->command("RNFR $from")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->command("RNFR $from")) { } 0 0 0
255 0 return $self->command("RNTO $to");
256 0 } else {return 0;};
257 };
258 0 ▶sub mdtm ($$) {
Subroutine mdtm: not called CC=1 SCAR=6.9
Pod undocumented
259 0 my ($self,$file)=@_;
260 0 return $self->command("MDTM $file");
261 };
262  
263 0 ▶sub command ($$){
Subroutine command: not called CC=2 SCAR=17.9
Pod undocumented
264 0 my ($self,$data)=@_;
265 0 ▶ print STDERR "Sending: ",$data."\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
266 0 my $sock=$self->{'Sock'};
267 # print $sock $data."\r\n";
268 0 syswrite( $sock ,$data."\r\n");
269 0 return $self->response();
270 }
271  
272 0 ▶sub response ($) {
Subroutine response: not called CC=5 SCAR=34.0
Pod undocumented
273 0 my ($self)=@_;
274 0 my $sock=$self->{'Sock'};
275 0 my ($read,$resp,$code,$cont);
276 0 my $start=time;
277 0 $read=($resp=<$sock>);#, redo if (Errno::EAGAIN && (!defined($read)));
278 #my $recvbytes=$sock->recv($read,1024);#, redo if Errno::EAGAIN;
279
280 #TODO skip this, if RAWSock is disconnected... otherwise there's no sense in waiting for data..
281  
282 0 ▶ while (!defined($read) && Errno::EAGAIN && (time-$start<190)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $read and 11 and time - $start < 190) 0 0 0
Condition0%0/5
not defined $read and 11 and time - $start < 190
!ll&&!rl&&r
000
not defined $read and 11
!ll
00
MC/DC0%0/2
not defined $read and 11 and time - $start < 190
not defined $read time - $start < 190
Truth table0%0/3
not(A) and B
A= not defined $readB= time - $start < 190
ABresult
0X0
100
111
283 0 $read=($resp=<$sock>);
284 #, redo until timeout or sth
285 }
286  
287 0 ▶ if (!defined($read)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $read) 0 0 0
288 0 warn "EAGAIN again 190s! $!" if Errno::EAGAIN;
289 0 warn "Damn! undefined response (err:$!) {H: ".$self->{'Host'}." P:".$self->{'Port'}."}\n";# unless defined($read);
290 0 $self->{'FTPCODE'}=undef;
291 0 $self->{'FTPMSG'}=undef;
292 0 $self->{'FTPRAWMSG'}=undef;
293 0 return undef;# unless defined($read);
294 };
295 0 return $self->responserest($read);
296 }
297  
298 0 ▶sub responserest ($$) {
Subroutine responserest: not called CC=13 SCAR=52.0
Pod undocumented
299 0 my ($self,$read)=@_;
300 0 my $sock=$self->{'Sock'};
301 0 my ($resp,$code,$cont,$msg);
302 0 $resp=$read;
303 #UWAGA!
304 # wcale nieprawda to co nizej pisze. Jesli pierwsza linijka to \d\d\d-
305 # to odbierac linijki az do napotkania \d\d\d\s
306 # np:
307 # 226-EDI processing started
308 # 01 costam...
309 # 02 costam..
310 # 226 ...EDI processing complete
311  
312  
313 # Responsy maja format \d\d\d
314 # lub wielolinijkowe: \d\d\d-
315 0 ▶ print STDERR "SRV Response: $read" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
316 0 ▶ $read=~/^(\d\d\d)\s(.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
$read =~ /^(\d\d\d)\s(.*)/ and do { $code = $1; $msg = $2; chomp $msg } 0 0 0
317 0 $code=$1;$msg=$2;chomp($msg);
318 };
319 0 ▶ $read=~/^(\d\d\d)-(.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
$read =~ /^(\d\d\d)-(.*)/ and do { $cont = 1; $code = $1; $msg .= $2; print STDERR "wielolinijkowa odpowiedz z servera.." if $self->{"Debug"} } 0 0 0
320 0 $cont=1;$code=$1;$msg.=$2;
321 0 ▶ print STDERR "wielolinijkowa odpowiedz z servera.." if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
322 };
323 0 ▶ if ($read=~/^(\d\d\d)\s(.*)/m) {$cont=0;}; # wyjatek na wielolinijkowe na dziendobry
Branch: 1 branch
BranchTrueFalseTotal
if ($read =~ /^(\d\d\d)\s(.*)/m) 0 0 0
324 0 ▶ if ($cont) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont) 0 0 0
325 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$cont == 0 or do { do { $read = readline $sock; $resp .= $read; $read =~ /^(\d\d\d)-(.*)/ and do { $cont = 1; $code = $1; $msg .= $2 }; $read =~ /^(\d\d\d)\s(.*)/ and do { $cont = 0; $code = $1; $msg .= $2 }; print " ----> $read\n" if $self->{"Debug"} } } 0 0 0
326 0 $read=<$sock>;
327 0 $resp.=$read;
328 0 ▶ $read=~/^(\d\d\d)-(.*)/ && do {$cont=1;$code=$1;$msg.=$2;};
Branch: 1 branch
BranchTrueFalseTotal
$read =~ /^(\d\d\d)-(.*)/ and do { $cont = 1; $code = $1; $msg .= $2 } 0 0 0
329 0 ▶ $read=~/^(\d\d\d)\s(.*)/ && do {$cont=0;$code=$1;$msg.=$2;};
Branch: 1 branch
BranchTrueFalseTotal
$read =~ /^(\d\d\d)\s(.*)/ and do { $cont = 0; $code = $1; $msg .= $2 } 0 0 0
330 0 ▶ print " ----> $read\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
331 } until ($cont==0);
332 };
333 0 $self->{'FTPCODE'}=$code;
334 0 $self->{'FTPMSG'}=$msg;
335 #$resp=~s/^\d\d\d\s/;
336 0 $self->{'FTPRAWMSG'}=$resp;
337  
338 0 ▶ if ($code>399) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code > 399) 0 0 0
339 #warn "Jaki¶ problem, chyba najlepiej sie wycofac\n";
340 #warn $resp;
341 # print STDERR "ERR: $resp\n";
342 #warn "Server said we're bad.";
343 0 $self->{'ErrMSG'}=$resp;
344 0 return undef;
345 };
346 0 ▶ print STDERR "RECV: ",$resp if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
347 0 return $msg;
348 }
349  
350 0 ▶sub list {return nlst(@_);};
Subroutine list: not called CC=1 SCAR=6.9
Pod undocumented
351 0 ▶sub nlst {
Subroutine nlst: not called CC=19 SCAR=59.4
Pod undocumented
352 0 my ($self,$mask)=@_;
353 0 my $sock=$self->{'Sock'};
354 0 my $socket;
355 0 my (@files)=();
356 0 $socket=$self->datasocket();
357 0 ▶ if (defined($socket)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $socket) 0 0 0
358 0 my $response;
359 0 ▶ if (defined($mask)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mask) { } 0 0 0
360 0 $response=$self->command("NLST $mask");
361 } else {
362 0 $response=$self->command("NLST");
363 };
364 #print STDERR "ReSPONSE: -> : $response\n";
365 #print "KOD : ",$self->{'FTPCODE'},"\n";
366 # 1xx - cos jeszcze bedzie
367 # 2xx - to juz koniec
368 0 ▶ if ($response && ($self->{'FTPCODE'}<200) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response and $self->{"FTPCODE"} < 200) 0 0 0
Condition0%0/3
$response and $self->{"FTPCODE"} < 200
!ll&&!rl&&r
000
MC/DC0%0/2
$response and $self->{"FTPCODE"} < 200
$response $self->{"FTPCODE"} < 200
Truth table0%0/3
A and B
A= $responseB= $self->{"FTPCODE"} < 200
ABresult
0X0
100
111
369  
370 0 ▶ if ($self->{"EncryptData"}==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} == 1) 0 0 0
371 0 {my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $socket);$socket = \*$io;};
372 0 ▶ print STDERR "SSL for data connection enabled...\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
373 };
374 0 my $tmp;
375 0 ▶ if ( $self->{'Compress'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Compress'}) { } 0 0 0
376 0 ▶ my $x = new Compress::Raw::Zlib::Inflate()
Branch: 1 branch
BranchTrueFalseTotal
my $x = "Compress::Raw::Zlib::Inflate"->new or die "Cannot create a inflation stream\n" 0 0 0
377 or die "Cannot create a inflation stream\n" ;
378 0 my $buf;my $read;
379  
380 0 my ($output, $status) ;
381 0 ▶ while (sysread($socket,$buf,BUFSIZE))
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $socket, $buf, 4096) 0 0 0
382 {
383 0 $status = $x->inflate($buf, $output) ;
384 0 $read+=length($output);
385 #print $output ;
386 0 ▶ print STDERR "LST: $output\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
387 0 $output=~s/\r\n$//;
388 0 push @files,$output;
389  
390 0 ▶ last if $status != Z_OK ;
Branch: 1 branch
BranchTrueFalseTotal
if $status != Z_OK() 0 0 0
391 };
392 0 ▶ die "inflation failed\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $status == Z_STREAM_END() 0 0 0
393 unless $status == Z_STREAM_END ;
394  
395 # print STDERR "===> READ: $read\n";
396  
397 } else {
398 #TODO: if {'Compress'}
399 0 ▶ while ($tmp=<$socket>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($tmp = readline $socket)) 0 0 0
400 #print STDERR "G: $q";
401 #chop($tmp);chop($tmp);#\r\n -> remove.
402 0 $tmp=~s/\r\n$//;
403 0 push @files,$tmp;
404 };
405 }
406 };
407 0 close $socket;
408 0 ▶ if ($response && ($self->{'FTPCODE'}<200) ) {if ($response) {$response=$self->response();};}
Branch: 2 branches
BranchTrueFalseTotal
if ($response and $self->{"FTPCODE"} < 200) 0 0 0
if ($response) 0 0 0
Condition0%0/3
$response and $self->{"FTPCODE"} < 200
!ll&&!rl&&r
000
MC/DC0%0/2
$response and $self->{"FTPCODE"} < 200
$response $self->{"FTPCODE"} < 200
Truth table0%0/3
A and B
A= $responseB= $self->{"FTPCODE"} < 200
ABresult
0X0
100
111
409 0 ▶ print STDERR "resp(end LIST) ",$response if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
410 0 ▶ return \@files if $response;
Branch: 1 branch
BranchTrueFalseTotal
if $response 0 0 0
411 };
412 0 return 0;
413 };
414  
415 0 ▶sub putblat {
Subroutine putblat: not called CC=29 SCAR=67.7
Pod undocumented
416 0 my ($putorblat,$stororappe,$self,$remote,$local)=@_;
417 0 my $socket;
418 0 my $sock=$self->{'Sock'};
419 0 ▶ $local=$remote unless defined($local);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $local 0 0 0
420 0 ▶ $self->command("TYPE I") unless ($self->{'DontDoType'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DontDoType"} 0 0 0
421 0 $socket=$self->datasocket();
422 0 ▶ warn "SOCKET NOT CONNECTED! $!\n" unless defined($socket);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $socket 0 0 0
423 0 ▶ if ($self->{"EncryptData"}!=0) {$self->command("PROT P"); };
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} != 0) 0 0 0
424 0 my $r=$self->command("$stororappe $remote");
425 0 ▶ if (!$r) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r) 0 0 0
426 0 ▶ print STDERR "Problem trying to put file" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
427 0 return $r;
428 };
429  
430 0 ▶ if ($self->{"EncryptData"}==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} == 1) 0 0 0
431 0 {my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $socket);$socket = \*$io;};
432 0 ▶ print STDERR "SSL for data connection enabled...\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
433 };
434  
435 0 ▶ print STDERR "$stororappe connection opened.\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
436 0 select($socket);
437 #print "selected.\n";
438 0 ▶ if ($putorblat=~/put/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($putorblat =~ /put/) { } 0 0 0
439 #
440  
441  
442 0 ▶ CORE::open(L,"$local") or die "Can't open file $local, $!";
Branch: 1 branch
BranchTrueFalseTotal
CORE::open L, "$local" or die "Can't open file $local, $!" 0 0 0
443 0 binmode L;
444 0 my $buf;
445  
446 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Compress'}) { } 0 0 0
447 #my $x = new Compress::Raw::Zlib::Deflate ( -Bufsize => 8192, -Level=> 1,-Strategy=>Z_DEFAULT_STRATEGY,-WindowBits=>15)
448 0 ▶ my $x = new Compress::Raw::Zlib::Deflate ( -Bufsize => $self->{"CompressionBufsize"}, -Level=> $self->{"CompressionLevel"},-Strategy=>$self->{"CompressionStrategy"},-WindowBits=>$self->{"CompressionWindowBits"})
Branch: 1 branch
BranchTrueFalseTotal
my $x = "Compress::Raw::Zlib::Deflate"->new("-Bufsize", $self->{"CompressionBufsize"}, "-Level", $self->{"CompressionLevel"}, "-Strategy", $self->{"CompressionStrategy"}, "-WindowBits", $self->{"CompressionWindowBits"}) or die "Cannot create compression stream $!" 0 0 0
449 or die "Cannot create compression stream $!";
450 #deflate $local => $socket,AutoClose=>1,BinModeIn=>1
451 # or die "Cannot compress to $socket $DeflateError $!";
452 #
453 0 my $read=0;my $circular=0;
454 0 my ($output, $status) ;
455 #while ($buf=<L>)
456 0 ▶ while ( sysread(L,$buf,BUFSIZE))
Branch: 1 branch
BranchTrueFalseTotal
if (sysread L, $buf, 4096) 0 0 0
457 {
458 0 $status = $x->deflate($buf, $output) ;
459 0 ▶ $status == Z_OK
Branch: 1 branch
BranchTrueFalseTotal
$status == Z_OK() or die "deflation failed $!\n" 0 0 0
460 or die "deflation failed $!\n" ;
461 0 print $output ;
462 #print STDERR "GOT ".length($output)." bytes from deflation\n";
463 0 $read+=length($buf);
464 #$circular+=length($buf);
465 #if ($circular>8192) {
466 # $circular=0;
467 # print STDERR "trying part-flush\n";
468 # $status = $x->flush($output,Z_SYNC_FLUSH) ;
469 # $status == Z_OK
470 # or die "deflation failed $!\n" ;
471 # print $output ;
472 # print STDERR "GOT ".length($output)." bytes from no-flush-deflation\n";
473 #};
474 0 ▶ if (defined ($self->{'PutUpdateCallback'})) {$self->{'PutUpdateCallback'}->( length($buf) ); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"PutUpdateCallback"}) 0 0 0
475  
476 }
477 0 ▶ print STDERR "out of buf LOOP\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
478 0 $status = $x->flush($output) ;
479 0 ▶ $status == Z_OK
Branch: 1 branch
BranchTrueFalseTotal
$status == Z_OK() or die "deflation failed $!\n" 0 0 0
480 or die "deflation failed $!\n" ;
481 #print $output ;
482 0 syswrite($socket, $output) ;
483 0 ▶ print STDERR "GOT ".length($output)." bytes from flush-deflation\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
484  
485 }
486 else {
487 0 ▶ while ($buf=<L>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($buf = readline L)) 0 0 0
488 0 print $buf;
489 0 ▶ if (defined ($self->{'PutUpdateCallback'})) {$self->{'PutUpdateCallback'}->( length($buf) ); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"PutUpdateCallback"}) 0 0 0
490 };#Probably syswrite/sysread would be smarter..
491 }
492 0 close L;
493 } else {
494 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Compress'}) { } 0 0 0
495 0 ▶ my $x = new Compress::Raw::Zlib::Deflate ( -Bufsize => 8192)
Branch: 1 branch
BranchTrueFalseTotal
my $x = "Compress::Raw::Zlib::Deflate"->new("-Bufsize", 8192) or die "Cannot create compression stream $!" 0 0 0
496 or die "Cannot create compression stream $!";
497 0 my $output;
498 0 my $status = $x->deflate($local, $output) ;
499 0 ▶ $status == Z_OK
Branch: 1 branch
BranchTrueFalseTotal
$status == Z_OK() or die "deflation failed\n" 0 0 0
500 or die "deflation failed\n" ;
501 #print $output ;
502 0 syswrite($socket, $output) ;
503 0 $status = $x->flush($output) ;
504 0 ▶ $status == Z_OK
Branch: 1 branch
BranchTrueFalseTotal
$status == Z_OK() or die "deflation failed\n" 0 0 0
505 or die "deflation failed\n" ;
506 #print $output ;
507 0 syswrite($socket, $output) ;
508 } else {
509 #print $local;
510 0 syswrite($socket, $local) ;
511 };
512 0 ▶ if (defined ($self->{'PutUpdateCallback'})) {$self->{'PutUpdateCallback'}->( length($local) ); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"PutUpdateCallback"}) 0 0 0
513 }
514 #print "after write...\n";
515 0 select(STDOUT);
516 0 $socket->flush();
517 0 close $socket;
518 0 my $response=$self->response();
519 0 ▶ print STDERR "resp(after$stororappe) ",$response if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
520 0 ▶ if (defined $self->{'PutDoneCallBack'}) {$self->{'PutDoneCallBack'}->($response);};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"PutDoneCallBack"}) 0 0 0
521 0 return $self->{'FTPRAWMSG'};
522 };
523 0 ▶sub put {
Subroutine put: not called CC=1 SCAR=6.9
Pod undocumented
524 0 putblat('put','STOR',@_);
525 };
526 0 ▶sub blat {
Subroutine blat: not called CC=1 SCAR=6.9
Pod undocumented
527 0 putblat('blat','STOR',@_);
528 };
529 0 ▶sub appe {
Subroutine appe: not called CC=1 SCAR=6.9
Pod undocumented
530 0 putblat('put','APPE',@_);
531 };
532 0 ▶sub blatappe {
Subroutine blatappe: not called CC=1 SCAR=6.9
Pod undocumented
533 0 putblat('blat','APPE',@_);
534 };
535  
536 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
537 0 getslurp('get',@_);
538 };
539 0 ▶sub slurp {
Subroutine slurp: not called CC=1 SCAR=6.9
Pod undocumented
540 0 getslurp('slurp',@_);
541 };
542  
543 0 ▶sub getslurp {
Subroutine getslurp: not called CC=37 SCAR=72.5
Pod undocumented
544 0 my ($getorslurp,$self,$remote,$local)=@_;
545 0 my $socket;
546 0 my $sock=$self->{'Sock'};
547 0 ▶ $local=$remote unless defined($local);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $local 0 0 0
548 0 $self->command("TYPE I");
549 0 $socket=$self->datasocket();
550 #tmp
551 #setsockopt($sock,&SOL_SOCKET,&SO_KEEPALIVE,undef,undef) || warn "setsockopt: $!";
552 0 ▶ setsockopt($socket, SOL_SOCKET, SO_SNDTIMEO, pack('L!L!', 15, 0) ) or warn "setsockopt SNDTIMEO: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $socket, 1, 21, "\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or warn 'setsockopt SNDTIMEO: ' . $! 0 0 0
553 0 ▶ setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack('L!L!', 15, 0) ) or warn "setsockopt RCVTIMEO: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $socket, 1, 20, "\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or warn 'setsockopt RCVTIMEO: ' . $! 0 0 0
554 0 ▶ setsockopt($socket, SOL_SOCKET, SO_KEEPALIVE, 1 ) or warn "setsockopt KEEPALIVE: ".$!;
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $socket, 1, 9, 1 or warn 'setsockopt KEEPALIVE: ' . $! 0 0 0
555 0 ▶ setsockopt($socket, IPPROTO_IP, IP_TOS(), pack("I*",0x08 )) or warn "setsockopt TOS THROUGPHUT problem: $!";#THROUGHPUT
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $socket, 0, 1, "\b\0\0\0" or warn "setsockopt TOS THROUGPHUT problem: $!" 0 0 0
556 #end tmp 2008-11-04
557  
558 0 ▶ if ($self->{"EncryptData"}!=0) {$self->command("PROT P"); };
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} != 0) 0 0 0
559 0 my $r=$self->command("RETR $remote");
560 0 ▶ if (!$r) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r) 0 0 0
561 0 ▶ print STDERR "Problem trying to get file($remote)" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
562 0 return $r;
563 };
564  
565 0 ▶ if ($self->{"EncryptData"}==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} == 1) 0 0 0
566 0 {my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $socket);$socket = \*$io;};
567 0 ▶ print STDERR "SSL for data connection(RETR) enabled...\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
568 };
569 0 my $slurped="";
570 0 ▶ if ($getorslurp=~/get/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getorslurp =~ /get/) { } 0 0 0
571 0 ▶ print STDERR "getorslurp: get\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
572 0 ▶ CORE::open(L,">$local") or die("Can't open file for writing $local, $!");
Branch: 1 branch
BranchTrueFalseTotal
CORE::open L, ">$local" or die "Can't open file for writing $local, $!" 0 0 0
573 0 binmode L;
574 0 my $tmp;my $cntr=0;
575  
576  
577 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Compress'}) { } 0 0 0
578 #my $z = new IO::Uncompress::Inflate $socket, AutoClose=>1,Strict=>1
579 # or die "IO::Uncompress::Inflate failed: $InflateError\n";
580 #inflate $socket => "ftp.".$local, AutoClose=>1
581 # or die "Cannot decompress from $socket to $local $InflateError $!";
582  
583
584 0 ▶ my $x = new Compress::Raw::Zlib::Inflate()
Branch: 1 branch
BranchTrueFalseTotal
my $x = "Compress::Raw::Zlib::Inflate"->new or die "Cannot create a inflation stream\n" 0 0 0
585 or die "Cannot create a inflation stream\n" ;
586 0 my $buf;my $read;
587  
588 0 my ($output, $status) ;
589 0 ▶ while (sysread($socket,$buf,BUFSIZE))
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $socket, $buf, 4096) 0 0 0
590 {
591 0 $status = $x->inflate($buf, $output) ;
592 0 $read+=length($output);
593 #print $output ;
594 0 print L $output;
595 0 ▶ print STDERR length($output),":;".++$cntr."\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
596 0 ▶ if (defined ($self->{'GetUpdateCallback'})) {$self->{'GetUpdateCallback'}->(length($output)); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"GetUpdateCallback"}) 0 0 0
597 0 ▶ last if $status != Z_OK ;
Branch: 1 branch
BranchTrueFalseTotal
if $status != Z_OK() 0 0 0
598 };
599 0 ▶ die "inflation failed\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $status == Z_STREAM_END() 0 0 0
600 unless $status == Z_STREAM_END ;
601  
602 # print STDERR "===> READ: $read\n";
603 } else
604 {
605 # TODO replace while <$socket> with
606 # TODO while sysread($sock,$tmp,BUFSIZE);
607  
608 0 ▶ while (sysread($socket,$tmp,BUFSIZE)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $socket, $tmp, 4096) 0 0 0
609 0 print L $tmp;
610 0 ▶ print STDERR length($tmp),":;".++$cntr."\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
611 0 ▶ if (defined ($self->{'GetUpdateCallback'})) {$self->{'GetUpdateCallback'}->(length($tmp)); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"GetUpdateCallback"}) 0 0 0
612 };
613 #tmp-2008-10-22# while ($tmp=<$socket>) {
614 #tmp-2008-10-22# print L $tmp;
615 #tmp-2008-10-22# print STDERR length($tmp),":;\n" if $self->{Debug};
616 #tmp-2008-10-22# if (defined ($self->{'GetUpdateCallback'})) {$self->{'GetUpdateCallback'}->();print STDERR "GUC defined, and has been called\n"; };#TODO send sth..
617 #tmp-2008-10-22# };
618 0 close L;
619 }
620 } else {
621  
622 0 ▶ print STDERR "getorslurp: slurp($getorslurp)\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
623 0 my $tmp;
624  
625 0 ▶ if ($self->{'Compress'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Compress'}) { } 0 0 0
626 0 ▶ my $x = new Compress::Raw::Zlib::Inflate()
Branch: 1 branch
BranchTrueFalseTotal
my $x = "Compress::Raw::Zlib::Inflate"->new or die "Cannot create a inflation stream\n" 0 0 0
627 or die "Cannot create a inflation stream\n" ;
628 0 my $buf;my $read;
629  
630 0 my ($output, $status) ;
631 0 ▶ while (sysread($socket,$buf,BUFSIZE))
Branch: 1 branch
BranchTrueFalseTotal
if (sysread $socket, $buf, 4096) 0 0 0
632 {
633 0 $status = $x->inflate($buf, $output) ;
634 0 $read+=length($output);
635 #print $output ;
636 0 $slurped.=$output;
637 0 ▶ print STDERR length($output),":slurpZ;" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
638 0 ▶ if (defined ($self->{'GetUpdateCallback'})) {$self->{'GetUpdateCallback'}->(length($output)); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"GetUpdateCallback"}) 0 0 0
639 0 ▶ last if $status != Z_OK ;
Branch: 1 branch
BranchTrueFalseTotal
if $status != Z_OK() 0 0 0
640 };
641 0 ▶ die "inflation failed\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $status == Z_STREAM_END() 0 0 0
642 unless $status == Z_STREAM_END ;
643  
644  
645 } else {
646 0 ▶ while ($tmp=<$socket>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($tmp = readline $socket)) 0 0 0
647 0 ▶ $slurped.=$tmp;print STDERR ":slurp." if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
648 0 ▶ if (defined ($self->{'GetUpdateCallback'})) {$self->{'GetUpdateCallback'}->( length($tmp) ); };#TODO send sth..
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"GetUpdateCallback"}) 0 0 0
649 };
650 };
651 };
652 0 close $socket;
653 0 my $response=$self->response();
654 0 ▶ print STDERR "resp(afterRETR) ",$response if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
655 0 ▶ if (defined $self->{'GetDoneCallBack'}) {$self->{'GetDoneCallBack'}->($response);};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"GetDoneCallBack"}) 0 0 0
656 0 return $slurped;
657 };
658  
659 0 ▶sub datasocket {
Subroutine datasocket: not called CC=9 SCAR=45.0
Pod undocumented
660 0 my ($self)=@_;
661 0 my ($tmp,$socket);
662 0 ▶ if ($tmp=$self->command("PASV")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp = $self->command('PASV')) { } 0 0 0
663 0 ▶ if ($self->msgcode()==227 && $tmp=~/[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->msgcode == 227 and $tmp =~ /[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/) { } 0 0 0
Condition0%0/3
$self->msgcode == 227 and $tmp =~ /[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->msgcode == 227 and $tmp =~ /[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/
$self->msgcode == 227 $tmp =~ /[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/
Truth table0%0/3
A and B
A= $self->msgcode == 227B= $tmp =~ /[^\d]*(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)/
ABresult
0X0
100
111
664 0 my $port=$5*256+$6;
665 0 my $host="$1.$2.$3.$4";
666 0 ▶ print STDERR "PASV port is $port ( $host )\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
667 0 ▶ if (defined($self->{'ForcePASVIP'})) {$host=$self->{'ForcePASVIP'};print STDERR "Forcing PASV IP to $host\n" if $self->{Debug}};
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{"ForcePASVIP"}) 0 0 0
if $self->{"Debug"} 0 0 0
668 0 $socket = Net::SSLeay::Handle->make_socket($host, $port);
669 0 setsockopt($socket, IPPROTO_IP, IP_TOS(), pack("I*",0x08 ));#THROUGHPUT
670 0 ▶ if (defined($socket)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $socket) { } 0 0 0
671 0 ▶ print STDERR "Data link connected.. to $host at $port\n" if $self->{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Debug"} 0 0 0
672 } else {
673 0 warn "Data link NOT connected ($host,$port) $!";
674 0 die "Data link NOT connected ($host,$port) $!";
675 };
676 } else {
677 0 die "Problem parsing PASV response($tmp)";
678 };
679 } else {
680 0 warn "undefined response to PASV cmd (err:$!) {H: ".$self->{'Host'}." P:".$self->{'Port'}."}\n";# unless defined($read);
681 0 die "Problem sending PASV request, $tmp";
682 };# end if self -> command PASV
683 0 return $socket
684 };
685  
686 1 ▶sub trivialm {
Subroutine trivialm: called CC=1 SCAR=0.0
Pod undocumented
687 1 my ($self)=@_;
688 1 return 1;
689 };
690  
691 # extras...
692 #
693 0 ▶sub registerGetUpdateCallback {
Subroutine registerGetUpdateCallback: not called CC=1 SCAR=6.9
Pod undocumented
694 0 my ($self,$callback_ref)=@_;
695  
696 0 $self->{'GetUpdateCallback'} = $callback_ref;
697 }
698 0 ▶sub registerGetDoneCallback {
Subroutine registerGetDoneCallback: not called CC=1 SCAR=6.9
Pod undocumented
699 0 my ($self,$callback_ref)=@_;
700  
701 0 $self->{'GetDoneCallback'} = $callback_ref;
702 }
703 0 ▶sub registerPutUpdateCallback {
Subroutine registerPutUpdateCallback: not called CC=1 SCAR=6.9
Pod undocumented
704 0 my ($self,$callback_ref)=@_;
705  
706 0 $self->{'PutUpdateCallback'} = $callback_ref;
707 }
708 0 ▶sub registerPutDoneCallback {
Subroutine registerPutDoneCallback: not called CC=1 SCAR=6.9
Pod undocumented
709 0 my ($self,$callback_ref)=@_;
710  
711 0 $self->{'PutDoneCallback'} = $callback_ref;
712 }
713  
714 0 ▶sub setup_protection {
Subroutine setup_protection: not called CC=3 SCAR=24.8
Pod undocumented
715 0 my ($self)=@_;
716 0 ▶ if ($self->{'Encrypt'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Encrypt'}) { } 0 0 0
717 0 $self->command("PBSZ 0");# TODO
718 0 ▶ if ($self->{"EncryptData"}!=0) {$self->command("PROT P"); };
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EncryptData"} != 0) 0 0 0
719 0 } else {return 1;};
720 };
721  
722  
723 0 ▶sub check_raw_socket {
Subroutine check_raw_socket: not called CC=1 SCAR=2.2
Pod undocumented
724 0 my ($self)=@_;
725 1 ▶ use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
726 0 my $s=$self->{'RAWSock'};
727 0 my $hersockaddr = getpeername($s);
728 0 my ($port, $iaddr) = sockaddr_in($hersockaddr);
729 0 return $s->eof."$hersockaddr $port $iaddr";
730 };
731  
732  
733  
734 1 1;
735 __END__
↑ Summary example.pl »