feat: simplified logs for regex + added xban (hooks) support

This commit is contained in:
Lomain 2026-03-23 23:13:55 +01:00
parent de3937721a
commit bae82d00df

View file

@ -1,16 +1,27 @@
# /!\ Warning: be careful, as webdav clients often generate a large number of 404 requets.
# In your `jail.local`, add: # In your `jail.local`, add:
# [copyparty] # [copyparty]
# enabled = true # enabled = true
# logtimezone = UTC
# logpath = /path/to/log/file # or keep the default value if you're using systemd # logpath = /path/to/log/file # or keep the default value if you're using systemd
# Create the `copyparty.conf` file in `filter.d` with the following: # Create the `copyparty.conf` file in `filter.d` with the following:
# [Definition] # [Definition]
# failregex = ^ fail2ban\s*WARN: <ADDR>$ # failregex = ^ <ADDR>$
# ignoreregex = # ignoreregex =
# datepattern = ^%%H:%%M:%%S\.%%f # datepattern = ^fail2ban: %%Y-%%m-%%dT%%H:%%M:%%S
# First check `--dont-ban`, and if it doesn't match, log the line to be intercepted by fail2ban. # First check `--dont-ban`, and if it doesn't match, log the line to be intercepted by fail2ban.
def main(cli, vn, rem): from datetime import datetime, UTC
def main(cli, vn="", rem=""):
now = datetime.now(UTC).isoformat()[:19]
msg = "\nfail2ban: %s %s"
if not vn and not rem:
# got called by --xban
cli["log"](msg % (now, cli["ip"]), 3)
return {"rc": 0}
cond = cli.args.dont_ban cond = cli.args.dont_ban
if ( if (
cond == "any" cond == "any"
@ -21,5 +32,5 @@ def main(cli, vn, rem):
): ):
return "" return ""
cli.log_func("fail2ban", f"{cli.ip}", 3) cli.log(msg % (now, cli.ip), 3)
return "" return ""