Merge pull request #792 from nextcloud/enh/745/improve-ip-check

improve the ip-address check for setdomain
This commit is contained in:
Simon L 2022-06-13 11:57:03 +02:00 committed by GitHub
commit c2c4698119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -199,12 +199,19 @@ class ConfigurationManager
}
$dnsRecordIP = gethostbyname($domain);
if ($dnsRecordIP === $domain) {
$dnsRecordIP = '';
}
// Validate IP
if(!filter_var($dnsRecordIP, FILTER_VALIDATE_IP)) {
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 . "')");
}
if (!filter_var($dnsRecordIP, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
throw new InvalidSettingConfigurationException("It seems like the ip-address is set to an internal or reserved ip-address. This is not supported. (It was found to be set to '" . $dnsRecordIP . "')");
}
// Check if port 443 is open
$connection = @fsockopen($domain, 443, $errno, $errstr, 10);
if ($connection) {