Skip to content

Commit a6130ab

Browse files
committed
debug: log detected IP and ip-api response for VPN check
1 parent a6e6891 commit a6130ab

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

routes/auth.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ const router = Router();
1616
router.get('/check-vpn', async (req, res) => {
1717
try {
1818
const ip = getClientIp(req);
19+
const forwarded = req.headers['x-forwarded-for'] || 'none';
1920
const isVpn = await isVpnOrProxy(ip);
20-
res.json({ vpn: isVpn });
21+
res.json({ vpn: isVpn, ip, forwarded });
2122
} catch {
2223
res.json({ vpn: false });
2324
}
@@ -93,13 +94,16 @@ async function fetchWithTimeout(url, options = {}, timeout = 5000) {
9394
async function isVpnOrProxy(ip) {
9495
if (ip === '127.0.0.1' || ip === '::1' || ip === '0.0.0.0' ||
9596
ip.startsWith('192.168.') || ip.startsWith('10.') || ip.startsWith('172.16.')) {
97+
console.log('[VPN] Skipping private IP:', ip);
9698
return false;
9799
}
98100
try {
99-
const res = await fetchWithTimeout(`https://ip-api.com/json/${ip}?fields=proxy,hosting,query`);
101+
const res = await fetchWithTimeout(`https://ip-api.com/json/${ip}?fields=proxy,hosting,isp,org,query`);
100102
const data = await res.json();
103+
console.log('[VPN] ip-api response for', ip, ':', JSON.stringify(data));
101104
return data.proxy === true || data.hosting === true;
102-
} catch {
105+
} catch (err) {
106+
console.log('[VPN] ip-api failed for', ip, ':', err.message);
103107
return false;
104108
}
105109
}

0 commit comments

Comments
 (0)