Skip to content

Commit

Permalink
Fix connection to IPv6 URIs (#45)
Browse files Browse the repository at this point in the history
Connections directly to IPv6 URIs failed previously, such as tcp://[2a03:2880:f02d:12:face:b00c:0:3]:443.

It was interpreted as a host name which then is not valid.
  • Loading branch information
brstgt authored and kelunik committed Nov 7, 2017
1 parent 71590e3 commit ef0d70d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/functions.php
Expand Up @@ -72,6 +72,10 @@ function connect(string $uri, ClientConnectContext $socketContext = null, Cancel

list($scheme, $host, $port) = Internal\parseUri($uri);

if ($host[0] === '[') {
$host = substr($host, 1, -1);
}

if ($port === 0 || @\inet_pton($host)) {
// Host is already an IP address or file path.
$uris = [$uri];
Expand Down

0 comments on commit ef0d70d

Please sign in to comment.