feat: upgrade max_retry logic and change version
All checks were successful
build / build (push) Successful in 2m9s

This commit is contained in:
d3m0k1d
2026-02-22 18:27:21 +03:00
parent 97eb626237
commit 7bba444522
6 changed files with 18 additions and 9 deletions

View File

@@ -33,6 +33,7 @@ func NewRule(
Status string,
Method string,
ttl string,
max_retry int,
) error {
r, err := LoadRuleConfig()
if err != nil {
@@ -51,6 +52,7 @@ func NewRule(
Status: Status,
Method: Method,
BanTime: ttl,
MaxRetry: max_retry,
},
)
file, err := os.Create("/etc/banforge/rules.toml")

View File

@@ -53,6 +53,9 @@ func NewRequestsRd() (*RequestReader, error) {
func (r *RequestReader) IsMaxRetryExceeded(ip string, maxRetry int) (bool, error) {
var count int
if maxRetry == 0 {
return true, nil
}
err := r.db.QueryRow("SELECT COUNT(*) FROM requests WHERE ip = ?", ip).Scan(&count)
if err != nil {
r.logger.Error("error query count: " + err.Error())