Net-INET6Glue-0.602/0000755000175100017520000000000012266215311012437 5ustar workworkNet-INET6Glue-0.602/Changes0000644000175100017520000000122712266215307013741 0ustar workwork0.602 2014/01/17 - fix t/01_inet_is_inet6.t 0.601 2014/01/14 - add support for IO::Socket::IP instead of IO::Socket::INET6 and prefer it 0.600_1 2013/05/31 - set AUTHOR in Makefile.PL back from array to string, because array is only supported in newer ExtUtils::MakeMaker versions 0.6 2013/05/30 - add more meta information to Makefile.PL, based on patch from ktdreyer 0.5 2011/02/25 - fix for IO::Socket::INET6 >=2.67 0.4 2010/02/16 - fix EPRT in Net::INET6Glue::FTP so that it can also be used with IPv4 (when eprt is explicitly called) 0.3 2009/01/17 - make it work on perl5.10.0 0.2 2008/12/27 - ftp test, small fixes 0.1 2008/12/27 - initial relase Net-INET6Glue-0.602/COPYRIGHT0000644000175100017520000000030311125253352013726 0ustar workworkThese modules are copyright (c) 2008, Steffen Ullrich. All Rights Reserved. These modules are free software. They may be used, redistributed and/or modified under the same terms as Perl itself. Net-INET6Glue-0.602/Makefile.PL0000644000175100017520000000224112265205273014415 0ustar workworkuse ExtUtils::MakeMaker 6.46; require 5.008; my $xt = prompt( "Should I do external tests?\n". "These tests will fail if there is no internet connection or if a firewall\n". "blocks active or passive IPv6 FTP traffic.\n". "[y/N]", 'n' ); my %INET6 = ( 'IO::Socket::IP' => 0.25 ); if ( ! eval "require IO::Socket::IP" || $IO::Socket::IP::VERSION < 0.25 and eval "require IO::Socket::INET6" and $IO::Socket::INET6::VERSION >= 2.54 ) { %INET6 = ( 'IO::Socket::INET6' => 2.54 ); warn "using IO::Socket::INET6 instead of IO::Socket::IP\n"; } WriteMakefile( NAME => 'Net::INET6Glue', AUTHOR => "Steffen Ullrich ", LICENSE => 'perl', VERSION_FROM => 'lib/Net/INET6Glue.pm', PREREQ_PM => { %INET6, 'Net::FTP' => 2.75, }, META_MERGE => { resources => { license => 'http://dev.perl.org/licenses/', homepage => 'https://github.com/noxxi/p5-net-inet6glue', bugtracker => 'https://rt.cpan.org/Dist/Display.html?Queue=Net-INET6Glue', repository => 'https://github.com/noxxi/p5-net-inet6glue', }, }, $xt =~m{^y}i ? ( test => { TESTS => 't/*.t t/external/*.t' }):(), ); Net-INET6Glue-0.602/README0000644000175100017520000000036511134447203013323 0ustar workworkNet::INET6Glue is a hack to make more of Perl IPv6 able. This is partly done by replacing IO::Socket::INET with IO::Socket::INET6 and by adding IPv6 Protocol functionality to Net::FTP. Works for Net::SMTP, LWP, Net::FTP and probably others too. Net-INET6Glue-0.602/MANIFEST0000644000175100017520000000041012266215311013563 0ustar workworkCOPYRIGHT lib/Net/INET6Glue.pm lib/Net/INET6Glue/FTP.pm lib/Net/INET6Glue/INET_is_INET6.pm Makefile.PL MANIFEST Changes README t/01_inet_is_inet6.t t/02_ftp_load.t t/external/03_ftp6.t META.yml Module meta-data (added by MakeMaker) Net-INET6Glue-0.602/lib/0000755000175100017520000000000012266215311013205 5ustar workworkNet-INET6Glue-0.602/lib/Net/0000755000175100017520000000000012266215311013733 5ustar workworkNet-INET6Glue-0.602/lib/Net/INET6Glue.pm0000644000175100017520000000304112266215244015736 0ustar workworkpackage Net::INET6Glue; $VERSION = "0.602"; use Net::INET6Glue::INET_is_INET6; use Net::INET6Glue::FTP; 1; =head1 NAME Net::INET6Glue - Make common modules IPv6 ready by hotpatching =head1 SYNOPSIS use Net::INET6Glue; # include all glue use LWP; use Net::SMTP; use Net::FTP; .. =head1 DESCRIPTION L is a collection of modules to make common modules IPv6 ready by hotpatching them. Unfortunatly the current state of IPv6 support in perl is that no IPv6 support is in the core and that a lot of important modules (like L, L, L,...) do not support IPv6 even if the modules for IPv6 sockets like L, L or L are available. This module tries to mitigate this by hotpatching. Currently the following submodules are available: =over 4 =item L Makes L behave like L (with fallback to like L), especially make it capable to create IPv6 sockets. This makes L, L and others IPv6 capable. =item L Hotpatches L to support EPRT and EPSV commands which are needed to deal with FTP over IPv6. Also loads L. =back =head1 COPYRIGHT This module and the modules in the Net::INET6Glue Hierarchy distributed together with this module are copyright (c) 2008..2014, Steffen Ullrich. All Rights Reserved. These modules are free software. They may be used, redistributed and/or modified under the same terms as Perl itself. Net-INET6Glue-0.602/lib/Net/INET6Glue/0000755000175100017520000000000012266215311015375 5ustar workworkNet-INET6Glue-0.602/lib/Net/INET6Glue/FTP.pm0000644000175100017520000000742012265205273016374 0ustar workworkuse strict; use warnings; package Net::INET6Glue::FTP; our $VERSION = 0.5; ############################################################################ # implement EPRT, EPSV for Net::FTP to support IPv6 ############################################################################ use Net::INET6Glue::INET_is_INET6; use Net::FTP; # tested with version 2.77 BEGIN { $Net::FTP::VERSION eq '2.77' or warn "Not tested with Net::FTP version $Net::FTP::VERSION"; } use Socket; use Carp 'croak'; if ( defined &Net::FTP::_EPRT ) { # Net::SSLGlue::FTP implements IPv6 too warn "somebody else already implements FTP IPv6 support - skipping ". __PACKAGE__."\n"; } else { # implement EPRT *Net::FTP::_EPRT = sub { shift->command("EPRT", @_)->response() == Net::FTP::CMD_OK }; *Net::FTP::eprt = sub { @_ == 1 || @_ == 2 or croak 'usage: $ftp->eprt([PORT])'; my ($ftp,$port) = @_; delete ${*$ftp}{net_ftp_intern_port}; unless ($port) { my $listen = ${*$ftp}{net_ftp_listen} ||= $Net::INET6Glue::INET_is_INET6::INET6CLASS->new( Listen => 1, Timeout => $ftp->timeout, LocalAddr => $ftp->sockhost, ); ${*$ftp}{net_ftp_intern_port} = 1; my $fam = ($listen->sockdomain == AF_INET) ? 1:2; $port = "|$fam|".$listen->sockhost."|".$listen->sockport."|"; } my $ok = $ftp->_EPRT($port); ${*$ftp}{net_ftp_port} = $port if $ok; return $ok; }; # implement EPSV *Net::FTP::_EPSV = sub { shift->command("EPSV", @_)->response() == Net::FTP::CMD_OK }; *Net::FTP::epsv = sub { my $ftp = shift; @_ and croak 'usage: $ftp->epsv()'; delete ${*$ftp}{net_ftp_intern_port}; $ftp->_EPSV && $ftp->message =~ m{\(([\x33-\x7e])\1\1(\d+)\1\)} ? ${*$ftp}{'net_ftp_pasv'} = $2 : undef; }; # redefine PORT and PASV so that they use EPRT and EPSV if necessary no warnings 'redefine'; my $old_port = \&Net::FTP::port; *Net::FTP::port =sub { goto &$old_port if $_[0]->sockdomain == AF_INET or @_<1 or @_>2; goto &Net::FTP::eprt; }; my $old_pasv = \&Net::FTP::pasv; *Net::FTP::pasv = sub { goto &$old_pasv if $_[0]->sockdomain == AF_INET or @_<1 or @_>2; goto &Net::FTP::epsv; }; # redefined _dataconn to make use of the data it got from EPSV # copied and adapted from Net::FTP::_dataconn my $old_dataconn = \&Net::FTP::_dataconn; *Net::FTP::_dataconn = sub { goto &$old_dataconn if $_[0]->sockdomain == AF_INET; my $ftp = shift; my $pkg = "Net::FTP::" . $ftp->type; eval "require $pkg"; $pkg =~ s/ /_/g; delete ${*$ftp}{net_ftp_dataconn}; my $data; if ( my $port = ${*$ftp}{net_ftp_pasv} ) { $data = $pkg->new( PeerAddr => $ftp->peerhost, PeerPort => $port, LocalAddr => ${*$ftp}{net_ftp_localaddr}, ); } elsif (my $listen = delete ${*$ftp}{net_ftp_listen}) { $data = $listen->accept($pkg); close($listen); } return if ! $data; $data->timeout($ftp->timeout); ${*$ftp}{net_ftp_dataconn} = $data; ${*$data} = ""; ${*$data}{net_ftp_cmd} = $ftp; ${*$data}{net_ftp_blksize} = ${*$ftp}{net_ftp_blksize}; return $data; }; } 1; =head1 NAME Net::INET6Glue::FTP - adds IPv6 support to L by hotpatching =head1 SYNOPSIS use Net::INET6Glue::FTP; use Net::FTP; my $ftp = Net::FTP->new( '::1' ); $ftp->login(...) =head1 DESCRIPTION This module adds support for IPv6 by hotpatching support for EPRT and EPSV commands into L and hotpatching B, B and B<_dataconn> methods to make use of EPRT and EPSV on IPv6 connections. It also includes L to make the L sockets IPv6 capable. =head1 COPYRIGHT This module is copyright (c) 2008..2014, Steffen Ullrich. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Net-INET6Glue-0.602/lib/Net/INET6Glue/INET_is_INET6.pm0000644000175100017520000000471612265205273020107 0ustar workworkuse strict; use warnings; package Net::INET6Glue::INET_is_INET6; our $VERSION = 0.6; ############################################################################ # copy IO::Socket::INET to IO::Socket::INET4 # copy IO::Socket::(IP|INET6) to IO::Socket::INET ############################################################################ use IO::Socket::INET; our $INET6CLASS; $INC{'IO/Socket/INET4.pm'} = $INC{'IO/Socket/INET.pm'}; if ( eval "require IO::Socket::IP" && $IO::Socket::IP::VERSION >= 0.25 ) { $INC{'IO/Socket/INET.pm'} = $INC{'IO/Socket/IP.pm'}; $INET6CLASS = 'IO::Socket::IP'; } elsif ( eval "require IO::Socket::INET6" && $IO::Socket::INET6::VERSION >= 2.54 ) { $INC{'IO/Socket/INET.pm'} = $INC{'IO/Socket/INET6.pm'}; $INET6CLASS = 'IO::Socket::INET6'; } else { die "failed to load IO::Socket::IP or IO::Socket::INET6: $@" } { # copy subs no strict 'refs'; no warnings 'redefine'; for ( keys %{IO::Socket::INET::} ) { ref(my $v = $IO::Socket::INET::{$_}) and next; *{'IO::Socket::INET4::'.$_} = \&{ "IO::Socket::INET::$_" } if *{$v}{CODE}; } for ( keys %{"$INET6CLASS\::"} ) { eval { *{${"$INET6CLASS\::"}{$_}} && *{${"$INET6CLASS\::"}{$_}}{CODE} } or next; *{'IO::Socket::INET::'.$_} = \&{ "$INET6CLASS\::$_" }; } } 1; =head1 NAME Net::INET6Glue::INET_is_INET6 - make L behave like L =head1 SYNOPSIS use Net::INET6Glue::INET_is_INET6; use LWP::Simple; print get( 'http://[::1]:80' ); print get( 'http://ipv6.google.com' ); =head1 DESCRIPTION Many modules directly create L sockets or have it as a superclass. Because L has no support for IPv6 these modules don't have it either. This module tries to make L behave like L (with fallback to L) by copying the symbol table from L into L. The original symbol table from L is still available in L. This strategy works for L, L and probably a lot of other modules too, which don't try to depend too much on the innards of L or on the text representation of IP addresses (IPv6 addresses look different than IPv4 addresses). =head1 COPYRIGHT This module is copyright (c) 2008..2014, Steffen Ullrich. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Net-INET6Glue-0.602/t/0000755000175100017520000000000012266215311012702 5ustar workworkNet-INET6Glue-0.602/t/01_inet_is_inet6.t0000644000175100017520000000152312266215156016136 0ustar workworkuse strict; use warnings; use IO::Socket::INET; use Net::INET6Glue::INET_is_INET6; # check if we can use ::1, e.g if the computer has IPv6 enabled my $l6; for my $ioclass (qw(IO::Socket::IP IO::Socket::INET6)) { eval "require $ioclass" or next; $l6 = $ioclass->new( Listen => 1, LocalAddr => '::1'); if ( ! $l6 ) { print "1..0 # no IPv6 enabled on this computer\n"; exit } last; } # IPv4 should be still available in the next years my $l4 = IO::Socket::INET->new( Listen => 1, LocalAddr => '127.0.0.1' ); if ( ! $l4 ) { print "1..0 # no IPv4 on this computer\n"; exit } print "1..2\n"; my $cl4 = IO::Socket::INET->new( '127.0.0.1:'.$l4->sockport ); print ( $cl4 ? "ok\n" : "not ok # connect IPv4\n" ); my $cl6 = IO::Socket::INET->new( '[::1]:'.$l6->sockport ); print ( $cl6 ? "ok\n" : "not ok # connect IPv6: $!\n" ); Net-INET6Glue-0.602/t/02_ftp_load.t0000644000175100017520000000016411125511445015161 0ustar workworkuse strict; use warnings 'FATAL'; print "1..1\n"; eval "use Net::INET6Glue::FTP"; print $@ ? "not ok # $@\n":"ok\n" Net-INET6Glue-0.602/t/external/0000755000175100017520000000000012266215311014524 5ustar workworkNet-INET6Glue-0.602/t/external/03_ftp6.t0000644000175100017520000000125012265205273016075 0ustar workworkuse strict; use Net::INET6Glue::FTP; use Net::FTP; # check if we can reach ftp6.netbsd.org $Net::INET6Glue::INET_is_INET6::INET6CLASS->new( 'ftp6.netbsd.org:21' ) or do { print "1..0 # ftp6.netbsd.org not reachable\n"; exit }; print "1..6\n"; for my $pasv ( 0,1 ) { if ( my $ftp = Net::FTP->new( 'ftp6.netbsd.org', Passive => $pasv )) { print "ok # connect\n"; print $ftp->login( 'ftp','cpantest@example.com' ) ? "ok # login\n" : "not ok # login\n"; my @files = $ftp->ls; print @files > 0 ? "ok # ls pasv=$pasv\n" : "not ok # no files in ls pasv=$pasv\n"; } else { print "not ok # connect passive=$pasv failed\n" for (1..3); } } Net-INET6Glue-0.602/META.yml0000644000175100017520000000144712266215311013716 0ustar workwork--- #YAML:1.0 name: Net-INET6Glue version: 0.602 abstract: ~ author: - Steffen Ullrich license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: IO::Socket::INET6: 2.54 Net::FTP: 2.75 resources: bugtracker: https://rt.cpan.org/Dist/Display.html?Queue=Net-INET6Glue homepage: https://github.com/noxxi/p5-net-inet6glue license: http://dev.perl.org/licenses/ repository: https://github.com/noxxi/p5-net-inet6glue no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.57_05 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4