Add proxy support for http client
This commit is contained in:
@@ -12,6 +12,7 @@ New features:
|
|||||||
* Added user API access for procedure getProjectActivity()
|
* Added user API access for procedure getProjectActivity()
|
||||||
* Added config parameter to enable/disable Syslog
|
* Added config parameter to enable/disable Syslog
|
||||||
* Added custom filters
|
* Added custom filters
|
||||||
|
* Added http client proxy support
|
||||||
|
|
||||||
Core functionalities moved to plugins:
|
Core functionalities moved to plugins:
|
||||||
|
|
||||||
|
|||||||
@@ -99,9 +99,18 @@ class HttpClient extends Base
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = array_merge(array('User-Agent: '.self::HTTP_USER_AGENT, 'Connection: close'), $headers);
|
$default_headers = array(
|
||||||
|
'User-Agent: '.self::HTTP_USER_AGENT,
|
||||||
|
'Connection: close',
|
||||||
|
);
|
||||||
|
|
||||||
$context = stream_context_create(array(
|
if (HTTP_PROXY_USERNAME) {
|
||||||
|
$default_headers[] = 'Proxy-Authorization: Basic '.base64_encode(HTTP_PROXY_USERNAME.':'.HTTP_PROXY_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
$headers = array_merge($default_headers, $headers);
|
||||||
|
|
||||||
|
$context = array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'method' => $method,
|
'method' => $method,
|
||||||
'protocol_version' => 1.1,
|
'protocol_version' => 1.1,
|
||||||
@@ -110,9 +119,14 @@ class HttpClient extends Base
|
|||||||
'header' => implode("\r\n", $headers),
|
'header' => implode("\r\n", $headers),
|
||||||
'content' => $content
|
'content' => $content
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
|
|
||||||
$stream = @fopen(trim($url), 'r', false, $context);
|
if (HTTP_PROXY_HOSTNAME) {
|
||||||
|
$context['http']['proxy'] = 'tcp://'.HTTP_PROXY_HOSTNAME.':'.HTTP_PROXY_PORT;
|
||||||
|
$context['http']['request_fulluri'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stream = @fopen(trim($url), 'r', false, stream_context_create($context));
|
||||||
$response = '';
|
$response = '';
|
||||||
|
|
||||||
if (is_resource($stream)) {
|
if (is_resource($stream)) {
|
||||||
|
|||||||
@@ -120,3 +120,10 @@ defined('BRUTEFORCE_LOCKDOWN_DURATION') or define('BRUTEFORCE_LOCKDOWN_DURATION'
|
|||||||
// Session duration in second (0 = until the browser is closed)
|
// Session duration in second (0 = until the browser is closed)
|
||||||
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
|
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
|
||||||
defined('SESSION_DURATION') or define('SESSION_DURATION', 0);
|
defined('SESSION_DURATION') or define('SESSION_DURATION', 0);
|
||||||
|
|
||||||
|
// HTTP client proxy
|
||||||
|
defined('HTTP_PROXY_HOSTNAME') or define('HTTP_PROXY_HOSTNAME', '');
|
||||||
|
defined('HTTP_PROXY_PORT') or define('HTTP_PROXY_PORT', '3128');
|
||||||
|
defined('HTTP_PROXY_USERNAME') or define('HTTP_PROXY_USERNAME', '');
|
||||||
|
defined('HTTP_PROXY_PASSWORD') or define('HTTP_PROXY_PASSWORD', '');
|
||||||
|
|
||||||
|
|||||||
@@ -219,3 +219,10 @@ define('BRUTEFORCE_LOCKDOWN_DURATION', 15);
|
|||||||
// Session duration in second (0 = until the browser is closed)
|
// Session duration in second (0 = until the browser is closed)
|
||||||
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
|
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
|
||||||
define('SESSION_DURATION', 0);
|
define('SESSION_DURATION', 0);
|
||||||
|
|
||||||
|
// HTTP client proxy
|
||||||
|
define('HTTP_PROXY_HOSTNAME', '');
|
||||||
|
define('HTTP_PROXY_PORT', '3128');
|
||||||
|
define('HTTP_PROXY_USERNAME', '');
|
||||||
|
define('HTTP_PROXY_PASSWORD', '');
|
||||||
|
|
||||||
|
|||||||
@@ -255,6 +255,18 @@ Session
|
|||||||
define('SESSION_DURATION', 0);
|
define('SESSION_DURATION', 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
HTTP client proxy
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
If external HTTP requests need to be sent through a proxy:
|
||||||
|
|
||||||
|
```php
|
||||||
|
define('HTTP_PROXY_HOSTNAME', '');
|
||||||
|
define('HTTP_PROXY_PORT', '3128');
|
||||||
|
define('HTTP_PROXY_USERNAME', '');
|
||||||
|
define('HTTP_PROXY_PASSWORD', '');
|
||||||
|
```
|
||||||
|
|
||||||
Various settings
|
Various settings
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user