From b2f8dfbdf9b7683a7b6425af54d646008b57cfd7 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Tue, 10 Aug 2021 00:43:43 +0200 Subject: [PATCH 1/2] ip block brave --- hooks/useIpAddress.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hooks/useIpAddress.tsx b/hooks/useIpAddress.tsx index 5ce15ff..9368227 100644 --- a/hooks/useIpAddress.tsx +++ b/hooks/useIpAddress.tsx @@ -36,10 +36,17 @@ export default function useIpAddress() { useEffect(() => { const checkIpLocation = async () => { - const response = await fetch(`https://www.cloudflare.com/cdn-cgi/trace`) - const parsedResponse = await response.text() - const ipLocation = parsedResponse.match(/loc=(.+)/) - const ipCountryCode = ipLocation ? ipLocation[1] : '' + let ipCountryCode + try { + const response = await fetch(`https://www.cloudflare.com/cdn-cgi/trace`) + const parsedResponse = await response.text() + const ipLocation = parsedResponse.match(/loc=(.+)/) + ipCountryCode = ipLocation ? ipLocation[1] : '' + } catch { + const response = await fetch(`https://countrycode.bonfida.workers.dev/`) + const parsedResponse = await response.json() + ipCountryCode = parsedResponse.countryCode + } if (ipCountryCode) { setIpAllowed(!SANCTIONED_COUNTRY_CODES.includes(ipCountryCode)) From 3934c54413b5dbe056529d8f6885d17f0f239c50 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Tue, 10 Aug 2021 00:44:28 +0200 Subject: [PATCH 2/2] use cached rpcpool --- stores/useWalletStore.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stores/useWalletStore.tsx b/stores/useWalletStore.tsx index 7b9b619..861d392 100644 --- a/stores/useWalletStore.tsx +++ b/stores/useWalletStore.tsx @@ -26,8 +26,8 @@ import { calculateNativeAmountUnsafe } from '../utils/balance' export const ENDPOINTS: EndpointInfo[] = [ { name: 'mainnet-beta', - url: 'https://mango.rpcpool.com/', - websocket: 'https://mango.rpcpool.com/', + url: 'https://cache-mango.rpcpool.com', + websocket: 'https://cache-mango.rpcpool.com/cache', programId: '6QXNNAPkPsWjd1j3qQJTvRFgSNPARMhF2tE8g1WeGyrM', poolKey: 'AHBj9LAjxStT2YQHN6QdfHKpZLtEVr8ACqeFgYcPsTnr', },