summaryrefslogtreecommitdiffstats
path: root/apps/settings
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2022-03-08 10:23:05 +0100
committerGitHub <noreply@github.com>2022-03-08 10:23:05 +0100
commit1ada7928590679b8ab4edd2ed58f94373fd10f29 (patch)
tree7f8d32a2a64abc282b06b2b3b5c978e81bb4d805 /apps/settings
parent7f10de2cb876494dcdecf85b545134f9f19e9df5 (diff)
parentcb28da438629f090ba3a03ce48a57da367942b0a (diff)
downloadnextcloud-server-1ada7928590679b8ab4edd2ed58f94373fd10f29.tar.gz
nextcloud-server-1ada7928590679b8ab4edd2ed58f94373fd10f29.zip
Merge pull request #31479 from nextcloud/backport/31426/stable23
[stable23] Connectivity check: allow using the protocol in 'connectivity_check_domains'
Diffstat (limited to 'apps/settings')
-rw-r--r--apps/settings/lib/Controller/CheckSetupController.php21
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php
index 11900fad45b..b9bdd0929d6 100644
--- a/apps/settings/lib/Controller/CheckSetupController.php
+++ b/apps/settings/lib/Controller/CheckSetupController.php
@@ -198,19 +198,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,
]);