WKnak / fail2ban-block-ip-range

A python script to block attacks from a network range address, from CIDR /23 up to /31
25 stars 15 forks source link

Add compatibility to older versions of fail2ban #22 #23

Closed WKnak closed 4 months ago

WKnak commented 4 months ago

Changed the way we get the status of an already banned IP/network to be compatible with older versions of Fail2Ban (for example, version 0.11.1+). See issue #22 for more details. Please review this pull request, it will be merged in couple days :-)

pbiering commented 4 months ago

See my comment in https://github.com/WKnak/fail2ban-block-ip-range/issues/22#issuecomment-2193866992, at least on 0.11.2 it's working fine.

In case <= 0.11.1 really behave different, I would strongly suggest checking for the fail2ban-client version on startup and then conditionally fall back to more cpu expensive code.

WKnak commented 4 months ago

Now it detectes if fail2ban is able to run the new "get banned ip command" in the new and more efficient way (I suppose), and only if it fails, it falls back to use the legacy "get jail IP list command".

Additionally to that, some refactory was made. I kept the new classes all toghether in the same file so it is easier to deploy a single file.