Просмотр исходного кода

change regex for fail2ban

tags/2019.03^2
Philipp Holzer Hypolite Petovan <hypolite@mrpetovan.com> 1 год назад
Родитель
Сommit
b5afd2a21d
3 измененных файлов: 5 добавлений и 7 удалений
  1. +1
    -1
      doc/tools.md
  2. +3
    -5
      src/Core/Logger.php
  3. +1
    -1
      src/Module/Login.php

+ 1
- 1
doc/tools.md Просмотреть файл

@@ -56,7 +56,7 @@ In */etc/fail2ban/jail.local* create a section for Friendica:
And create a filter definition in */etc/fail2ban/filter.d/friendica.conf*:

[Definition]
failregex = ^.*Login\.php.*failed login attempt.*from IP <HOST>.*$
failregex = ^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$
ignoreregex =

Additionally you have to define the number of failed logins before the ban should be activated.


+ 3
- 5
src/Core/Logger.php Просмотреть файл

@@ -323,21 +323,19 @@ class Logger extends BaseObject
* @brief Logs the given message at the given log level
*
* @param string $msg
* @param int $level
* @param string $level
*
* @throws \Exception
* @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead
*/
public static function log($msg, $level = 3)
public static function log($msg, $level = LogLevel::INFO)
{
if (!isset(self::$logger)) {
return;
}

$loglevel = self::mapLegacyDebugLevel($level);

$stamp1 = microtime(true);
self::$logger->log($loglevel, $msg);
self::$logger->log($level, $msg);
self::getApp()->saveTimestamp($stamp1, "file");
}



+ 1
- 1
src/Module/Login.php Просмотреть файл

@@ -148,7 +148,7 @@ class Login extends BaseModule
);
}
} catch (Exception $e) {
Logger::notice('authenticate: failed login attempt', ['username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
Logger::notice('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
info('Login failed. Please check your credentials.' . EOL);
$a->internalRedirect();
}


Загрузка…
Отмена
Сохранить