diff --git a/src/lib/detect.ts b/src/lib/detect.ts index 2e78a1f35..6bba1596f 100644 --- a/src/lib/detect.ts +++ b/src/lib/detect.ts @@ -140,31 +140,31 @@ export async function getClientInfo(request: Request, payload: Record n.trim())); + const ips = ignoreIps.split(',').map(n => n.trim()); + + return ips.find(ip => { + if (ip === clientIp) { + return true; } - return ips.find(ip => { - if (ip === clientIp) { - return true; - } - - // CIDR notation - if (ip.indexOf('/') > 0) { + // CIDR notation + if (ip.indexOf('/') > 0) { + try { const addr = ipaddr.parse(clientIp); const range = ipaddr.parseCIDR(ip); if (addr.kind() === range[0].kind() && addr.match(range)) { return true; } + } catch { + // Ignore parsing errors } + } - return false; - }); - } - - return false; + return false; + }); }