mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
fix: disable ip-cidr on empty cidr list
This commit is contained in:
parent
771fb00d62
commit
cae8e79e0f
@ -11,7 +11,10 @@ export const createIpWhitelistMiddleware = (blockedCIDRs: string[]) => {
|
||||
next: express.NextFunction,
|
||||
) => {
|
||||
const ip = req.ip // or req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||
if (blockedCIDRObjects.some((cidr) => cidr.contains(ip))) {
|
||||
if (
|
||||
blockedCIDRs.length === 0 ||
|
||||
blockedCIDRObjects.some((cidr) => cidr.contains(ip))
|
||||
) {
|
||||
next()
|
||||
} else {
|
||||
res.status(403).send('Nope')
|
||||
|
Loading…
x
Reference in New Issue
Block a user