make the domain check more verbose and allow to debug it better

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-05-20 14:02:04 +02:00
parent be7d57cf9f
commit 3bf0a769c7
2 changed files with 12 additions and 8 deletions

View file

@ -12,7 +12,7 @@
}
lastError = toast
body.prepend(toast)
setTimeout(toast.remove.bind(toast), 7000)
setTimeout(toast.remove.bind(toast), 10000)
}
function handleEvent(e) {

View file

@ -190,7 +190,7 @@ class ConfigurationManager
public function SetDomain(string $domain) : void {
// Validate domain
if (!filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
throw new InvalidSettingConfigurationException("Domain is not in a valid format!");
throw new InvalidSettingConfigurationException("Domain is not a valid domain!");
}
// Validate that it is not an IP-address
@ -202,14 +202,15 @@ class ConfigurationManager
// Validate IP
if(!filter_var($dnsRecordIP, FILTER_VALIDATE_IP)) {
throw new InvalidSettingConfigurationException("DNS config is not set or domain is not in a valid format!");
throw new InvalidSettingConfigurationException("DNS config is not set for this domain or the domain is not a valid domain! (It was found to be set to '" . $dnsRecordIP . "')");
}
$connection = @fsockopen($domain, 443, $errno, $errstr, 0.1);
// Check if port 443 is open
$connection = @fsockopen($domain, 443, $errno, $errstr, 10);
if ($connection) {
fclose($connection);
} else {
throw new InvalidSettingConfigurationException("The server is not reachable on Port 443.");
throw new InvalidSettingConfigurationException("The server is not reachable on Port 443. You can verify this e.g. with 'https://portchecker.co/' by entering your domain there as ip-address and port 443 as port.");
}
// Get Instance ID
@ -223,15 +224,18 @@ class ConfigurationManager
$protocol = 'http://';
}
// Check if response is correct
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $protocol . $domain . ':443');
$testUrl = $protocol . $domain . ':443';
curl_setopt($ch, CURLOPT_URL, $testUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = (string)curl_exec($ch);
# Get rid of trailing \n
$response = str_replace("\n", "", $response);
if($response !== $instanceID) {
throw new InvalidSettingConfigurationException("Domain does not point to this server or reverse proxy not configured correctly.");
if ($response !== $instanceID) {
error_log('The response of the connection attempt to "' . $testUrl . '" was: ' . $response);
throw new InvalidSettingConfigurationException("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')");
}
// Write domain