firewall: max 65536 elements
This commit is contained in:
@@ -76,6 +76,7 @@ async function setBlocklist(blocklist, auditSource) {
|
||||
|
||||
const parsedIp = ipaddr.process(auditSource.ip);
|
||||
|
||||
let count = 0;
|
||||
for (const line of blocklist.split('\n')) {
|
||||
if (!line || line.startsWith('#')) continue;
|
||||
const rangeOrIP = line.trim();
|
||||
@@ -88,8 +89,10 @@ async function setBlocklist(blocklist, auditSource) {
|
||||
const parsedRange = ipaddr.parseCIDR(rangeOrIP); // returns [addr, range]
|
||||
if (parsedRange[0].kind() === parsedIp.kind() && parsedIp.match(parsedRange)) throw new BoxError(BoxError.BAD_FIELD, `${rangeOrIP} includes client IP. Cannot block yourself`);
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
||||
if (count >= 65536) throw new BoxError(BoxError.CONFLICT, 'Blocklist is too large. Max 65536 entries are allowed'); // https://ipset.netfilter.org/ipset.man.html (maxelem)
|
||||
if (constants.DEMO) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode');
|
||||
|
||||
// store in blob since the value field is TEXT and has 16kb size limit
|
||||
|
||||
Reference in New Issue
Block a user