1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
Index: Fan/FTP/FTP.pm
===================================================================
RCS file: /usr/home/ume/ncvs/src/ftpmirror/Fan/FTP/FTP.pm,v
retrieving revision 1.1.1.2
retrieving revision 1.6
diff -u -r1.1.1.2 -r1.6
--- Fan/FTP/FTP.pm 2000/03/03 07:35:58 1.1.1.2
+++ Fan/FTP/FTP.pm 2000/03/09 13:32:04 1.6
@@ -60,6 +60,9 @@
use Carp;
use Socket;
+
+use Socket6;
+
use Fan::TCP;
use AutoLoader 'AUTOLOAD';
@@ -390,7 +393,7 @@
$self->clearerror || return undef;
$self->cleardataconn; # always success
- my($port, $addr) = $self->sockname;
+ my ($port, $addr, $family) = $self->sockname;
my $acpt = Fan::TCP->new();
unless (defined($acpt)) {
@@ -398,20 +401,28 @@
return undef;
}
- unless ($acpt->do_server(tcp_bindaddr => $addr)) {
+ unless ($acpt->do_server(tcp_family => $family,
+ tcp_bindaddr => $addr)) {
warn("Fan::TCP->do_server failed");
return undef;
}
- ($port, $addr) = $acpt->sockname;
- unless ($addr =~ tr/./,/ == 3) {
- warn("ADDRESS=$addr must have just 3 dots");
- return undef;
+ ($port, $addr, $family) = $acpt->sockname;
+ my $command;
+ if ($family == AF_INET) {
+ unless ($addr =~ tr/./,/ == 3) {
+ warn("ADDRESS=$addr must have just 3 dots");
+ return undef;
+ }
+ $addr .= sprintf(",%d,%d", ($port >> 8) & 0xff, $port & 0xff);
+ $command = 'PORT';
+ } else {
+ $addr = "|2|$addr|$port|";
+ $command = 'EPRT';
}
- $addr .= sprintf(",%d,%d", ($port >> 8) & 0xff, $port & 0xff);
- unless ($self->putreq("PORT $addr") =~ /^2/) {
- warn("PORT command failed\n") if $LOG > 5;
+ unless ($self->putreq("$command $addr") =~ /^2/) {
+ warn("$command command failed\n") if $LOG > 5;
$self->error($self->{lastmesg});
return undef;
}
@@ -437,12 +448,20 @@
;#
sub pasv ($) {
my $self = shift;
- my $a_regexp = '\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)';
$self->clearerror &&
$self->cleardataconn || return undef;
- if ($self->putreq("PASV") !~ /^2/) {
+ my $family = ($self->sockname)[2];
+ my ($a_regexp, $command);
+ if ($family == AF_INET) {
+ $a_regexp = '\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)';
+ $command = 'PASV';
+ } else {
+ $a_regexp = '\([^\d\s]{3}(\d+)[^\d\s]\)';
+ $command = 'EPSV';
+ }
+ if ($self->putreq($command) !~ /^2/) {
$self->error($self->{lastmesg});
return undef;
}
@@ -452,11 +471,18 @@
}
my $bindaddr = $self->{ftp_bindaddr};
- my $port = $5 * 256 + $6;
- my $addr = join('.', $1, $2, $3, $4);
+ my ($port, $addr);
+ if ($family == AF_INET) {
+ $port = $5 * 256 + $6;
+ $addr = join('.', $1, $2, $3, $4);
+ } else {
+ $port = $1;
+ $addr = ($self->peername)[1];
+ }
my $data = Fan::TCP->new();
$data && $data->do_client(
+ tcp_family => $family,
tcp_bindaddr => $bindaddr,
tcp_host => $addr,
tcp_port => $port
|