From bc13342e0627aad48abf83831351c058dc099b92 Mon Sep 17 00:00:00 2001 From: ppom Date: Mon, 8 Jan 2024 12:00:00 +0100 Subject: [PATCH] Add banFor snippet to jsonnet example --- config/example.jsonnet | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/example.jsonnet b/config/example.jsonnet index 516feb4..25075a1 100644 --- a/config/example.jsonnet +++ b/config/example.jsonnet @@ -8,6 +8,17 @@ local iptables(args) = ['ip46tables', '-w'] + args; // ip46tables is a minimal C program (only POSIX dependencies) present in a subdirectory of this repo. // it permits to handle both ipv4/iptables and ipv6/ip6tables commands +// See meaning and usage of this function around L106 +local banFor(time) = { + ban: { + cmd: iptables(['-A', 'reaction', '-s', '', '-j', 'DROP']), + }, + unban: { + after: time, + cmd: iptables(['-D', 'reaction', '-s', '', '-j', 'DROP']), + }, +}; + { // patterns are substitued in regexes. // when a filter performs an action, it replaces the found pattern @@ -91,6 +102,8 @@ local iptables(args) = ['ip46tables', '-w'] + args; // (with the stop commands) }, }, + // or use the banFor function defined at the beginning! + // actions: banFor('48h'), }, }, },