Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ public function connect($uri)

// append hostname from URI to query string unless explicitly given
if (!isset($args['hostname'])) {
$args['hostname'] = $parts['host'];
$args['hostname'] = $host;
}

// append query string
$socksUri .= '?' . http_build_query($args, '', '&');;
$socksUri .= '?' . http_build_query($args, '', '&');

// append fragment from URI if given
if (isset($parts['fragment'])) {
Expand Down
18 changes: 18 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,24 @@ public function testEmitSocks5DataInvalidAddressTypeWillRejectConnection()
$promise->then(null, $this->expectCallableOnceWithExceptionCode(SOCKET_EBADMSG));
}

public function testEmitSocks5DataIpv6AddressWillResolveConnection()
{
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('write', 'close'))->getMock();
$stream->expects($this->never())->method('close');

$promise = \React\Promise\resolve($stream);

$this->connector->expects($this->once())->method('connect')->with('127.0.0.1:1080?hostname=%3A%3A1')->willReturn($promise);

$this->client = new Client('socks5://127.0.0.1:1080', $this->connector);

$promise = $this->client->connect('[::1]:80');

$stream->emit('data', array("\x05\x00" . "\x05\x00\x00\x04" . inet_pton('::1') . "\x00\x50"));

$promise->then($this->expectCallableOnce());
}

public function testEmitSocks5DataHostnameAddressWillResolveConnection()
{
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('write', 'close'))->getMock();
Expand Down