Add configuration items to determine DNS records returned and sort order
This commit is contained in:
parent
179233385b
commit
9aecd61a2f
@ -61,3 +61,9 @@ AWS_USE_PATH_STYLE_ENDPOINT=true
|
|||||||
MATRIX_SERVER=
|
MATRIX_SERVER=
|
||||||
MATRIX_AS_TOKEN=
|
MATRIX_AS_TOKEN=
|
||||||
MATRIX_HS_TOKEN=
|
MATRIX_HS_TOKEN=
|
||||||
|
|
||||||
|
FIDO_DNS_NS=
|
||||||
|
FIDO_IP_AAAA=
|
||||||
|
FIDO_AAAA_ORDER=
|
||||||
|
FIDO_IP_A=
|
||||||
|
FIDO_A_ORDER=
|
||||||
|
@ -190,7 +190,8 @@ final class SocketClient {
|
|||||||
{
|
{
|
||||||
Log::info(sprintf('%s:+ Creating connection to [%s:%d]',self::LOGKEY,$address,$port));
|
Log::info(sprintf('%s:+ Creating connection to [%s:%d]',self::LOGKEY,$address,$port));
|
||||||
|
|
||||||
$sort = collect(['AAAA','A']);
|
$type = collect(config('fido.ip'))
|
||||||
|
->filter(fn($item)=>$item['enabled']);
|
||||||
|
|
||||||
if (filter_var($address,FILTER_VALIDATE_IP))
|
if (filter_var($address,FILTER_VALIDATE_IP))
|
||||||
$resolved = collect([[
|
$resolved = collect([[
|
||||||
@ -199,9 +200,9 @@ final class SocketClient {
|
|||||||
]]);
|
]]);
|
||||||
else
|
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,$type->map(fn($item)=>$item['type'])->sum()))
|
||||||
->filter(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')) !== FALSE; })
|
->filter(fn($item)=>$type->has(Arr::get($item,'type')))
|
||||||
->sort(function($item) use ($sort) { return $sort->search(Arr::get($item,'type')); });
|
->sort(fn($a,$b)=>$type->get(Arr::get($a,'type'))['order'] < $type->get(Arr::get($b,'type'))['order']);
|
||||||
|
|
||||||
if (! $resolved->count())
|
if (! $resolved->count())
|
||||||
throw new SocketException(SocketException::CANT_CONNECT,sprintf('%s doesnt resolved to an IPv4/IPv6 address',$address));
|
throw new SocketException(SocketException::CANT_CONNECT,sprintf('%s doesnt resolved to an IPv4/IPv6 address',$address));
|
||||||
|
@ -43,4 +43,18 @@ return [
|
|||||||
'down' => 35,
|
'down' => 35,
|
||||||
'delist' => 45,
|
'delist' => 45,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// IP Address Resolution preferences
|
||||||
|
'ip' => [
|
||||||
|
'AAAA' => [
|
||||||
|
'enabled' => env('FIDO_IP_AAAA',false),
|
||||||
|
'order' => env('FIDO_AAAA_ORDER',2),
|
||||||
|
'type' => DNS_AAAA,
|
||||||
|
],
|
||||||
|
'A' => [
|
||||||
|
'enabled' => env('FIDO_IP_A',TRUE),
|
||||||
|
'order' => env('FIDO_A_ORDER',1),
|
||||||
|
'type' => DNS_A,
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
Loading…
Reference in New Issue
Block a user