Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #64 from philkra/development
Browse files Browse the repository at this point in the history
Support for forwarded IP's
  • Loading branch information
philkra authored Mar 24, 2019
2 parents 6f43ec1 + 745b4a6 commit 80e79d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Events/EventBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,16 @@ final protected function getContext() : array

// Build Context Stub
$SERVER_PROTOCOL = $_SERVER['SERVER_PROTOCOL'] ?? '';
$remote_address = $_SERVER['REMOTE_ADDR'];
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) === true) {
$remote_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$context = [
'request' => [
'http_version' => substr($SERVER_PROTOCOL, strpos($SERVER_PROTOCOL, '/')),
'method' => $_SERVER['REQUEST_METHOD'] ?? 'cli',
'socket' => [
'remote_address' => $_SERVER['REMOTE_ADDR'] ?? '',
'remote_address' => $remote_address ?? '',
'encrypted' => isset($_SERVER['HTTPS'])
],
'response' => $this->contexts['response'],
Expand Down

0 comments on commit 80e79d7

Please sign in to comment.