From 1bd6f240ccb9433276b029d25a6287cbba409e1f Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 26 Jun 2026 23:18:46 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20add=20Country=20`is=20not`?= =?UTF-8?q?=20rule=20to=20`verifySession`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/routers/badger/verifySession.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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") {