domain-check: replace curl with GuzzleHttp\Client in ConfigurationManager

This commit is contained in:
copilot-swe-agent[bot]
2026-04-24 19:20:45 +00:00
committed by Simon L.
parent 39f30a6609
commit d772c14f55

View File

@@ -5,6 +5,8 @@ namespace AIO\Data;
use AIO\Auth\PasswordGenerator;
use AIO\Controller\DockerController;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException;
class ConfigurationManager
{
@@ -530,23 +532,22 @@ class ConfigurationManager
}
// Check if response is correct
$ch = curl_init();
if ($ch === false) {
throw new InvalidSettingConfigurationException('Could not init curl! Please check the logs!');
}
$testUrl = $protocol . $domain . ':443';
curl_setopt($ch, CURLOPT_URL, $testUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = (string)curl_exec($ch);
# Get rid of trailing \n
$response = str_replace("\n", "", $response);
$errorMessage = '';
$guzzleClient = new Client(['connect_timeout' => 10, 'timeout' => 10, 'http_errors' => false]);
try {
$guzzleResponse = $guzzleClient->get($testUrl);
# Get rid of trailing \n
$response = str_replace("\n", "", (string)$guzzleResponse->getBody());
} catch (TransferException $e) {
$response = '';
$errorMessage = 'The error message was: ' . $e->getMessage();
}
if ($response !== $instanceID) {
error_log('The response of the connection attempt to "' . $testUrl . '" was: ' . $response);
error_log('Expected was: ' . $instanceID);
error_log('The error message was: ' . curl_error($ch));
error_log($errorMessage);
$notice = "Domain does not point to this server or the reverse proxy is not configured correctly. See the mastercontainer logs for more details. ('sudo docker logs -f nextcloud-aio-mastercontainer')";
if ($port === '443') {
$notice .= " If you should be using Cloudflare, make sure to disable the Cloudflare Proxy feature as it might block the domain validation. Same for any other firewall or service that blocks unencrypted access on port 443.";