Update SocketClient to support raw IP addresses

This commit is contained in:
Deon George 2024-05-21 21:07:11 +10:00
parent aaec5f8f4a
commit 72d68fa1ab

View File

@ -201,6 +201,12 @@ final class SocketClient {
$sort = collect(['AAAA','A']); $sort = collect(['AAAA','A']);
if (filter_var($address,FILTER_VALIDATE_IP))
$resolved = collect([[
(($x=filter_var($address,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 'ipv6' : 'ip')=>$address,
'type'=>$x ? 'AAAA' : 'A'
]]);
else
// We only look at AAAA/A records // We only look at AAAA/A records
$resolved = collect(dns_get_record($address,DNS_AAAA|DNS_A)) $resolved = collect(dns_get_record($address,DNS_AAAA|DNS_A))
->filter(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')) !== FALSE; }) ->filter(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')) !== FALSE; })