1 | <?php |
||
18 | class IP implements ExcluderInterface |
||
19 | { |
||
20 | /** |
||
21 | * List of IPs to be excluded. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $ips = []; |
||
26 | |||
27 | /** |
||
28 | * Allowe proxies. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $trustedProxies; |
||
33 | |||
34 | /** |
||
35 | * @param array $ips |
||
36 | * @param array $trustedProxies |
||
37 | */ |
||
38 | public function __construct(array $ips = [], array $trustedProxies = []) |
||
46 | |||
47 | /** |
||
48 | * Add IP. |
||
49 | * |
||
50 | * @param string $ipAddress |
||
51 | * |
||
52 | * @throws \InvalidArgumentException |
||
53 | */ |
||
54 | public function addIP($ipAddress) |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function isExcluded(ServerRequestInterface $request) |
||
80 | |||
81 | /** |
||
82 | * Find client's IP. |
||
83 | * |
||
84 | * @param ServerRequestInterface $request |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | protected function determineCurrentIp($request) |
||
117 | |||
118 | /** |
||
119 | * Check IP validity. |
||
120 | * |
||
121 | * @param string $ipAddress |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | private function isValidIp($ipAddress) |
||
129 | } |
||
130 |