Implement full support for IPv6.

Using IPv6 with Predis was basically impossible due to various inconsistencies
and bugs through the library, now it is supported by all the connection classes.

Following the standard for IPv6 literal addresses in URI strings, the IP literal
must be enclosed within square brackets when passing the parameters as a string:

  $parameters = 'tcp://[2001:db8:0:f101::1]:6379';

See https://tools.ietf.org/html/rfc3986#section-3.2.2 for further details.

This commit also fixes #239 making redis-cluster usable with nodes using IPv6.
This commit is contained in:
Daniele Alessandri
2015-07-29 18:00:38 +02:00
parent eeb1e8b7a7
commit 8aec51b34f
10 changed files with 162 additions and 72 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ class StreamConnection extends AbstractConnection
*/
protected function tcpStreamInitializer(ParametersInterface $parameters)
{
$uri = "tcp://{$parameters->host}:{$parameters->port}";
$uri = "tcp://[$parameters->host]:$parameters->port";
$flags = STREAM_CLIENT_CONNECT;
if (isset($parameters->async_connect) && (bool) $parameters->async_connect) {