diff --git a/server/routers/badger/verifySession.ts b/server/routers/badger/verifySession.ts index d3076ec4d..987d7e061 100644 --- a/server/routers/badger/verifySession.ts +++ b/server/routers/badger/verifySession.ts @@ -1054,7 +1054,10 @@ async function checkRules( isPathAllowed(rule.value, path) ) { return rule.action as any; - } else if (clientIp && rule.match == "COUNTRY") { + } else if ( + clientIp && + (rule.match === "COUNTRY" || rule.match === "COUNTRY_IS_NOT") + ) { // COUNTRY=ALL should not affect local/private/CGNAT addresses. if ( rule.value.toUpperCase() === "ALL" && @@ -1063,7 +1066,10 @@ async function checkRules( continue; } - if (await isIpInGeoIP(ipCC, rule.value)) { + const inCountry = await isIpInGeoIP(ipCC, rule.value); + const matched = rule.match === "COUNTRY" ? inCountry : !inCountry; + + if (matched) { return rule.action as any; } } else if (clientIp && rule.match == "ASN") {