Update SocketClient to support raw IP addresses
This commit is contained in:
parent
04aa86b6ee
commit
0c4c2f8cf5
@ -201,10 +201,16 @@ final class SocketClient {
|
||||
|
||||
$sort = collect(['AAAA','A']);
|
||||
|
||||
// We only look at AAAA/A records
|
||||
$resolved = collect(dns_get_record($address,DNS_AAAA|DNS_A))
|
||||
->filter(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')) !== FALSE; })
|
||||
->sort(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')); });
|
||||
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
|
||||
$resolved = collect(dns_get_record($address,DNS_AAAA|DNS_A))
|
||||
->filter(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')) !== FALSE; })
|
||||
->sort(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')); });
|
||||
|
||||
if (! $resolved->count())
|
||||
throw new SocketException(SocketException::CANT_CONNECT,sprintf('%s doesnt resolved to an IPv4/IPv6 address',$address));
|
||||
|
Loading…
Reference in New Issue
Block a user