2021-10-06 07:29:47 -05:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Proxy.php
|
|
|
|
*
|
|
|
|
* -Description-
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @package LibreNMS
|
|
|
|
* @link http://librenms.org
|
|
|
|
* @copyright 2021 Tony Murray
|
|
|
|
* @author Tony Murray <murraytony@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace LibreNMS\Util;
|
|
|
|
|
|
|
|
use LibreNMS\Config;
|
|
|
|
|
|
|
|
class Proxy
|
|
|
|
{
|
2023-05-23 09:25:17 -05:00
|
|
|
public static function http(): string
|
2021-10-29 03:10:17 -05:00
|
|
|
{
|
2023-05-23 09:25:17 -05:00
|
|
|
// use local_only to avoid CVE-2016-5385
|
|
|
|
$http_proxy = getenv('http_proxy', local_only: true) ?: getenv('HTTP_PROXY', local_only: true) ?: Config::get('http_proxy', '');
|
2021-10-06 07:29:47 -05:00
|
|
|
|
2023-05-23 09:25:17 -05:00
|
|
|
return $http_proxy;
|
2021-10-06 07:29:47 -05:00
|
|
|
}
|
|
|
|
|
2023-05-23 09:25:17 -05:00
|
|
|
public static function https(): string
|
2021-10-06 07:29:47 -05:00
|
|
|
{
|
2023-05-23 09:25:17 -05:00
|
|
|
// use local_only to avoid CVE-2016-5385
|
|
|
|
return getenv('https_proxy', local_only: true) ?: getenv('HTTPS_PROXY', local_only: true) ?: Config::get('https_proxy', '');
|
2021-10-06 07:29:47 -05:00
|
|
|
}
|
|
|
|
|
2023-05-23 09:25:17 -05:00
|
|
|
public static function ignore(): array
|
2021-10-06 07:29:47 -05:00
|
|
|
{
|
2023-05-23 09:25:17 -05:00
|
|
|
// use local_only to avoid CVE-2016-5385
|
|
|
|
$no_proxy = getenv('no_proxy', local_only: true) ?: getenv('NO_PROXY', local_only: true) ?: Config::get('no_proxy', '');
|
2021-10-06 07:29:47 -05:00
|
|
|
|
2023-05-23 09:25:17 -05:00
|
|
|
if ($no_proxy == '') {
|
|
|
|
return [];
|
2021-10-06 07:29:47 -05:00
|
|
|
}
|
2023-05-23 09:25:17 -05:00
|
|
|
|
|
|
|
return explode(',', str_replace(' ', '', $no_proxy));
|
2021-10-06 07:29:47 -05:00
|
|
|
}
|
|
|
|
}
|