ADL-008
Country detection and VPN gating with Anti-Proxy
Offers are priced per country and void on proxies, so the country you send and the proxy check you run decide whether your conversions survive.
Offerwall inventory is country-specific and advertisers reverse completions that came through a proxy. Both facts land on you: send the wrong country and the feed is wrong, let proxy traffic through and the reversals arrive later.
Anti-Proxy answers both questions in one call — the country to request the feed with, and whether this visitor looks like a proxy or VPN.
Gate the offers, not the site. A VPN user who can still read your pages and do the non-paying parts is a user; one who gets a blank page is gone.
function adslab_ip_check(string $apiKey, string $ip): array
{
$body = fetch_guarded(
'https://adslab.me/api/anti-proxy?key=' . rawurlencode($apiKey) . '&ip=' . rawurlencode($ip),
8
);
$d = $body === null ? null : json_decode($body, true);
if (!is_array($d)) {
// Unknown. Do not treat an outage as "everyone is a proxy".
return ['country' => '', 'proxy' => false, 'known' => false];
}
return [
'country' => strtoupper((string) ($d['country'] ?? $d['country_code'] ?? '')),
'proxy' => (bool) ($d['proxy'] ?? $d['is_proxy'] ?? false),
'known' => true,
];
}
function offers_for_visitor(PDO $pdo, array $user): array
{
$check = adslab_ip_check(setting('adslab_api_key'), client_ip());
// Cache per address for the session: one lookup, not one per page view.
if ($check['known'] && $check['proxy'] && setting_bool('block_proxy_offers', true)) {
return []; // the page still renders
}
$country = $check['country'] !== '' ? $check['country'] : setting('default_country', 'US');
return adslab_tasks(setting('adslab_task_pid'), setting('adslab_api_key'),
$country, (string) $user['id'], client_ip());
}
Using it
Cache the result per address for the session. It is a network call and the answer does not change between page loads.
Tell the user why the list is empty. "Offers are not available over a VPN" prevents the ticket; an empty page does not.
Record the country you used on each completion. When an advertiser disputes one, that is the field they will ask about.
What bites people
Treat an unreachable check as unknown, not as proxy. Failing closed on an outage empties every user's task list at once.
Country from the address can be wrong for mobile carriers. It is good enough for feed selection and not good enough to accuse anyone of anything.
Blocking the whole site for VPN users costs you the search traffic too, since some crawlers arrive through addresses that look like datacentres — because they are.