diff --git a/src/directoryserver.js b/src/directoryserver.js index afcc240c6..19608546a 100644 --- a/src/directoryserver.js +++ b/src/directoryserver.js @@ -56,7 +56,7 @@ async function validateConfig(config) { for (const line of allowlist.split('\n')) { if (!line || line.startsWith('#')) continue; const rangeOrIP = line.trim(); - if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `${rangeOrIP} is not a valid IP or range`); + if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `'${rangeOrIP}' is not a valid IP or range`); gotOne = true; } diff --git a/src/network.js b/src/network.js index e6344c8bf..a55a6bb95 100644 --- a/src/network.js +++ b/src/network.js @@ -78,12 +78,12 @@ async function setBlocklist(blocklist, auditSource) { for (const line of blocklist.split('\n')) { if (!line || line.startsWith('#')) continue; const rangeOrIP = line.trim(); - if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `${rangeOrIP} is not a valid IP or range`); + if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `'${rangeOrIP}' is not a valid IP or range`); if (rangeOrIP.indexOf('/') === -1) { - if (ipaddr.isEqual(rangeOrIP, auditSource.ip)) throw new BoxError(BoxError.BAD_FIELD, `IP ${rangeOrIP} is the client IP. Cannot block yourself`); + if (ipaddr.isEqual(rangeOrIP, auditSource.ip)) throw new BoxError(BoxError.BAD_FIELD, `IP '${rangeOrIP}' is the client IP. Cannot block yourself`); } else { - if (ipaddr.includes(rangeOrIP, auditSource.ip)) throw new BoxError(BoxError.BAD_FIELD, `range ${rangeOrIP} includes client IP. Cannot block yourself`); + if (ipaddr.includes(rangeOrIP, auditSource.ip)) throw new BoxError(BoxError.BAD_FIELD, `range '${rangeOrIP}' includes client IP. Cannot block yourself`); } // this won't work in cases where it's a bigger subnet diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 93af0f70f..c7fb5a718 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -764,7 +764,7 @@ async function setTrustedIps(trustedIps) { for (const line of trustedIps.split('\n')) { if (!line || line.startsWith('#')) continue; const rangeOrIP = line.trim(); - if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `${rangeOrIP} is not a valid IP or range`); + if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `'${rangeOrIP}' is not a valid IP or range`); trustedIpsConfig += `set_real_ip_from ${rangeOrIP};\n`; } diff --git a/src/tokens.js b/src/tokens.js index fc23b5b2e..6f97be74a 100644 --- a/src/tokens.js +++ b/src/tokens.js @@ -87,7 +87,7 @@ function parseIpRanges(ipRanges) { // each line can have comma separated list. this complexity is because we changed the UI to take a line input instead of textarea for (const entry of line.split(',')) { const rangeOrIP = entry.trim(); - if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `${rangeOrIP} is not a valid IP or range`); + if (!ipaddr.isValid(rangeOrIP) && !ipaddr.isValidCIDR(rangeOrIP)) throw new BoxError(BoxError.BAD_FIELD, `'${rangeOrIP}' is not a valid IP or range`); result.push(rangeOrIP); } }