Support for IPv6 in redis 2.8, updated tests to 2.8, make it work also on an IPv6-only host #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that redis server 2.8 finally supports IPv6, some updates are needed on the client side too. The old IO::Socket::INET perl module does not support IPv6, but there are two Perl CPAN socket modules that do support both protocol families: an oldish IO::Socket::INET6, and a modern and actively maintained IO::Socket::IP.
The proposed change to Redis.pm choses one of the available IO::Socket::* modules and updates $self->{server} to an arrayref of IP or Unix socket specifications to be tried in order, the first one that succeeds will be used.
The list is needed to choose a suitable default IP server specification, as it is not known in advance on which protocol family the server listens on a loopback interface (e.g. on an IPv6-only host the loopback interface does not have address 127.0.0.1, only the ::1 ). Once we settle for a list for a choice of servers, it can be handy to let a caller specify alternative server choices too.
The change also updates several tests, as the 2.8 redis server has changed some error types or error strings.
The SpawnRedisServer.pm is modified to let it chose between 127.0.0.1 and ::1 for the test server based on availability of protocol families support. This makes it possible for tests to auto-detect an IPv6-only or IPv4-only or dual-stack host. It may appear that using 'localhost' instead of testing IP addresses would be a cleaner solution, but that only works in a 'bind' config of a 2.8 server, and the older IO::Socket::INET6 module does not try multiple IP addresses resolved from 'localhost', so hard-coded IP addresses seem to be the more reliable choice.