From c00f86f9d34de8c6c1c7ada6653b3f457fadd828 Mon Sep 17 00:00:00 2001 From: Andrii Kuzmin Date: Fri, 1 Nov 2024 01:10:56 +0200 Subject: [PATCH] fix releasing bot --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index b773ec6..8dcaaba 100644 --- a/main.go +++ b/main.go @@ -104,12 +104,13 @@ func main() { attempts[ip] = 0 if out, err := exec.Command("ufw", "deny", "from", ip).CombinedOutput(); err != nil { slog.Error("exec", "error", string(out)) + } else { + releaseCmd := fmt.Sprintf(`echo "ufw delete deny from %s" | at now + %s`, ip, config.JailDuration) + if out, err = exec.Command("/bin/sh", "-c", releaseCmd).CombinedOutput(); err != nil { + slog.Error("exec", "error", string(out)) + } + slog.Info("jailed", "ip", ip, "term", config.JailDuration) } - releaseCmd := fmt.Sprintf(`echo "ufw delete deny from %s" | at now + %s`, ip, config.JailDuration) - if out, err := exec.Command("/bin/sh", "-c", releaseCmd).CombinedOutput(); err != nil { - slog.Error("exec", "error", string(out)) - } - slog.Info("jailed", "ip", ip, "term", config.JailDuration) } if cmd != "" {