diff --git a/.env.example b/.env.example index 022a987..34e0c8e 100644 --- a/.env.example +++ b/.env.example @@ -47,7 +47,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" FIDO_DIR=fido -FIDO_PACKET_KEEP= +FIDO_PACKET_KEEP=false FIDO_STRICT=false FILESYSTEM_DISK=s3 @@ -58,6 +58,12 @@ AWS_ENDPOINT= AWS_DEFAULT_REGION=home AWS_USE_PATH_STYLE_ENDPOINT=true -MATRIX_SERVER= -MATRIX_AS_TOKEN= -MATRIX_HS_TOKEN= +#MATRIX_SERVER= +#MATRIX_AS_TOKEN= +#MATRIX_HS_TOKEN= + +#FIDO_DNS_NS= +#FIDO_DNS_AAAA= +#FIDO_DNS_ORDER_AAAA= +#FIDO_DNS_A= +#FIDO_DNS_ORDER_A= diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index a3f051c..1b2aa50 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -190,7 +190,8 @@ final class SocketClient { { 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)) $resolved = collect([[ @@ -199,9 +200,9 @@ final class SocketClient { ]]); 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')); }); + $resolved = collect(dns_get_record($address,$type->map(fn($item)=>$item['type'])->sum())) + ->filter(fn($item)=>$type->has(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()) throw new SocketException(SocketException::CANT_CONNECT,sprintf('%s doesnt resolved to an IPv4/IPv6 address',$address)); diff --git a/config/fido.php b/config/fido.php index 13d02e6..0bbb8d9 100644 --- a/config/fido.php +++ b/config/fido.php @@ -43,4 +43,18 @@ return [ 'down' => 35, 'delist' => 45, ], + + // IP Address Resolution preferences + 'ip' => [ + 'AAAA' => [ + 'enabled' => env('FIDO_DNS_AAAA',TRUE), + 'order' => env('FIDO_DNS_ORDER_AAAA',2), + 'type' => DNS_AAAA, + ], + 'A' => [ + 'enabled' => env('FIDO_DNS_A',TRUE), + 'order' => env('FIDO_DNS_ORDER__ORDER',1), + 'type' => DNS_A, + ], + ], ]; \ No newline at end of file