diff options
author | kuriyama <kuriyama@FreeBSD.org> | 2001-03-02 10:16:30 +0800 |
---|---|---|
committer | kuriyama <kuriyama@FreeBSD.org> | 2001-03-02 10:16:30 +0800 |
commit | 388e105309911aae8e074e540f5d8ff8acd4830b (patch) | |
tree | 22e37d51f6f5805486dccabba7df8841cfee22ab /ftp | |
parent | 8854d3b4ba18e4584361de20752ff6cb571043b1 (diff) | |
download | freebsd-ports-gnome-388e105309911aae8e074e540f5d8ff8acd4830b.tar.gz freebsd-ports-gnome-388e105309911aae8e074e540f5d8ff8acd4830b.tar.zst freebsd-ports-gnome-388e105309911aae8e074e540f5d8ff8acd4830b.zip |
Apply IPv6 patch.
Obtained from: ume
No response from: maintainer
Diffstat (limited to 'ftp')
-rw-r--r-- | ftp/ftpmirror/Makefile | 2 | ||||
-rw-r--r-- | ftp/ftpmirror/files/patch-FTP.pm | 108 | ||||
-rw-r--r-- | ftp/ftpmirror/files/patch-TCP.pm | 154 |
3 files changed, 264 insertions, 0 deletions
diff --git a/ftp/ftpmirror/Makefile b/ftp/ftpmirror/Makefile index 9ded91b31cdf..217a80be2542 100644 --- a/ftp/ftpmirror/Makefile +++ b/ftp/ftpmirror/Makefile @@ -12,6 +12,8 @@ MASTER_SITES= ftp://ftp.intec.co.jp/pub/utils/ftpmirror/beta/ MAINTAINER= yasuf@big.or.jp +BUILD_DEPENDS= ${LOCALBASE}/lib/perl5/site_perl/${PERL_VER}/${PERL_ARCH}/Socket6.pm:${PORTSDIR}/net/p5-Socket6 + USE_PERL5= YES GNU_CONFIGURE= YES diff --git a/ftp/ftpmirror/files/patch-FTP.pm b/ftp/ftpmirror/files/patch-FTP.pm new file mode 100644 index 000000000000..dd580e099080 --- /dev/null +++ b/ftp/ftpmirror/files/patch-FTP.pm @@ -0,0 +1,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; ++BEGIN { ++ eval 'use Socket6' unless (eval '&AF_INET6'); # IPv6 patched Perl ++} + 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 diff --git a/ftp/ftpmirror/files/patch-TCP.pm b/ftp/ftpmirror/files/patch-TCP.pm new file mode 100644 index 000000000000..86e5901413ae --- /dev/null +++ b/ftp/ftpmirror/files/patch-TCP.pm @@ -0,0 +1,154 @@ +Index: Fan/TCP/TCP.pm +=================================================================== +RCS file: /usr/home/ume/ncvs/src/ftpmirror/Fan/TCP/TCP.pm,v +retrieving revision 1.1.1.1 +retrieving revision 1.12 +diff -u -r1.1.1.1 -r1.12 +--- Fan/TCP/TCP.pm 1999/10/24 10:28:15 1.1.1.1 ++++ Fan/TCP/TCP.pm 2000/03/09 13:32:06 1.12 +@@ -35,15 +35,16 @@ + package Fan::TCP; + + use strict; +-use vars qw($VERSION $LOG +- $tcp_proto $seq_id $sent_octets $recv_octets); ++use vars qw($VERSION $LOG $seq_id $sent_octets $recv_octets); + + use Carp; + use Socket; ++BEGIN { ++ eval 'use Socket6' unless (eval '&AF_INET6'); # IPv6 patched Perl ++} + use AutoLoader 'AUTOLOAD'; + + $VERSION = '0.03'; +-$tcp_proto = (getprotobyname('tcp'))[2]; + + ;# + BEGIN { +@@ -463,27 +464,21 @@ + + # check local side port #. + my $port = $params{tcp_bindport} || $self->{tcp_bindport} || 0; +- if ($port !~ /^\d+$/) { +- if (!defined($port = getservbyname($port, 'tcp'))) { +- my $e = $!.''; +- $self->error($e, &FATAL); +- carp("$self: getservbyname($port) - $e"); +- return undef; +- } +- } + + # define local side address if bindaddr is not null string. +- my $addr = inet_aton( +- $params{tcp_bindaddr} || $self->{tcp_bindaddr} || '0.0.0.0'); +- +- # parameter for bind. +- my $me = sockaddr_in($port, $addr); ++ my $family = $params{tcp_family} ? $params{tcp_family} : AF_INET; ++ my $tcp_bindaddr = $params{tcp_bindaddr} || $self->{tcp_bindaddr} || ++ (($family == AF_INET) ? '0.0.0.0' : '::'); ++ ++ my ($socktype, $proto, $me, $canonname); ++ ($family, $socktype, $proto, $me, $canonname) ++ = getaddrinfo($tcp_bindaddr, $port, $family, SOCK_STREAM); + + # local file handle... + local *SOCKET; + + # creating a stream socket. +- unless (socket(SOCKET, PF_INET, SOCK_STREAM, $tcp_proto)) { ++ unless (socket(SOCKET, $family, $socktype, $proto)) { + my $e = $!.''; + $self->error($e, &FATAL); + carp("$self: socket - $e") if $LOG >= 5; +@@ -539,41 +534,27 @@ + return undef; + } + +- # try to parse port number +- if ($port !~ /^\d+$/) { +- if (!defined($port = getservbyname($port, 'tcp'))) { +- my $e = $!.''; +- $self->error($e, &FATAL); +- carp("$self: getservbyname($port) - $e"); +- return undef; +- } +- } +- +- # check server name +- my @addr; +- if ($host =~ /^(\d+)\.(\d+)\.(\d+).(\d+)$/) { +- @addr = (pack('C4', $1, $2, $3, $4)); +- } else { +- if ((@addr = gethostbyname($host)) < 5) { +- carp("$self: gethostbyname - $?"); +- my $e = $?.''; +- $self->error($e, &FATAL); +- carp("$self: gethostbyname - $e"); +- return undef; +- } +- splice(@addr, 0, 4); ++ # check server name and try to parse port number ++ my @infos = getaddrinfo($host, $port, AF_UNSPEC, SOCK_STREAM); ++ if ($#infos < 0) { ++ carp("$self: getaddrinfo($host, $port) - $?"); ++ my $e = $?.''; ++ $self->error($e, &FATAL); ++ carp("$self: getaddrinfo($host, $port) - $e"); ++ return undef; + } + + # Perl's bug? once connect fails, we could not any more + # connect (connect returns "Invalid Argument"). So we + # create/close a socket in each iteration. +- for my $i (@addr) { ++ while ($#infos >= 0) { ++ my ($family, $socktype, $proto, $peer, $canonname) ++ = splice(@infos, 0, 5); + + # open socket stores any error ++ $params{tcp_family} = $family; + $self->open_socket(%params) || return undef; + +- # target address. +- my $peer = sockaddr_in($port, $i); + my $result = undef; + + # do real work. +@@ -758,10 +739,13 @@ + my $sock = $self->handle; + + if (defined($sock)) { +- my($port, $a) = sockaddr_in(getsockname($sock)); +- my $addr = join('.', unpack('C4', $a)); +-carp("$self sockname=$addr:$port") if $LOG > 7; +- return wantarray ? ($port, $addr) : "$addr:$port"; ++ my $sa = getsockname($sock); ++ my $family = (unpack('CC', $sa))[1]; ++ my ($addr, $port) = getnameinfo($sa, NI_NUMERICHOST | ++ NI_NUMERICSERV); ++ carp("$self sockname=$addr|$port|$family") if $LOG > 7; ++ return wantarray ? ($port, $addr, $family) ++ : "$addr|$port|$family"; + } + return wantarray ? () : undef; + } +@@ -772,10 +756,13 @@ + my $sock = $self->handle; + + if (defined($sock)) { +- my($port, $a) = sockaddr_in(getpeername($sock)); +- my $addr = join('.', unpack('C4', $a)); +-carp("$self sockpeer=$addr:$port") if $LOG > 7; +- return wantarray ? ($port, $addr) : "$addr:$port"; ++ my $sa = getpeername($sock); ++ my $family = (unpack('CC', $sa))[1]; ++ my ($addr, $port) = getnameinfo($sa, NI_NUMERICHOST | ++ NI_NUMERICSERV); ++ carp("$self sockpeer=$addr|$port|$family") if $LOG > 7; ++ return wantarray ? ($port, $addr, $family) ++ : "$addr|$port|$family"; + } + return wantarray ? () : undef; + } |