fix: TestConnection for unsaved servers, traffic display, and cache-busting
- Use $params['serverhostname']/serverpassword directly in TestConnection instead of database lookup (serverid=0 is falsy for new servers) - Default traffic "Used" to 0 GB when allocated but no usage reported - Add ?v=0.0.19 cache-busting to JS/CSS includes in overview.tpl Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,15 +70,17 @@ function VirtFusionDirect_ConfigOptions()
|
||||
function VirtFusionDirect_TestConnection(array $params)
|
||||
{
|
||||
try {
|
||||
$module = new Module();
|
||||
$cp = $module->getCP($params['serverid']);
|
||||
$hostname = trim($params['serverhostname'] ?? '');
|
||||
$password = $params['serverpassword'] ?? '';
|
||||
|
||||
if (!$cp) {
|
||||
return ['success' => false, 'error' => 'Unable to retrieve server configuration. Please verify the server hostname and access hash/password.'];
|
||||
if (empty($hostname) || empty($password)) {
|
||||
return ['success' => false, 'error' => 'Server hostname and password are required. Please verify the server configuration.'];
|
||||
}
|
||||
|
||||
$request = $module->initCurl($cp['token']);
|
||||
$data = $request->get($cp['url'] . '/connect');
|
||||
$url = 'https://' . $hostname . '/api/v1';
|
||||
$module = new Module();
|
||||
$request = $module->initCurl($password);
|
||||
$data = $request->get($url . '/connect');
|
||||
|
||||
$httpCode = $request->getRequestInfo('http_code');
|
||||
|
||||
@@ -96,7 +98,7 @@ function VirtFusionDirect_TestConnection(array $params)
|
||||
}
|
||||
|
||||
return ['success' => false, 'error' => 'Unexpected response from VirtFusion API (HTTP ' . $httpCode . '). Please check the server configuration.'];
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
return ['success' => false, 'error' => 'Connection test failed: ' . $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user