mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-04 08:02:05 +02:00
Add proxy support to callback function
This commit is contained in:
@@ -12,6 +12,21 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function set_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;
|
||||||
|
printf("Setting proxy to %s (from https_proxy=%s)\n", $proxystr, $_ENV['https_proxy']);
|
||||||
|
}
|
||||||
|
if (isset($config['callback_proxy'])) {
|
||||||
|
printf("Using %s as proxy\n", $config['callback_proxy']);
|
||||||
|
curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'");
|
$enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'");
|
||||||
if ($enabled == 1) {
|
if ($enabled == 1) {
|
||||||
|
|
||||||
@@ -78,7 +93,9 @@ if ($enabled == 1) {
|
|||||||
rtrim($fields, '&');
|
rtrim($fields, '&');
|
||||||
|
|
||||||
$post = curl_init();
|
$post = curl_init();
|
||||||
|
set_proxy($post);
|
||||||
curl_setopt($post, CURLOPT_URL, $config['callback_post']);
|
curl_setopt($post, CURLOPT_URL, $config['callback_post']);
|
||||||
|
curl_setopt($post, CURLOPT_PROXY, count($submit));
|
||||||
curl_setopt($post, CURLOPT_POST, count($submit));
|
curl_setopt($post, CURLOPT_POST, count($submit));
|
||||||
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
|
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
|
||||||
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
|
||||||
@@ -89,6 +106,7 @@ if ($enabled == 1) {
|
|||||||
$fields = "uuid=$uuid";
|
$fields = "uuid=$uuid";
|
||||||
|
|
||||||
$clear = curl_init();
|
$clear = curl_init();
|
||||||
|
set_proxy($post);
|
||||||
curl_setopt($clear, CURLOPT_URL, $config['callback_clear']);
|
curl_setopt($clear, CURLOPT_URL, $config['callback_clear']);
|
||||||
curl_setopt($clear, CURLOPT_POST, count($clear));
|
curl_setopt($clear, CURLOPT_POST, count($clear));
|
||||||
curl_setopt($clear, CURLOPT_POSTFIELDS, $fields);
|
curl_setopt($clear, CURLOPT_POSTFIELDS, $fields);
|
||||||
|
|||||||
@@ -41,3 +41,6 @@ $config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
|
|||||||
$config['poller-wrapper']['alerter'] = FALSE;
|
$config['poller-wrapper']['alerter'] = FALSE;
|
||||||
# Uncomment the next line to disable daily updates
|
# Uncomment the next line to disable daily updates
|
||||||
#$config['update'] = 0;
|
#$config['update'] = 0;
|
||||||
|
|
||||||
|
# Uncomment to submit callback stats via proxy
|
||||||
|
#$config['callback_proxy'] = "hostname:port";
|
||||||
|
|||||||
Reference in New Issue
Block a user