mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #49977 from nextcloud/jtr-perf-checks-connectivity-https-proto
perf(settings): Speed up InternetConnectivity setup check
This commit is contained in:
commit
1304590d6c
2 changed files with 18 additions and 18 deletions
|
|
@ -41,11 +41,12 @@ class InternetConnectivity implements ISetupCheck {
|
|||
}
|
||||
|
||||
$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
|
||||
'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
|
||||
'https://www.nextcloud.com', 'https://www.startpage.com', 'https://www.eff.org', 'https://www.edri.org'
|
||||
]);
|
||||
|
||||
foreach ($siteArray as $site) {
|
||||
if ($this->isSiteReachable($site)) {
|
||||
// successful as soon as one connection succeeds
|
||||
return SetupResult::success();
|
||||
}
|
||||
}
|
||||
|
|
@ -55,19 +56,18 @@ class InternetConnectivity implements ISetupCheck {
|
|||
/**
|
||||
* Checks if the Nextcloud server can connect to a specific URL
|
||||
* @param string $site site domain or full URL with http/https protocol
|
||||
* @return bool success/failure
|
||||
*/
|
||||
private function isSiteReachable(string $site): bool {
|
||||
// if there is no protocol specified, test http:// first then, if necessary, https://
|
||||
if (preg_match('/^https?:\/\//', $site) !== 1) {
|
||||
$httpSite = 'http://' . $site . '/';
|
||||
$httpsSite = 'https://' . $site . '/';
|
||||
return $this->isSiteReachable($httpSite) || $this->isSiteReachable($httpsSite);
|
||||
}
|
||||
try {
|
||||
$client = $this->clientService->newClient();
|
||||
// if there is no protocol, test http:// AND https://
|
||||
if (preg_match('/^https?:\/\//', $site) !== 1) {
|
||||
$httpSite = 'http://' . $site . '/';
|
||||
$client->get($httpSite);
|
||||
$httpsSite = 'https://' . $site . '/';
|
||||
$client->get($httpsSite);
|
||||
} else {
|
||||
$client->get($site);
|
||||
}
|
||||
$client->get($site);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('Cannot connect to: ' . $site, [
|
||||
'app' => 'internet_connection_check',
|
||||
|
|
|
|||
|
|
@ -936,16 +936,16 @@ $CONFIG = [
|
|||
*
|
||||
* Defaults to the following domains:
|
||||
*
|
||||
* - www.nextcloud.com
|
||||
* - www.startpage.com
|
||||
* - www.eff.org
|
||||
* - www.edri.org
|
||||
* - https://www.nextcloud.com
|
||||
* - https://www.startpage.com
|
||||
* - https://www.eff.org
|
||||
* - https://www.edri.org
|
||||
*/
|
||||
'connectivity_check_domains' => [
|
||||
'www.nextcloud.com',
|
||||
'www.startpage.com',
|
||||
'www.eff.org',
|
||||
'www.edri.org'
|
||||
'https://www.nextcloud.com',
|
||||
'https://www.startpage.com',
|
||||
'https://www.eff.org',
|
||||
'https://www.edri.org'
|
||||
],
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue