vpn 차단 자바스크립트
본문
<script>
async function getClientIP() {
try {
const response = await fetch('https://api64.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
console.error('Error fetching client IP:', error);
return null;
}
}
async function detectVPNAndRedirect() {
const ip = await getClientIP();
if (!ip) {
console.error('Unable to retrieve IP address.');
return;
}
const apiUrl = `https://api.ipquery.io/${ip}`;
try {
const response = await fetch(apiUrl);
const data = await response.json();
if (data.risk && (data.risk.is_vpn || data.risk.is_proxy || data.risk.is_tor || data.risk.is_datacenter)) {
// Redirect VPN/proxy/Tor/datacenter users to block.html
window.location.href = '/block.html';
} else {
console.log(`The IP address ${ip} is not associated with a VPN, proxy, Tor, or datacenter.`);
}
} catch (error) {
console.error('Error while detecting VPN:', error);
}
}
// Call the function to detect VPN and redirect if necessary
detectVPNAndRedirect();
</script>
카테고리 분류 학습 시스템 (총 0개 학습됨)
이 분류가 맞나요? 학습시켜주세요!
등록된 댓글이 없습니다.