Skip to content

Commit e0e66c0

Browse files
Allow for custom Connector / DNS Resolver
Allow the user of the API to parse a custom Connector, so he can use it's own DNS Resolver. This is especially valid when working in a docker based environment, as docker uses it's own DNS server, so with the current solution, the names of the other docker container wont resolve
1 parent acda941 commit e0e66c0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Connection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ class Connection extends EventEmitter
4747
*/
4848
public $parser;
4949

50-
public function __construct(LoopInterface $loop, array $connectOptions = array())
50+
public function __construct(LoopInterface $loop, array $connectOptions = array(), Connector $connector = null)
5151
{
5252
$this->loop = $loop;
53-
$resolver = (new \React\Dns\Resolver\Factory())->createCached('8.8.8.8', $loop);
54-
$this->connector = new Connector($loop, ['dns' => $resolver]);
53+
if (!$connector) {
54+
$connector = new Connector($loop, [
55+
'dns' => (new \React\Dns\Resolver\Factory())->createCached('8.8.8.8', $loop)
56+
]);
57+
}
58+
$this->connector = $connector;
5559
$this->executor = new Executor($this);
5660
$this->options = $connectOptions + $this->options;
5761
}

0 commit comments

Comments
 (0)