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
"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"
],
"provides" : {
"IO::Socket::IP" : {
"file" : "lib/IO/Socket/IP.pm",
- "version" : "0.26"
+ "version" : "0.27"
}
},
"release_status" : "stable",
"http://dev.perl.org/licenses/"
]
},
- "version" : "0.26"
+ "version" : "0.27"
}
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
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
-# 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
(
# $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;
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 ) {
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 ) {
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 {
[ 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
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 {
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 )
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" );
}
}
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 ) {
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(
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;