Skip to content

Commit 23a1e62

Browse files
authored
Merge pull request #160 from clue-labs/skip-dns
Simplify skipping DNS lookup when connecting to IP addresses
2 parents d395731 + df02c39 commit 23a1e62

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/DnsConnector.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public function connect($uri)
3535
$host = trim($parts['host'], '[]');
3636
$connector = $this->connector;
3737

38+
// skip DNS lookup / URI manipulation if this URI already contains an IP
39+
if (false !== filter_var($host, FILTER_VALIDATE_IP)) {
40+
return $connector->connect($uri);
41+
}
42+
3843
return $this
3944
->resolveHostname($host)
4045
->then(function ($ip) use ($connector, $host, $parts) {
@@ -86,10 +91,6 @@ public function connect($uri)
8691

8792
private function resolveHostname($host)
8893
{
89-
if (false !== filter_var($host, FILTER_VALIDATE_IP)) {
90-
return Promise\resolve($host);
91-
}
92-
9394
$promise = $this->resolver->resolve($host);
9495

9596
return new Promise\Promise(

0 commit comments

Comments
 (0)