summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--app/Core/HttpClient.php22
-rw-r--r--app/constants.php7
-rw-r--r--config.default.php7
-rw-r--r--doc/config.markdown12
5 files changed, 45 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 507e458b..352a0a3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ New features:
* Added user API access for procedure getProjectActivity()
* Added config parameter to enable/disable Syslog
* Added custom filters
+* Added http client proxy support
Core functionalities moved to plugins:
diff --git a/app/Core/HttpClient.php b/app/Core/HttpClient.php
index b808f756..99534cfe 100644
--- a/app/Core/HttpClient.php
+++ b/app/Core/HttpClient.php
@@ -99,9 +99,18 @@ class HttpClient extends Base
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',
+ );
+
+ if (HTTP_PROXY_USERNAME) {
+ $default_headers[] = 'Proxy-Authorization: Basic '.base64_encode(HTTP_PROXY_USERNAME.':'.HTTP_PROXY_PASSWORD);
+ }
+
+ $headers = array_merge($default_headers, $headers);
- $context = stream_context_create(array(
+ $context = array(
'http' => array(
'method' => $method,
'protocol_version' => 1.1,
@@ -110,9 +119,14 @@ class HttpClient extends Base
'header' => implode("\r\n", $headers),
'content' => $content
)
- ));
+ );
+
+ 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, $context);
+ $stream = @fopen(trim($url), 'r', false, stream_context_create($context));
$response = '';
if (is_resource($stream)) {
diff --git a/app/constants.php b/app/constants.php
index f54930ab..0d8ffd87 100644
--- a/app/constants.php
+++ b/app/constants.php
@@ -120,3 +120,10 @@ defined('BRUTEFORCE_LOCKDOWN_DURATION') or define('BRUTEFORCE_LOCKDOWN_DURATION'
// Session duration in second (0 = until the browser is closed)
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
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', '');
+
diff --git a/config.default.php b/config.default.php
index 0d94686a..2b7da60d 100644
--- a/config.default.php
+++ b/config.default.php
@@ -219,3 +219,10 @@ define('BRUTEFORCE_LOCKDOWN_DURATION', 15);
// Session duration in second (0 = until the browser is closed)
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
define('SESSION_DURATION', 0);
+
+// HTTP client proxy
+define('HTTP_PROXY_HOSTNAME', '');
+define('HTTP_PROXY_PORT', '3128');
+define('HTTP_PROXY_USERNAME', '');
+define('HTTP_PROXY_PASSWORD', '');
+
diff --git a/doc/config.markdown b/doc/config.markdown
index 2cbd89e4..b711f137 100644
--- a/doc/config.markdown
+++ b/doc/config.markdown
@@ -255,6 +255,18 @@ Session
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
----------------