diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2022-03-08 12:22:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 12:22:55 +0300 |
commit | 86a375ef57c98bacc3e2956f1b0d00a6415c332e (patch) | |
tree | dadc76b7f5a8e9b1ef24cdf8dc18a5ac6cf337e5 | |
parent | 6c34d14ea2f2d7276770d5f0bbca5ff29920a6dd (diff) | |
parent | 15d60a02a3c38c743f93fff8e3f8bf6b85062202 (diff) |
Merge pull request #31480 from nextcloud/backport/31426/stable22
[stable22] Connectivity check: allow using the protocol in 'connectivity_check_domains'
-rw-r--r-- | apps/settings/lib/Controller/CheckSetupController.php | 21 | ||||
-rw-r--r-- | config/config.sample.php | 4 |
2 files changed, 17 insertions, 8 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 45b9b773a8c..7e778550ab7 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -179,19 +179,24 @@ class CheckSetupController extends Controller { } /** - * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP + * 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 */ - private function isSiteReachable($sitename) { - $httpSiteName = 'http://' . $sitename . '/'; - $httpsSiteName = 'https://' . $sitename . '/'; - + private function isSiteReachable(string $site): bool { try { $client = $this->clientService->newClient(); - $client->get($httpSiteName); - $client->get($httpsSiteName); + // 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); + } } catch (\Exception $e) { - $this->logger->error('Cannot connect to: ' . $sitename, [ + $this->logger->error('Cannot connect to: ' . $site, [ 'app' => 'internet_connection_check', 'exception' => $e, ]); diff --git a/config/config.sample.php b/config/config.sample.php index 783d9daea39..ac6fb93f0d5 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -768,6 +768,10 @@ $CONFIG = [ * connection. If none of these hosts are reachable, the administration panel * will show a warning. Set to an empty list to not do any such checks (warning * will still be shown). + * If no protocol is provided, both http and https will be tested. + * For example, 'http://www.nextcloud.com' and 'https://www.nextcloud.com' + * will be tested for 'www.nextcloud.com' + * If a protocol is provided, only this one will be tested. * * Defaults to the following domains: * |