-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup - remove proxy settings gui from Admin/Server tab, and add an e…
…xternal condition checking connectivity to a proxy
- Loading branch information
Showing
3 changed files
with
46 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Services/Http/classes/Setup/Condition/ProxyConnectableCondition.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* Copyright (c) 2020 Daniel Weise <[email protected]> Extended GPL, see docs/LICENSE */ | ||
|
||
use ILIAS\Setup; | ||
use ILIAS\Setup\Condition\ExternalConditionObjective; | ||
|
||
class ProxyConnectableCondition extends ExternalConditionObjective | ||
{ | ||
public function __construct($config) | ||
{ | ||
return parent::__construct( | ||
"Can establish a connection to proxy", | ||
function (Setup\Environment $env) use ($config) : bool { | ||
try { | ||
$host = $config->getProxyHost(); | ||
if (strspn($host, '.0123456789') != strlen($host) && strstr($host, '/') === false) { | ||
$host = gethostbyname($host); | ||
} | ||
$port = $config->getProxyPort() % 65536; | ||
|
||
if (!fsockopen($host, $port, $errno, $errstr, 10)) { | ||
throw new Exception("Can`t establish connection to proxy."); | ||
} | ||
} catch (\Exception $e) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
"Can`t establish connection to proxy." | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters