Subject: | Clear Command Channel Context support |
I find that I need CCC (Clear Command Channel) support for a particular
ftp site's firewall. I reads the command to open the proper ports for
passive mode connectivity.
I do not find support for this in any version of this package. I will
say that this package was the first one to actually connect to the
site, so I have attempted to modify it.
Attached is a diff file that does the following:
adds a status flag to track if we are using CCC
add a ccc method to turn on CCC and set the flag
add a stat method to support the STAT command
update the command and response methods to check the status flag and
use either the original RAWSock (CCC mode) or the secured sock for the
active socket.
updated list and nlst to call the matching LIST or NLST commands,
folded together into a single processor simlar to get/slurp.
I also cleaned up some of the debug prints and the commented out error
reports as I needed them for my testing.
I hope this helps
Marshall
Subject: | FTP.pm.diff |
49a50
> $self->{"EncryptCommand"}=1;
73a75,81
> sub ccc ($) {
> my ($self) = @_;
> my $response = $self->command("CCC");
> $self->{"EncryptCommand"}=0;
> return $response;
> }
>
83a92,96
> sub stat ($$) {
> my ($self,$filename)=@_;
> my $size=$self->command("STAT $filename");chop $size if defined($size);
> return $size;
> }
181,182c194,201
< print STDERR "Sending: ",$data."\n" if $self->{Debug};
< my $sock=$self->{'Sock'};
---
> my $sock;
> if ($self->{"EncryptCommand"}) {
> $sock=$self->{'Sock'};
> print STDERR "Sending Encrypted: ",$data."\n" if $self->{Debug};
> } else {
> $sock=$self->{'RAWSock'};
> print STDERR "Sending Open: ",$data."\n" if $self->{Debug};
> }
189c208,213
< my $sock=$self->{'Sock'};
---
> my $sock;
> if ($self->{"EncryptCommand"}) {
> $sock=$self->{'Sock'};
> } else {
> $sock=$self->{'RAWSock'};
> }
204c228,233
< my $sock=$self->{'Sock'};
---
> my $sock;
> if ($self->{"EncryptCommand"}) {
> $sock=$self->{'Sock'};
> } else {
> $sock=$self->{'RAWSock'};
> }
254,256c283,286
< sub list {return nlst(@_);};
< sub nlst {
< my ($self,$mask)=@_;
---
> sub list {return listornlst("LIST", @_);};
> sub nlst {return listornlst("NLST", @_);};
> sub listornlst {
> my ($cmd,$self,$mask)=@_;
264c294
< $response=$self->command("NLST $mask");
---
> $response=$self->command("$cmd $mask");
266c296
< $response=$self->command("NLST");
---
> $response=$self->command("$cmd");
280c310
< #print STDERR "G: $q";
---
> #print STDERR "G: $tmp";
288c318
< print STDERR "resp(end LIST) ",$response if $self->{Debug};
---
> print STDERR "resp(end LIST) ",$response."\n" if $self->{Debug};
302c332
< if ($self->{"EncryptData"}!=0) {$self->command("PROT P"); };
---
> if (($self->{"EncryptData"}!=0)&&($self->{"EncryptCommand"}!=0)) {$self->command("PROT P"); };
365c395
< if ($self->{"EncryptData"}!=0) {$self->command("PROT P"); };
---
> if (($self->{"EncryptData"}!=0)&&($self->{"EncryptCommand"}!=0)) {$self->command("PROT P"); };