>>>> "ZJ" == Zbigniew Jędrzejewski-Szmek
<zbyszek(a)in.waw.pl> writes:
ZJ> I you post the code somewhere, I could have a look.
It's in the upstream "journal" branch of the denyhosts source:
https://github.com/denyhosts/denyhosts/tree/journal
https://github.com/denyhosts/denyhosts/commit/d0d66a2890d50a460ecd20ee0b1...
The meat is in DenyHosts/deny_hosts.py. The code is mostly a mess
because it's an attempt to cram journal processing into an existing main
loop, and a lot of the diff is just reindentation. My intent was to
make sure the simple approach worked first and then refactor things to
make it less unpleasant.
Really all it's doing is "self.__journal = journal.Reader()", then
adding some match clauses with disjunctions in between, and maybe
loading a saved cursor and seeking to it. The main loop is just doing
"for entry in self.__journal:", but after running for some long period
of time (usually days) that ends up blocking forever waiting for the
next entry.
The code to deal with the journal really is trivial when compared to
polling to see if a logfile has changed, and then opening and seeking
and everything. It's just that, well, it would simply stop working.
- J<