Subject: | Should configure() return fail when MultiHomed enabled and there is no address where we can connect to? |
I have this test script
use strict;
use lib 'IO-Socket-INET6-2.72/lib/';
use IO::Socket::INET6;
my $sock = IO::Socket::INET6->new(PeerAddr => '127.0.0.1', PeerPort => 1, MultiHomed => 0)
or die $@;
warn "Connected successfully";
__END__
And it shows "IO::Socket::INET6: connect: Connection refused at t.pl line 5."
But if I'll change `MultiHomed' to 1 it will show: "Connected successfully at t.pl line 8."
In fact socket was not connected but constructor returns success. This is because there is no end of array of addresses check when `MultiHomed' is true.
So, after applying of the attached patch it will die at line 5 as expected
Subject: | multihomed-end-check.patch |
--- lib/IO/Socket/INET6.pm.orig 2015-01-07 23:19:11.163130587 +0600
+++ lib/IO/Socket/INET6.pm 2015-01-07 23:16:55.850469080 +0600
@@ -281,7 +281,7 @@
last if $sock->connect($rres);
return _error($sock, $!, $@ || "Timeout")
- if ! $arg->{MultiHomed};
+ if ! $arg->{MultiHomed} || $flr == $flr[-1];
}