fix: prevent empty "block" ip
Massimo Melina committed
Nov 5, 2023 at 23:45 UTC
9923e6153fd2d7796c028180ea1ca0082efed940
2 files changed
+2
-2
admin/src/OptionsPage.ts
+1
-1
@@ -183,7 +183,7 @@ export default function OptionsPage() {
183
},
184
{ k: 'block', label: false, comp: ArrayField, prepend: true, sm: 12,
185
fields: [
186
- { k: 'ip', label: "Blocked IP", sm: 6, helperText: h(WildcardsSupported) },
186
+ { k: 'ip', label: "Blocked IP", sm: 6, required: true, helperText: h(WildcardsSupported) },
187
{ k: 'expire', $type: 'dateTime', minDate: new Date(), sm: 6, helperText: "Leave empty for no expiration" },
188
{ k: 'comment' },
189
],
src/block.ts
+1
-1
@@ -12,7 +12,7 @@ const block = defineConfig('block', [] as BlockingRule[], rules => {
12
const ret = !Array.isArray(rules) ? []
13
: onlyTruthy(rules.map(rule => {
14
rule.expire &&= new Date(rule.expire)
15
- return !(rule.expire! > now) && makeNetMatcher(rule.ip, true)
15
+ return !(rule.expire! > now) && makeNetMatcher(rule.ip)
16
}))
17
// reapply new block to existing connections
18
for (const { socket, ip } of getConnections())