summaryrefslogtreecommitdiffstats
path: root/lib/private/request.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/request.php')
-rwxr-xr-xlib/private/request.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/private/request.php b/lib/private/request.php
index b063c1f5967..fa446837a97 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -14,6 +14,7 @@ class OC_Request {
const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#';
const REGEX_LOCALHOST = '/^(127\.0\.0\.1|localhost)(:[0-9]+|)$/';
+ static protected $reqId;
/**
* Returns the remote address, if the connection came from a trusted proxy and `forwarded_for_headers` has been configured
@@ -22,7 +23,7 @@ class OC_Request {
* @return string IP address
*/
public static function getRemoteAddress() {
- $remoteAddress = $_SERVER['REMOTE_ADDR'];
+ $remoteAddress = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$trustedProxies = \OC::$server->getConfig()->getSystemValue('trusted_proxies', array());
if(is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
@@ -44,6 +45,17 @@ class OC_Request {
}
/**
+ * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging
+ * @return string
+ */
+ public static function getRequestID() {
+ if(self::$reqId === null) {
+ self::$reqId = hash('md5', microtime().\OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(20));
+ }
+ return self::$reqId;
+ }
+
+ /**
* Check overwrite condition
* @param string $type
* @return bool