refactor: Updated and added more options for http proxy support (#4718)

This commit is contained in:
Neil Lathwood
2016-10-13 20:07:07 -05:00
committed by Tony Murray
parent 6073ba6112
commit d5ba013a8a
13 changed files with 67 additions and 14 deletions
+19 -9
View File
@@ -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);
}
}