1 | <?php |
||
11 | class UserRealIpMiddleware implements MiddlewareInterface |
||
12 | { |
||
13 | public const ATTRIBUTE_NAME = 'user-real-ip'; |
||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | private $nets; |
||
18 | |||
19 | public $ipAttribute = self::ATTRIBUTE_NAME; |
||
20 | |||
21 | public function __construct(array $nets) |
||
25 | |||
26 | /** |
||
27 | * @inheritDoc |
||
28 | */ |
||
29 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
33 | |||
34 | private function prepare(ServerRequestInterface $request): ServerRequestInterface |
||
50 | |||
51 | private function getIp(ServerRequestInterface $request): string |
||
55 | |||
56 | private function getNewIp(ServerRequestInterface $request): string |
||
62 | |||
63 | private function setNewIp(ServerRequestInterface $request, string $ip) |
||
76 | |||
77 | public function getParam(ServerRequestInterface $request, string $name): ?string |
||
81 | } |
||
82 |