@samitouri / QOSami-HFS / commits / 62e49998

fix: admin/logs: faulty blocking of an ip that's already part of a disabled rule

Massimo Melina committed Feb 21, 2025 at 18:33 UTC 62e499986271c897a5b7388923f24f0fd3603bdb
1 file changed +1 -1
src/block.ts
+1 -1
@@ -43,7 +43,7 @@ export function addBlock(rule: BlockingRule, merge?: Partial<BlockingRule>) {
43 if (isIP(rule.ip) && isBlocked(rule.ip)) return // already
44 block.set(was => {
45 const foundIdx = merge ? _.findIndex(was, merge) : -1
46 - return foundIdx < 0 ? [...was, { ...merge, ...rule }]
46 + return foundIdx < 0 || was[foundIdx]?.disabled ? [...was, { ...merge, ...rule }] // add as new rule
47 : netMatches(rule.ip, was[foundIdx]!.ip) ? was // in case the rule is disabled, and isBlocked returned false
48 : was.map((x, i) => i === foundIdx ? { ...x, ...rule, ip: `${x.ip}|${rule.ip}` } : x)
49 })