Upgrade IO::Socket::IP to version 0.27
authorTom Hukins <tom@eborcom.com>
Tue, 21 Jan 2014 19:48:09 +0000 (19:48 +0000)
committerTony Cook <tony@develop-help.com>
Tue, 4 Feb 2014 21:41:04 +0000 (08:41 +1100)
cpan/IO-Socket-IP/Changes
cpan/IO-Socket-IP/META.json
cpan/IO-Socket-IP/META.yml
cpan/IO-Socket-IP/Makefile.PL
cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
cpan/IO-Socket-IP/t/01local-client-v4.t
cpan/IO-Socket-IP/t/02local-server-v4.t
cpan/IO-Socket-IP/t/04local-client-v6.t
cpan/IO-Socket-IP/t/05local-server-v6.t
cpan/IO-Socket-IP/t/30nonblocking-connect.t
cpan/IO-Socket-IP/t/31nonblocking-connect-internet.t

index 4c7842a..7f2624e 100644 (file)
@@ -1,5 +1,12 @@
 Revision history for IO-Socket-IP
 
+0.27    2014/01/20 18:08:31
+        [BUGFIXES]
+         * Apply a short timeout to unit tests that probe for internet
+           connectivity, in case of bad firewalls, etc... (Perl RT121037)
+         * Defend against machines with IN6ADDR_LOOPBACK not being "::1" in
+           unit tests, similar to the INADDR_LOOPBACK case (RT92295)
+
 0.26    2014/01/16 12:20:02
         [CHANGES]
          * Set $VERSION in BEGIN block before 'use base' so that
index 4cbc5c9..2bc1290 100644 (file)
@@ -4,7 +4,7 @@
       "Paul Evans <leonerd@leonerd.org.uk>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "Module::Build version 0.4202",
+   "generated_by" : "Module::Build version 0.4203",
    "license" : [
       "perl_5"
    ],
@@ -29,7 +29,7 @@
    "provides" : {
       "IO::Socket::IP" : {
          "file" : "lib/IO/Socket/IP.pm",
-         "version" : "0.26"
+         "version" : "0.27"
       }
    },
    "release_status" : "stable",
@@ -38,5 +38,5 @@
          "http://dev.perl.org/licenses/"
       ]
    },
-   "version" : "0.26"
+   "version" : "0.27"
 }
index 481427b..7aa66ba 100644 (file)
@@ -5,7 +5,7 @@ author:
 build_requires:
   Test::More: 0.88
 dynamic_config: 1
-generated_by: 'Module::Build version 0.4202, CPAN::Meta::Converter version 2.133380'
+generated_by: 'Module::Build version 0.4203, CPAN::Meta::Converter version 2.133380'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -14,10 +14,10 @@ name: IO-Socket-IP
 provides:
   IO::Socket::IP:
     file: lib/IO/Socket/IP.pm
-    version: 0.26
+    version: 0.27
 requires:
   IO::Socket: 0
   Socket: 1.97
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.26
+version: 0.27
index 7547ce3..ba9c840 100644 (file)
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.4202
+# Note: this file was auto-generated by Module::Build::Compat version 0.4203
 use ExtUtils::MakeMaker;
 WriteMakefile
 (
index e8d3a20..11ecf3b 100644 (file)
@@ -7,7 +7,7 @@ package IO::Socket::IP;
 # $VERSION needs to be set before  use base 'IO::Socket'
 #  - https://rt.cpan.org/Ticket/Display.html?id=92107
 BEGIN {
-   $VERSION = '0.26';
+   $VERSION = '0.27';
 }
 
 use strict;
index 99b232b..9a7a94d 100644 (file)
@@ -8,13 +8,14 @@ use Test::More;
 use IO::Socket::IP;
 
 use IO::Socket::INET;
-use Socket qw( inet_ntoa unpack_sockaddr_in );
+use Socket qw( inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in );
 
 # Some odd locations like BSD jails might not like INADDR_LOOPBACK. We'll
 # establish a baseline first to test against
 my $INADDR_LOOPBACK = do {
-   my $localsock = IO::Socket::INET->new( LocalAddr => "localhost", Listen => 1 );
-   $localsock->sockaddr;
+   socket my $sockh, PF_INET, SOCK_STREAM, 0 or die "Cannot socket(PF_INET) - $!";
+   bind $sockh, pack_sockaddr_in( 0, inet_aton( "127.0.0.1" ) ) or die "Cannot bind() - $!";
+   ( unpack_sockaddr_in( getsockname $sockh ) )[1];
 };
 my $INADDR_LOOPBACK_HOST = inet_ntoa( $INADDR_LOOPBACK );
 if( $INADDR_LOOPBACK ne INADDR_LOOPBACK ) {
index 5ce757d..d1f2b40 100644 (file)
@@ -8,13 +8,14 @@ use Test::More;
 use IO::Socket::IP;
 
 use IO::Socket::INET;
-use Socket qw( inet_ntoa unpack_sockaddr_in );
+use Socket qw( inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in );
 
 # Some odd locations like BSD jails might not like INADDR_LOOPBACK. We'll
 # establish a baseline first to test against
 my $INADDR_LOOPBACK = do {
-   my $localsock = IO::Socket::INET->new( LocalAddr => "localhost", Listen => 1 );
-   $localsock->sockaddr;
+   socket my $sockh, PF_INET, SOCK_STREAM, 0 or die "Cannot socket(PF_INET) - $!";
+   bind $sockh, pack_sockaddr_in( 0, inet_aton( "127.0.0.1" ) ) or die "Cannot bind() - $!";
+   ( unpack_sockaddr_in( getsockname $sockh ) )[1];
 };
 my $INADDR_LOOPBACK_HOST = inet_ntoa( $INADDR_LOOPBACK );
 if( $INADDR_LOOPBACK ne INADDR_LOOPBACK ) {
index 6932d4d..5c55367 100644 (file)
@@ -6,13 +6,23 @@ use warnings;
 use Test::More;
 
 use IO::Socket::IP;
-use Socket;
+use Socket qw( inet_pton inet_ntop pack_sockaddr_in6 unpack_sockaddr_in6 IN6ADDR_LOOPBACK );
 
-my $AF_INET6 = eval { require Socket and Socket::AF_INET6() } or
+my $AF_INET6 = eval { Socket::AF_INET6() } or
    plan skip_all => "No AF_INET6";
 
-eval { IO::Socket::IP->new( LocalHost => "::1" ) } or
-   plan skip_all => "Unable to bind to ::1";
+# Some odd locations like BSD jails might not like IN6ADDR_LOOPBACK. We'll
+# establish a baseline first to test against
+my $IN6ADDR_LOOPBACK = eval {
+   socket my $sockh, Socket::PF_INET6(), SOCK_STREAM, 0 or die "Cannot socket(PF_INET6) - $!";
+   bind $sockh, pack_sockaddr_in6( 0, inet_pton( $AF_INET6, "::1" ) ) or die "Cannot bind() - $!";
+   ( unpack_sockaddr_in6( getsockname $sockh ) )[1];
+} or plan skip_all => "Unable to bind to ::1 - $@";
+my $IN6ADDR_LOOPBACK_HOST = inet_ntop( $AF_INET6, $IN6ADDR_LOOPBACK );
+if( $IN6ADDR_LOOPBACK ne IN6ADDR_LOOPBACK ) {
+   diag( "Testing with IN6ADDR_LOOPBACK=$IN6ADDR_LOOPBACK_HOST; this may be because of odd networking" );
+}
+my $IN6ADDR_LOOPBACK_HEX = unpack "H*", $IN6ADDR_LOOPBACK;
 
 # Unpack just ip6_addr and port because other fields might not match end to end
 sub unpack_sockaddr_in6_addrport { 
@@ -63,14 +73,14 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
               [ unpack_sockaddr_in6_addrport( $testclient->sockname ) ],
               "\$socket->peername for $socktype" );
 
-   is( $socket->peerhost, "::1",     "\$socket->peerhost for $socktype" );
-   is( $socket->peerport, $testport, "\$socket->peerport for $socktype" );
+   is( $socket->peerhost, $IN6ADDR_LOOPBACK_HOST, "\$socket->peerhost for $socktype" );
+   is( $socket->peerport, $testport,              "\$socket->peerport for $socktype" );
 
    # Unpack just so it pretty prints without wrecking the terminal if it fails
-   is( unpack("H*", $socket->peeraddr), "0000"x7 . "0001", "\$socket->peeraddr for $socktype" );
+   is( unpack("H*", $socket->peeraddr), $IN6ADDR_LOOPBACK_HEX, "\$testclient->peeraddr for $socktype" );
    if( $socktype eq "SOCK_STREAM" ) {
       # Some OSes don't update sockaddr with a local bind() on SOCK_DGRAM sockets
-      is( unpack("H*", $socket->sockaddr), "0000"x7 . "0001", "\$socket->sockaddr for $socktype" );
+      is( unpack("H*", $socket->sockaddr), $IN6ADDR_LOOPBACK_HEX, "\$testclient->sockaddr for $socktype" );
    }
 
    # Can't easily test the non-numeric versions without relying on the system's
index cadc9b7..2be2683 100644 (file)
@@ -6,13 +6,23 @@ use warnings;
 use Test::More;
 
 use IO::Socket::IP;
-use Socket;
+use Socket qw( inet_pton inet_ntop pack_sockaddr_in6 unpack_sockaddr_in6 IN6ADDR_LOOPBACK );
 
-my $AF_INET6 = eval { require Socket and Socket::AF_INET6() } or
+my $AF_INET6 = eval { Socket::AF_INET6() } or
    plan skip_all => "No AF_INET6";
 
-eval { IO::Socket::IP->new( LocalHost => "::1" ) } or
-   plan skip_all => "Unable to bind to ::1";
+# Some odd locations like BSD jails might not like IN6ADDR_LOOPBACK. We'll
+# establish a baseline first to test against
+my $IN6ADDR_LOOPBACK = eval {
+   socket my $sockh, Socket::PF_INET6(), SOCK_STREAM, 0 or die "Cannot socket(PF_INET6) - $!";
+   bind $sockh, pack_sockaddr_in6( 0, inet_pton( $AF_INET6, "::1" ) ) or die "Cannot bind() - $!";
+   ( unpack_sockaddr_in6( getsockname $sockh ) )[1];
+} or plan skip_all => "Unable to bind to ::1 - $@";
+my $IN6ADDR_LOOPBACK_HOST = inet_ntop( $AF_INET6, $IN6ADDR_LOOPBACK );
+if( $IN6ADDR_LOOPBACK ne IN6ADDR_LOOPBACK ) {
+   diag( "Testing with IN6ADDR_LOOPBACK=$IN6ADDR_LOOPBACK_HOST; this may be because of odd networking" );
+}
+my $IN6ADDR_LOOPBACK_HEX = unpack "H*", $IN6ADDR_LOOPBACK;
 
 # Unpack just ip6_addr and port because other fields might not match end to end
 sub unpack_sockaddr_in6_addrport { 
@@ -32,8 +42,8 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
    is( $testserver->sockdomain, $AF_INET6,         "\$testserver->sockdomain for $socktype" );
    is( $testserver->socktype,   Socket->$socktype, "\$testserver->socktype for $socktype" );
 
-   is( $testserver->sockhost, "::1",       "\$testserver->sockhost for $socktype" );
-   like( $testserver->sockport, qr/^\d+$/, "\$testserver->sockport for $socktype" );
+   is( $testserver->sockhost, $IN6ADDR_LOOPBACK_HOST, "\$testserver->sockhost for $socktype" );
+   like( $testserver->sockport, qr/^\d+$/,            "\$testserver->sockport for $socktype" );
 
    my $socket = IO::Socket->new;
    $socket->socket( $AF_INET6, Socket->$socktype, 0 )
@@ -69,10 +79,10 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
    is( $testclient->peerport, $sockport, "\$testclient->peerport for $socktype" );
 
    # Unpack just so it pretty prints without wrecking the terminal if it fails
-   is( unpack("H*", $testclient->peeraddr), "0000"x7 . "0001", "\$testclient->peeraddr for $socktype" );
+   is( unpack("H*", $testclient->peeraddr), $IN6ADDR_LOOPBACK_HEX, "\$testclient->peeraddr for $socktype" );
    if( $socktype eq "SOCK_STREAM" ) {
       # Some OSes don't update sockaddr with a local bind() on SOCK_DGRAM sockets
-      is( unpack("H*", $testclient->sockaddr), "0000"x7 . "0001", "\$testclient->sockaddr for $socktype" );
+      is( unpack("H*", $testclient->sockaddr), $IN6ADDR_LOOPBACK_HEX, "\$testclient->sockaddr for $socktype" );
    }
 }
 
index 5ac32d2..518bd2e 100644 (file)
@@ -8,13 +8,15 @@ use Test::More;
 use IO::Socket::IP;
 
 use IO::Socket::INET;
+use Socket qw( inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in );
 use Errno qw( EINPROGRESS EWOULDBLOCK );
 
 # Some odd locations like BSD jails might not like INADDR_LOOPBACK. We'll
 # establish a baseline first to test against
 my $INADDR_LOOPBACK = do {
-   my $localsock = IO::Socket::INET->new( LocalAddr => "localhost", Listen => 1 );
-   $localsock->sockaddr;
+   socket my $sockh, PF_INET, SOCK_STREAM, 0 or die "Cannot socket(PF_INET) - $!";
+   bind $sockh, pack_sockaddr_in( 0, inet_aton( "127.0.0.1" ) ) or die "Cannot bind() - $!";
+   ( unpack_sockaddr_in( getsockname $sockh ) )[1];
 };
 my $INADDR_LOOPBACK_HOST = inet_ntoa( $INADDR_LOOPBACK );
 if( $INADDR_LOOPBACK ne INADDR_LOOPBACK ) {
index b236205..8dc3ca0 100644 (file)
@@ -20,6 +20,7 @@ SKIP: {
       PeerHost => $test_host,
       PeerPort => $test_good_port,
       Type     => SOCK_STREAM,
+      Timeout  => 3,
    ) or skip "Can't connect to $test_host:$test_good_port", 5;
 
    my $socket = IO::Socket::IP->new(
@@ -57,6 +58,7 @@ SKIP: {
       PeerHost => $test_host,
       PeerPort => $test_bad_port,
       Type     => SOCK_STREAM,
+      Timeout  => 3,
    ) and skip "Connecting to $test_host:$test_bad_port succeeds", 4;
    $! == ECONNREFUSED or skip "Connecting to $test_host:$test_bad_port doesn't give ECONNREFUSED", 4;