code review

pull/716/head
sebres 2014-05-05 15:17:22 +02:00
parent ccf07c4b21
commit ccacfc1047
2 changed files with 5 additions and 4 deletions

View File

@ -93,7 +93,7 @@ class JailReader(ConfigReader):
["int", "maxretry", None], ["int", "maxretry", None],
["int", "findtime", None], ["int", "findtime", None],
["int", "bantime", None], ["int", "bantime", None],
["bool", "bantimeextra.enabled", False], ["bool", "bantimeextra.enabled", None],
["string", "bantimeextra.findtime", None], ["string", "bantimeextra.findtime", None],
["string", "bantimeextra.factor", None], ["string", "bantimeextra.factor", None],
["string", "bantimeextra.formula", None], ["string", "bantimeextra.formula", None],

View File

@ -248,8 +248,9 @@ class Actions(JailThread, Mapping):
be[opt] = value; be[opt] = value;
logSys.info('Set banTimeExtra.%s = %s', opt, value) logSys.info('Set banTimeExtra.%s = %s', opt, value)
if opt == 'enabled': if opt == 'enabled':
be[opt] = bool(value) if isinstance(value, str):
if bool(value) and self._jail.database is None: be[opt] = value.lower() in ("yes", "true", "ok", "1")
if be[opt] and self._jail.database is None:
logSys.warning("banTimeExtra is not available as long jail database is not set") logSys.warning("banTimeExtra is not available as long jail database is not set")
if opt in ['findtime', 'maxtime', 'rndtime']: if opt in ['findtime', 'maxtime', 'rndtime']:
if not value is None: if not value is None:
@ -346,7 +347,7 @@ class Actions(JailThread, Mapping):
ip=ip, jail=self._jail).getAttempt()) ip=ip, jail=self._jail).getAttempt())
try: try:
# if ban time was not set: # if ban time was not set:
if bTicket.getBanTime() is None: if not ticket.getRestored() and bTicket.getBanTime() is None:
btime = self.incrBanTime(bTicket, ip) btime = self.incrBanTime(bTicket, ip)
bTicket.setBanTime(btime); bTicket.setBanTime(btime);
except Exception as e: except Exception as e: