about summary refs log tree commit
path: root/lib/Net/FTP.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net/FTP.pm')
-rw-r--r--lib/Net/FTP.pm35
1 files changed, 28 insertions, 7 deletions
diff --git a/lib/Net/FTP.pm b/lib/Net/FTP.pm
index 699998e..2a820aa 100644
--- a/lib/Net/FTP.pm
+++ b/lib/Net/FTP.pm
@@ -28,6 +28,7 @@ use Time::Local;
 our $VERSION = '3.07';
 
 our $IOCLASS;
+my $family_key;
 BEGIN {
   # Code for detecting if we can use SSL
   my $ssl_class = eval {
@@ -55,6 +56,10 @@ BEGIN {
   sub can_inet6 { $inet6_class };
 
   $IOCLASS = $ssl_class || $inet6_class || 'IO::Socket::INET';
+  $family_key =
+    ( $ssl_class ? $ssl_class->can_ipv6 : $inet6_class || '' )
+      eq 'IO::Socket::IP'
+      ? 'Family' : 'Domain';
 }
 
 our @ISA = ('Exporter','Net::Cmd',$IOCLASS);
@@ -120,6 +125,7 @@ sub new {
     PeerAddr  => $peer,
     PeerPort  => $arg{Port} || ($arg{SSL} ? 'ftps(990)' : 'ftp(21)'),
     LocalAddr => $arg{'LocalAddr'},
+    $family_key => $arg{Domain} || $arg{Family},
     Proto     => 'tcp',
     Timeout   => defined $arg{Timeout} ? $arg{Timeout} : 120,
     %tlsargs,
@@ -131,6 +137,7 @@ sub new {
   ${*$ftp}{'net_ftp_blksize'} = abs($arg{'BlockSize'} || 10240);
 
   ${*$ftp}{'net_ftp_localaddr'} = $arg{'LocalAddr'};
+  ${*$ftp}{'net_ftp_family'} = $arg{Domain} || $arg{Family};
 
   ${*$ftp}{'net_ftp_firewall'} = $fire
     if (defined $fire);
@@ -889,6 +896,7 @@ sub _eprt {
       Listen    => 1,
       Timeout   => $ftp->timeout,
       LocalAddr => $ftp->sockhost,
+      $family_key  => $ftp->sockdomain,
       can_ssl() ? (
         %{ ${*$ftp}{net_ftp_tlsargs} },
         SSL_startHandshake => 0,
@@ -1035,6 +1043,7 @@ sub _dataconn {
       PeerAddr  => $pasv->[0],
       PeerPort  => $pasv->[1],
       LocalAddr => ${*$ftp}{net_ftp_localaddr},
+      $family_key => ${*$ftp}{net_ftp_domain},
       Timeout   => $ftp->timeout,
       can_ssl() ? (
         SSL_startHandshake => 0,
@@ -1435,10 +1444,15 @@ Net::FTP - FTP Client class
 =head1 DESCRIPTION
 
 C<Net::FTP> is a class implementing a simple FTP client in Perl as
-described in RFC959.  It provides wrappers for a subset of the RFC959
-commands.
+described in RFC959.  It provides wrappers for the commonly used subset of the
+RFC959 commands.
+If L<IO::Socket::IP> or L<IO::Socket::INET6> is installed it also provides
+support for IPv6 as defined in RFC2428.
+And with L<IO::Socket::SSL> installed it provides support for implicit FTPS
+and explicit FTPS as defined in RFC4217.
 
-The Net::FTP class is a subclass of Net::Cmd and IO::Socket::INET.
+The Net::FTP class is a subclass of Net::Cmd and (depending on avaibility) of
+IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET.
 
 =head1 OVERVIEW
 
@@ -1539,8 +1553,15 @@ simply invokes the C<hash()> method for you, so that hash marks
 are displayed for all transfers.  You can, of course, call C<hash()>
 explicitly whenever you'd like.
 
-B<LocalAddr> - Local address to use for all socket connections, this
-argument will be passed to L<IO::Socket::INET>
+B<LocalAddr> - Local address to use for all socket connections. This
+argument will be passed to the super class, i.e. L<IO::Socket::INET>
+or L<IO::Socket::IP>.
+
+B<Domain> - Domain to use, i.e. AF_INET or AF_INET6. This
+argument will be passed to the IO::Socket super class.
+This can be used to enforce IPv4 even with L<IO::Socket::IP>
+which would default to IPv6.
+B<Family> is accepted as alternative name for B<Domain>.
 
 If the constructor fails undef will be returned and an error message will
 be in $@
@@ -1592,8 +1613,8 @@ Only C<LEVEL>s "C" (clear) and "P" (private) are supported.
 
 =item host ()
 
-Returns the value used by the constructor, and passed to IO::Socket::INET,
-to connect to the host.
+Returns the value used by the constructor, and passed to the IO::Socket super
+class to connect to the host.
 
 =item account( ACCT )