/** * 해외 접속 차단 스크립트 (Access Blocking) - V3 (Premium API with IPInfo) * * 변경사항: * - 1순위 API로 'ipinfo.io' (Token 적용) 사용 -> 데이터센터/VPN 감지 능력 대폭 향상 * - 기존 무료 API(ipwho.is 등)는 백업용으로 유지 (이중 안전장치) * - 디버깅 로그 유지 */ (function () { // 0. 설정 var ALLOWED_TIMEZONE = 'Asia/Seoul'; var ALLOWED_COUNTRY_CODE = 'KR'; // GeoIP 서비스 목록 (우선순위: Premium -> Free Backup) var GEO_IP_APIS = [ // [Primary] ipinfo.io (가장 정확하고 빠름, 데이터센터 IP 식별 가능) { url: 'https://ipinfo.io/json?token=e9106b0bc143ae', field: 'country' }, // [Backup 1] ipwho.is (CORS 친화적) { url: 'https://ipwho.is/', field: 'country_code' }, // [Backup 2] ipapi.co (일부 브라우저 차단 가능성 있음) { url: 'https://ipapi.co/json/', field: 'country_code' }, // [Backup 3] db-ip (최후 수단) { url: 'https://api.db-ip.com/v2/free/self', field: 'countryCode' }, ]; // 1. 타임존 확인 (지연 시간 0ms) var userTimezone = ''; try { userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; console.log('[AccessBlocking] User Timezone:', userTimezone); } catch (e) { console.warn('[AccessBlocking] Timezone check failed', e); } // 한국 타임존 사용자는 즉시 통과 (빠른 속도 보장) if (userTimezone === ALLOWED_TIMEZONE) { console.log('[AccessBlocking] Allowed by Timezone (KR).'); return; } // 2. 타임존 비매칭 - 화면 가림 및 정밀 검사 console.warn('[AccessBlocking] Timezone mismatch! Blocking screen and checking IP...'); blockScreen(); checkGeoIpWithFailover(0); // -------------------------------------------------------------------------- function blockScreen() { if (document.getElementById('access-blocking-style')) return; var style = document.createElement('style'); style.id = 'access-blocking-style'; style.innerHTML = ` html, body { display: none !important; height: 100% !important; overflow: hidden !important; background-color: white !important; } `; document.head.appendChild(style); } function unblockScreen(reason) { console.log('[AccessBlocking] Unblocking screen. Reason:', reason); var style = document.getElementById('access-blocking-style'); if (style) style.remove(); } function showAccessDeniedMessage() { console.error('[AccessBlocking] Access Denied. Showing block message.'); unblockScreen('Prepare to show message'); // 기존 가림막 제거 후 메시지 표시 document.body.innerHTML = `
This service is not available in your region.
해외 IP에서의 접속이 제한되어 있습니다.
Error: GEO_BLOCK_LIMIT