import {countryForIP} from "./maxmind.js"; const bannedCountries = [ 'US', // FFS 'PR', // FFS (different country?!) // OFAC country bans 'CU', // Cuba 'IR', // Iran 'KP', // North Korea 'SY', // Syria 'RU', // Russia 'BY', // Belarus ] export function approveWallet(walletAddress) { // todo OFAC lookup return true } function approveIP(ipAddress) { try { const country = countryForIP(ipAddress) if (!country) return false const approved = !bannedCountries.includes(country) if (!approved) // todo log ban & report console.warn(`IP ${ipAddress} from ${country} is banned`) console.debug(`IP ${ipAddress} from ${country} is ${approved ? 'approved' : 'rejected'}`) return approved } catch (e) { console.warn(`IP lookup failed for ${ipAddress}: ${e.message}`) return false } } export function approveRegion(socket, bypass) { const ipAddress = socket.handshake.address const debug = bypass === process.env.DEXORDER_REGION_APPROVAL; const approved = debug || approveIP(ipAddress) socket.emit('approvedRegion', approved) if(debug) console.info(`approved admin at ${ipAddress}`) }