- $ip = $server['REMOTE_ADDR'];
- $trusted = $this->configManager->get('security.trusted_proxies', []);
-
- if (in_array($ip, $trusted)) {
- $ip = getIpAddressFromProxy($server, $trusted);
- if (! $ip) {
- // the IP is behind a trusted forward proxy, but is not forwarded
- // in the HTTP headers, so we do nothing
- return;
- }
- }
-
- // increment the fail count for this IP
- if (isset($this->globals['IPBANS']['FAILURES'][$ip])) {
- $this->globals['IPBANS']['FAILURES'][$ip]++;
- } else {
- $this->globals['IPBANS']['FAILURES'][$ip] = 1;
- }
-
- if ($this->globals['IPBANS']['FAILURES'][$ip] >= $this->configManager->get('security.ban_after')) {
- $this->globals['IPBANS']['BANS'][$ip] = time() + $this->configManager->get('security.ban_duration', 1800);
- logm(
- $this->configManager->get('resource.log'),
- $server['REMOTE_ADDR'],
- 'IP address banned from login'
- );
- }
- $this->writeBanFile();