sebres
fd32e908e3
fixes restoring of tickets from database for jails with persistent ban (if bantime = -1)
2017-06-15 18:28:37 +02:00
sebres
5e4fdb60c8
extended test-cases (coverage)
2016-09-26 10:50:02 +02:00
sebres
ebd864660a
normalize usage of preferred encoding (and decode any to string);
...
python 3.x compatibility (used uni_decode for string representation of stdout/stderr, unified test cases)
amend for #1542
2016-09-09 20:29:55 +02:00
sebres
a20f325f80
database: stability fix - repack cursor iterator as long as locked
2016-09-09 17:36:01 +02:00
sebres
8c4eebc3e3
reload actions amend, code review and test cases extended for update/start/stop of actions by reloading
2016-09-09 10:45:09 +02:00
sebres
4fb511294e
temp commit: reload now supported actions and action reloading (parameters, unban obsolete removed actions, etc.)
2016-09-08 23:56:32 +02:00
sebres
8c26cada27
temp commit: partially cherry picked from ban-time-incr branch
2016-09-08 11:43:27 +02:00
Yaroslav Halchenko
87acd7a0fc
RF: Replace old fashioned "except E , e" with "except E as e" ( Closes #1537 )
...
0.10 specific
supplement to b875e51cd7 in master AKA 0.9
2016-09-06 08:18:34 -04:00
sebres
f62266659f
Merge branch 'master' into '0.10'
2016-05-21 13:48:00 +02:00
sebres
1718c8dbe9
pypy: switch journal mode after upgrade (save it during the upgrade), to prevent errors like "database table is locked"
2016-05-20 15:12:32 +02:00
sebres
db9e724038
extremely speedup of all database operations:
...
- (synchronous = OFF) write data through OS without syncing
- (journal_mode = MEMORY) use memory for the transaction logging
2016-05-20 12:06:04 +02:00
sebres
d420148055
database: always explicit convert ip to str, because may be an IPAddr, that will be unsupported type by bind parameter (as long as we've found any default wrapper handler for sqlite3)
2016-05-13 22:53:57 +02:00
sebres
afe1f73af2
meantime commit: code review, simplification, pythonization, etc. (test cases passed)
...
unnecessarily code aggravation with explicit converting reverted - implicit converting inside internal functions if not IPAddr object;
2016-05-09 15:28:21 +02:00
Alexander Koeppe
85b895178b
change IP address string to object handling part 1
...
# Conflicts:
# fail2ban/server/filter.py
2016-05-04 14:07:12 +02:00
sebres
e065941ac5
use "maxEntries" (currently 50 as default) as range for max number of the last matches/failures, fail2ban will hold per IP in the list of failures in failmanager resp. in the database;
...
prevents out of memory situation if many IP's makes extremely many failures (or very large files since last fail2ban run);
closes gh-1277
todo: parameter `maxentries` should be configurable (jail.conf resp. fail2ban.conf);
todo: adjust ban-time-incr branch by merge (table "bips").
2015-12-29 12:49:48 +01:00
sebres
6faffe3201
test cases extended, code review (+ python 3.x compatibility);
...
database test cases extended - enable deleted (disabled) jail in addJail;
2015-12-29 12:49:27 +01:00
sebres
59bf5013c0
- performance of fail2ban optimized
...
-- cache dnsToIp, ipToName to prevent long wait during retrieving of ip/name for wrong dns or lazy dns-system;
-- instead of simple "sleep" used conditional wait "wait_for", that internal increases sleep interval up to sleeptime;
-- ticket / banmanager / failmanager modules are performance optimized;
-- api of filter (log files), jail, etc. rewritten and extended for performance purposes;
- performance of test cases optimized:
-- added option "--fast" to decrease wait intervals, avoid passive waiting, and skip few very slow test cases;
- code review after partially cherry pick of branch 'ban-time-incr' (see gh-716)
-- ticket module prepared to easy merge with newest version of 'ban-time-incr', now additionally holds banTime, banCount and json-data;
-- executeCmd partially moved from action to new module utils, etc.
-- python 2.6 compatibility;
- testExecuteTimeoutWithNastyChildren: test case repaired - wait for pid file inside bash, kill tree in any case (gh-1155);
- testSocket: test case repaired - wait for server thread starts a socket (listener)
2015-12-29 12:49:19 +01:00
sebres
d22b2498d4
normalizing time config entries: use time abbreviation (str2seconds) for all time options such 'dbpurgeage', 'bantime', 'findtime', ex.: default '1d' instead '86400';
...
code review and test case extended;
2015-12-29 12:49:10 +01:00
sebres
dad4234beb
The tricky bug fixed - last position of log file will be never retrieved ( #795 ):
...
addJail (executed before addLog) early uses a "INSERT OR REPLACE" statement to update "enabled" to 1 (and add jail the first time used at once), but this syntax in sqlite always deletes an entry (cause of constraint) and inserts it again, so because of CASCADE all log entries with this jail will be also deleted from logs table.
2015-12-29 12:49:08 +01:00
sebres
95c2a2976f
unbanip always deletes ip from database (independent of bantime, also if currently not banned or persistent);
...
merged from #716 where it works;
closes gh-972, closes gh-768
2015-07-10 13:56:26 +02:00
Lee Clemens
fdc3172aec
Fix PEP8 E302 expected 2 blank lines, found X
2015-07-04 13:47:40 -04:00
Lee Clemens
60c5c6951c
Fix PEP8 E301 expected 1 blank line, found 0
2015-07-04 13:23:08 -04:00
Lee Clemens
7667712909
Fix pep8 E401 multiple imports on one line
2015-06-26 12:51:19 -04:00
Yaroslav Halchenko
9339293413
ENH: minor formatting, no functional changes
2015-03-23 21:26:17 -04:00
sebres
5ab30c88c2
more stable handling of json dump/load different encoded strings for older python versions;
...
extended test cases (more precise, python version insensitive, etc.)
2015-02-25 22:14:49 +01:00
sebres
6c788a32ee
BF: binding parameter error (unsupported type) by writing json with invalid encoded lines into sqlite database (gh-973);
...
especially python < 3.0; try to prevent occurring such errors in the future;
2015-02-25 11:56:11 +01:00
sebres
518cc92ccc
actions: bug fix in lambdas in checkBan, because getBansMerged could return None (purge resp. asynchronous addBan), make the logic all around more stable;
...
test cases: extended with test to check action together with database functionality (ex.: to verify lambdas in checkBan);
database: getBansMerged should work within lock, using reentrant lock (cause call of getBans inside of getBansMerged);
2014-10-29 12:36:21 +01:00
Steven Hiscocks
01d02ca5e6
BF: Remove manually unbanned IPs from persistent database
...
Stops them being restored when Fail2Ban is restarted. Particularly this
is an issue with bantime < 0
Fixes gh-768
2014-07-19 15:17:32 +01:00
Sean DuBois
ac9fa90625
BF: Round timeofban before inserting into the persistant database
2014-07-17 21:57:52 +00:00
Steven Hiscocks
4fc7f1a831
ENH: Tweak naming of getF2BLogger, and ensure consistent use
2014-06-10 20:36:19 +01:00
Steven Hiscocks
e8131475cd
ENH: Realign and harmonise log messages with getF2BLogger helper
2014-06-09 22:17:00 +01:00
Steven Hiscocks
bbcbefd494
BF: bantime < 0 database should return all bans, as they are persistent
2014-04-22 19:20:44 +01:00
Steven Hiscocks
dc24d3d494
BF: On jail restart reinstatement of bans, fetch one ticket per IP
...
Closes gh-664
2014-03-29 21:44:39 +00:00
Ruben Kerkhof
1695d5c076
Fix a few typos
...
Found with https://github.com/lucasdemarchi/codespell
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2014-03-24 13:16:52 +00:00
Steven Hiscocks
689ed9d511
DOC: Fix up doc strings styling to comply with numpy doc style
2014-02-27 20:46:48 +00:00
Steven Hiscocks
edd0bf7d46
ENH+DOC: Update Fail2Ban database doc strings and use properties
2014-02-23 18:38:22 +00:00
Steven Hiscocks
df8d700d17
RF: Refactor Jail and JailThread
...
Includes:
- documentation to new format and use of properties
- change isActive->is_active as former no longer documented for
python3, and later introduction and documented in python2.6
- status formatter in beautifier somewhat more automatically
formatted; no changes are required for additional status elements
- JailThread now set to active within `start` method, complimenting
`stop` method
2014-02-23 17:41:14 +00:00
Steven Hiscocks
a9f0545d8f
BF: Add threading lock to database
2014-02-09 23:16:36 +00:00
Steven Hiscocks
a070284a18
ENH: Change all imports to "." style relative imports
2014-01-04 13:19:09 +00:00
Daniel Black
41bd0470bd
TST: table create definitations to end in ; for py26 compatibility
2013-12-26 21:28:46 +00:00
Daniel Black
8a25dd2dad
ENH: change addLog to use single SQL statement
...
ENH: separate out the database creation defination to make updates
easier
TST: add test framework for updates
2013-12-26 05:46:38 +00:00
Steven Hiscocks
fb7511fdea
ENH: Add cache for database getBansMerged
...
This is avoids duplicate queries when using the ip(jail)matches and
ip(jail)failures in actions
2013-12-15 21:52:50 +00:00
Steven Hiscocks
40007abc1d
ENH: Refactor and add database matches and failures for sendmail actions
2013-12-15 21:41:43 +00:00
Steven Hiscocks
d6cbc05e35
ENH: Make use of functools.wraps for server.database decorators
2013-12-15 21:10:11 +00:00
Steven Hiscocks
00ecd22851
ENH: Add getBansMerged method to Fail2BanDb
...
Creates a single ticket for an IP, made up of all previous bans
2013-12-12 22:22:30 +00:00
Steven Hiscocks
174f9a243a
ENH: Remove thread locks from Fail2BanDb
2013-12-08 22:03:57 +00:00
Steven Hiscocks
7f063b46f9
BF: Improve handling of clearing old jails in database
2013-12-08 11:40:40 +00:00
Steven Hiscocks
bbadef847b
ENH: Add fail2ban persistent data storage
2013-12-07 23:23:28 +00:00