Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/staking/src/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export const MAINNET_RPC = process.env.MAINNET_RPC;
export const HERMES_URL = getOr("HERMES_URL", "https://hermes.pyth.network");
export const BLOCKED_REGIONS = transformOr("BLOCKED_REGIONS", fromCsv, []);
export const IP_ALLOWLIST = transformOr("IP_ALLOWLIST", fromCsv, []);
export const VPN_ORGANIZATION_ALLOWLIST = transformOr(
"VPN_ORGANIZATION_ALLOWLIST",
fromCsv,
["iCloud Private Relay"],
);
export const GOVERNANCE_ONLY_REGIONS = transformOr(
"GOVERNANCE_ONLY_REGIONS",
fromCsv,
Expand Down
10 changes: 8 additions & 2 deletions apps/staking/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
GOVERNANCE_ONLY_REGIONS,
PROXYCHECK_API_KEY,
IP_ALLOWLIST,
VPN_ORGANIZATION_ALLOWLIST,
} from "./config/server";

const GEO_BLOCKED_PATH = `/${GEO_BLOCKED_SEGMENT}`;
Expand Down Expand Up @@ -61,8 +62,13 @@ const isProxyBlocked = async ({ ip }: NextRequest) => {
if (proxyCheckClient === undefined || ip === undefined) {
return false;
} else {
const result = await proxyCheckClient.checkIP(ip, { vpn: 2 });
return result[ip]?.proxy === "yes";
const response = await proxyCheckClient.checkIP(ip, { vpn: 2 });
const result = response[ip];
return (
result &&
result.proxy === "yes" &&
!VPN_ORGANIZATION_ALLOWLIST.includes(result.organisation)
);
}
};

Expand Down
Loading