Skip to content

Commit

Permalink
Merge pull request #2011 from cprussin/allow-icloud
Browse files Browse the repository at this point in the history
feat(staking): allow icloud public relay
  • Loading branch information
cprussin authored Oct 8, 2024
2 parents b533d40 + 97c0bfe commit a32f485
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit a32f485

Please sign in to comment.