API transport proxy toggle switch

I have been working on the API transport to get events from LibreNMS and into our Telemetry system. The API transport looks to be the best fit for our environment. In order to get it to work properly I have to comment out the following line in transport.api.php:

// set_curl_proxy($curl);

When this is commented out, then validate.php complains about a file being changed. Would it be possible to add a proxy toggle switch like the one that has been added to the ElasticSearch transport…??

My work around for now would be to add transport.api.php to .gitignore but then I would miss any future updates.

I expect this is because we’ve not included the required file for that function. Try uncommenting it and adding: include '/opt/librenms/includes/functions.php'; above it. If that works let me know and we can PR a proper fix.

I have added “include ‘/opt/librenms/includes/functions.php’;” above the set_curl_proxy($curl); line but I am not seeing the toggle on/off proxy option under API transport.

I tried removing the current API transport config and re-adding it to see if the proxy option would show but it did not.

I misunderstood the issue here, you don’t get a proxy toggle for the api. It uses the default proxy config: https://docs.librenms.org/#Support/Configuration/#proxy-support

@laf, I probably did not explain this very well. In the transport.api.php file, in order to get the transport to work correctly I need to set it as a GET request and comment out set_curl_proxy($curl);. When I comment out this file I get an error when running the daily.sh script. To work around that error, I added transport.api.php to .gitignore.

Is there a way to resolve the issue that I am having or should I just leave as is with the work around…???

You shouldn’t need to comment out set_curl_proxy, it defaults to off if it works so shouldn’t set one.

Shouldn’t need to change to use GET, that’s determined by the url, if it contains ? in it then it uses GET.

@laf, I am not sure why but I am only able to get the API transport to work when the set_curl_proxy($curl); is commented out. I don’t think this file will change in the future so I have just added it it .gitignore and will live with it the way it is.