Skip to content

Commit

Permalink
chore!(server/fail2ban): remove notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnvgr committed Nov 16, 2024
1 parent 9030c4b commit 002bdb7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions modules/server/core/fail2ban.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }:
{ lib, config, ... }:
let
inherit (builtins) concatStringsSep;
inherit (lib) mkIf mkOption types optionalString;
inherit (lib) mkIf mkOption types;

cfg = config.modules.server;
notificationsEnabled = cfg.ntfyChannel != null;
Expand All @@ -24,20 +24,12 @@ in {
jails.DEFAULT.settings = {
action = concatStringsSep "\n " [
"%(action_)s[blocktype=DROP]"
(optionalString notificationsEnabled "ntfy")
];

findtime = "4h";
};
};

# TODO: norestored does not work
environment.etc."fail2ban/action.d/ntfy.local".text = optionalString notificationsEnabled ''
[Definition]
norestored = true # Needed to avoid receiving a new notification after every restart
actionban = ${pkgs.curl}/bin/curl -H "Title: New ban! <name>: <ip>" -d "<name>: <ip> (x<failures>)" ntfy.sh/${cfg.ntfyChannel}
'';

# TODO: Auto restart
# FIXME: https://github.com/NixOS/nixpkgs/issues/288436
# systemd.services."fail2ban".restartTriggers = [ ];
Expand Down

0 comments on commit 002bdb7

Please sign in to comment.