diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-02-02 05:39:08 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-02-02 05:44:32 -0800 |
commit | 844ef76853914d83ccd2c4390ce92811c606b717 (patch) | |
tree | 3efd736ade99efe3d1033cfdad231faf773b7a03 /txrban.txr | |
parent | d3537462d567dcd80c060af9c602ddc618f4255b (diff) | |
download | txrban-844ef76853914d83ccd2c4390ce92811c606b717.tar.gz txrban-844ef76853914d83ccd2c4390ce92811c606b717.tar.bz2 txrban-844ef76853914d83ccd2c4390ce92811c606b717.zip |
Implement *dry-run* variable for testing.
Diffstat (limited to 'txrban.txr')
-rw-r--r-- | txrban.txr | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -54,7 +54,8 @@ (new-until (+ time howlong))) (cond ((not cli.banned) - (sh `@{*off*}iptables -I INPUT 1 -s @{cli.ip} -i @{*iface*} -j DROP`) + (unless *dry-run* + (sh `@{*off*}iptables -I INPUT 1 -s @{cli.ip} -i @{*iface*} -j DROP`)) (debug "banned ~a for ~a starting on ~a\n" cli.ip (hrtime howlong) (time-string-local time "%c")) (set cli.banned (rcons time new-until))) @@ -85,11 +86,14 @@ (unban cli)))) (defun unban (cli) - (sh `@{*off*}iptables -D INPUT -s @{cli.ip} -i @{*iface*} -j DROP`) + (unless *dry-run* + (sh `@{*off*}iptables -D INPUT -s @{cli.ip} -i @{*iface*} -j DROP`)) (debug "unbanned ~a\n" cli.ip) (set cli.banned nil)) (cond - (t (daemon nil nil) - (openlog `txrban-@self` log-pid log-authpriv)) - (nil (set *stdlog* *stdout*)))) + (*dry-run* + (set *stdlog* *stdout*)) + (t + (daemon nil nil) + (openlog `txrban-@self` log-pid log-authpriv)))) |