Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a732af

Browse filesBrowse files
committed
resolve IPv6 addresses with amphp/http-client 5
1 parent 54cd626 commit 3a732af
Copy full SHA for 3a732af

File tree

Expand file treeCollapse file tree

1 file changed

+18
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-4
lines changed

‎src/Symfony/Component/HttpClient/Internal/AmpResolverV5.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Internal/AmpResolverV5.php
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,33 @@ public function __construct(
3232

3333
public function resolve(string $name, ?int $typeRestriction = null, ?Cancellation $cancellation = null): array
3434
{
35-
if (!isset($this->dnsMap[$name]) || !\in_array($typeRestriction, [DnsRecord::A, null], true)) {
35+
$recordType = DnsRecord::A;
36+
$ip = $this->dnsMap[$name] ?? null;
37+
38+
if (null !== $ip && str_contains($ip, ':')) {
39+
$recordType = DnsRecord::AAAA;
40+
}
41+
42+
if (null === $ip || $recordType !== ($typeRestriction ?? $recordType)) {
3643
return Dns\resolve($name, $typeRestriction, $cancellation);
3744
}
3845

39-
return [new DnsRecord($this->dnsMap[$name], DnsRecord::A, null)];
46+
return [new DnsRecord($ip, $recordType, null)];
4047
}
4148

4249
public function query(string $name, int $type, ?Cancellation $cancellation = null): array
4350
{
44-
if (!isset($this->dnsMap[$name]) || DnsRecord::A !== $type) {
51+
$recordType = DnsRecord::A;
52+
$ip = $this->dnsMap[$name] ?? null;
53+
54+
if (null !== $ip && str_contains($ip, ':')) {
55+
$recordType = DnsRecord::AAAA;
56+
}
57+
58+
if (null !== $ip || $recordType !== $type) {
4559
return Dns\resolve($name, $type, $cancellation);
4660
}
4761

48-
return [new DnsRecord($this->dnsMap[$name], DnsRecord::A, null)];
62+
return [new DnsRecord($ip, $recordType, null)];
4963
}
5064
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.