fix: block.expire not working
Massimo Melina committed
May 5, 2024 at 22:49 UTC
f30b92ab1572c73c33ea5b01ef43eef55944b31b
1 file changed
+2
-2
src/block.ts
+2
-2
@@ -7,12 +7,12 @@ import { Socket } from 'net'
7
8
interface BlockingRule { ip: string, comment?: string, expire?: Date, disabled?: boolean }
9
10
-const block = defineConfig('block', [] as BlockingRule[], rules => {
10
+export const block = defineConfig('block', [] as BlockingRule[], rules => {
11
const now = new Date()
12
const ret = !Array.isArray(rules) ? []
13
: onlyTruthy(rules.map(rule => {
14
rule.expire &&= new Date(rule.expire)
15
- return !rule.disabled && (rule.expire || now) <= now && makeNetMatcher(rule.ip)
15
+ return !rule.disabled && (rule.expire || now) >= now && makeNetMatcher(rule.ip)
16
}))
17
// reapply new block to existing connections
18
for (const { socket, ip } of getConnections())