ip block brave
This commit is contained in:
parent
836e7d5e44
commit
b2f8dfbdf9
|
@ -36,10 +36,17 @@ export default function useIpAddress() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkIpLocation = async () => {
|
const checkIpLocation = async () => {
|
||||||
const response = await fetch(`https://www.cloudflare.com/cdn-cgi/trace`)
|
let ipCountryCode
|
||||||
const parsedResponse = await response.text()
|
try {
|
||||||
const ipLocation = parsedResponse.match(/loc=(.+)/)
|
const response = await fetch(`https://www.cloudflare.com/cdn-cgi/trace`)
|
||||||
const ipCountryCode = ipLocation ? ipLocation[1] : ''
|
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) {
|
if (ipCountryCode) {
|
||||||
setIpAllowed(!SANCTIONED_COUNTRY_CODES.includes(ipCountryCode))
|
setIpAllowed(!SANCTIONED_COUNTRY_CODES.includes(ipCountryCode))
|
||||||
|
|
Loading…
Reference in New Issue