Fix public hostname DNS resolution in Swoole

This commit is contained in:
Chirag Aggarwal committed 2026-05-30 11:04:32 +05:30
1 parent 5a8947e3d8
commit 41660819e7
1 file changed
+8 -4
@@ -117,19 +117,23 @@ class PublicHostname extends Validator
*/
public static function resolve(string $hostname): array
{
$ipv4 = @\gethostbynamel($hostname) ?: [];
$ipv4 = [];
$ipv6 = [];
$records = @\dns_get_record($hostname, DNS_AAAA);
$records = @\dns_get_record($hostname, DNS_A | DNS_AAAA);
if (\is_array($records)) {
foreach ($records as $record) {
if (!empty($record['ip'])) {
$ipv4[] = $record['ip'];
}
if (!empty($record['ipv6'])) {
$ipv6[] = $record['ipv6'];
}
}
}
return \array_values(\array_unique(\array_merge($ipv4, $ipv6)));
return \array_values(\array_unique([...$ipv4, ...$ipv6]));
}
/**