Merge pull request #791 from paulgear/master

Add proxy support for callback stats
This commit is contained in:
Daniel Preussker
2015-04-13 10:15:49 +00:00
3 changed files with 23 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ if ($enabled == 1) {
rtrim($fields, '&');
$post = curl_init();
set_curl_proxy($post);
curl_setopt($post, CURLOPT_URL, $config['callback_post']);
curl_setopt($post, CURLOPT_POST, count($submit));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
@@ -89,6 +90,7 @@ if ($enabled == 1) {
$fields = "uuid=$uuid";
$clear = curl_init();
set_curl_proxy($clear);
curl_setopt($clear, CURLOPT_URL, $config['callback_clear']);
curl_setopt($clear, CURLOPT_POST, count($clear));
curl_setopt($clear, CURLOPT_POSTFIELDS, $fields);

View File

@@ -41,3 +41,6 @@ $config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
$config['poller-wrapper']['alerter'] = FALSE;
# Uncomment the next line to disable daily updates
#$config['update'] = 0;
# Uncomment to submit callback stats via proxy
#$config['callback_proxy'] = "hostname:port";

View File

@@ -1140,4 +1140,17 @@ function guidv4($data) {
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
?>
function set_curl_proxy($post)
{
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";
}
if (isset($config['callback_proxy'])) {
echo "Using ".$config['callback_proxy']." as proxy\n";
curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']);
}
}