34 lines
933 B
PHP
34 lines
933 B
PHP
<?php
|
|
|
|
namespace App\Vito\Plugins\LiittleCookie\VitoTechnitiumDns\Actions;
|
|
|
|
use App\Vito\Plugins\LiittleCookie\VitoTechnitiumDns\Services\TechnitiumClient;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Throwable;
|
|
|
|
class TestConnection
|
|
{
|
|
public function test(array $credentials): bool
|
|
{
|
|
try {
|
|
$client = TechnitiumClient::fromCredentials($credentials);
|
|
|
|
// Use zones/list as a connectivity test — if the token is valid,
|
|
// we get back a list of zones.
|
|
$response = $client->get('zones/list');
|
|
|
|
if ($client->isSuccessful($response)) {
|
|
return true;
|
|
}
|
|
|
|
Log::error('Technitium connection failed', ['response' => $response->json()]);
|
|
|
|
return false;
|
|
} catch (Throwable $e) {
|
|
Log::error('Technitium connection exception', ['error' => $e->getMessage()]);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|