mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Updated and added more options for http proxy support (#4718)
This commit is contained in:
committed by
Tony Murray
parent
6073ba6112
commit
d5ba013a8a
+19
-9
@@ -1118,18 +1118,28 @@ function guidv4($data)
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
|
||||
function set_curl_proxy($post)
|
||||
/**
|
||||
* @param $curl
|
||||
*/
|
||||
function set_curl_proxy($curl)
|
||||
{
|
||||
global $config;
|
||||
if (isset($_ENV['https_proxy'])) {
|
||||
$tmp = rtrim($_ENV['https_proxy'], "/");
|
||||
$proxystr = str_replace(array("http://", "https://"), "", $tmp);
|
||||
$config['callback_proxy'] = $proxystr;
|
||||
echo "Setting proxy to ".$proxystr." (from https_proxy=".$_ENV['https_proxy'].")\n";
|
||||
|
||||
$proxy = '';
|
||||
if (getenv('http_proxy')) {
|
||||
$proxy = getenv('http_proxy');
|
||||
} elseif (getenv('https_proxy')) {
|
||||
$proxy = getenv('https_proxy');
|
||||
} elseif (isset($config['callback_proxy'])) {
|
||||
$proxy = $config['callback_proxy'];
|
||||
} elseif (isset($config['http_proxy'])) {
|
||||
$proxy = $config['http_proxy'];
|
||||
}
|
||||
if (isset($config['callback_proxy'])) {
|
||||
echo "Using ".$config['callback_proxy']." as proxy\n";
|
||||
curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']);
|
||||
|
||||
$tmp = rtrim($proxy, "/");
|
||||
$proxy = str_replace(array("http://", "https://"), "", $tmp);
|
||||
if (!empty($proxy)) {
|
||||
curl_setopt($curl, CURLOPT_PROXY, $proxy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user