mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-05 02:06:41 +00:00
Check country code
This commit is contained in:
@@ -948,7 +948,7 @@ async function checkRules(
|
|||||||
} else if (
|
} else if (
|
||||||
clientIp &&
|
clientIp &&
|
||||||
rule.match == "COUNTRY" &&
|
rule.match == "COUNTRY" &&
|
||||||
(await isIpInGeoIP(clientIp, rule.value))
|
(await isIpInGeoIP(ipCC, rule.value))
|
||||||
) {
|
) {
|
||||||
return rule.action as any;
|
return rule.action as any;
|
||||||
}
|
}
|
||||||
@@ -1077,15 +1077,13 @@ export function isPathAllowed(pattern: string, path: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function isIpInGeoIP(
|
async function isIpInGeoIP(
|
||||||
ipCountryCode: string,
|
ipCountryCode: string | undefined,
|
||||||
checkCountryCode: string
|
checkCountryCode: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (checkCountryCode == "ALL") {
|
if (checkCountryCode == "ALL") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(`IP ${ipCountryCode} is in country: ${checkCountryCode}`);
|
|
||||||
|
|
||||||
return ipCountryCode?.toUpperCase() === checkCountryCode.toUpperCase();
|
return ipCountryCode?.toUpperCase() === checkCountryCode.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user