"use client"; import Link from "next/link"; import { useState, useEffect, useRef } from "react"; /** Total time for the progress bar to reach 100% (ms). */ const DURATION_MS = 3500; /** Hard cap — always complete after this (ms) even if something glitches. */ const MAX_WAIT_MS = 9000; /** Wall-clock polling (Tor Browser throttles requestAnimationFrame aggressively). */ const TICK_MS = 50; export default function DDoSProtection({ onComplete }: { onComplete: () => void }) { const [progress, setProgress] = useState(0); const [status, setStatus] = useState("Checking your browser…"); const [rayId, setRayId] = useState(""); const doneRef = useRef(false); const onCompleteRef = useRef(onComplete); onCompleteRef.current = onComplete; const finish = () => { if (doneRef.current) return; doneRef.current = true; setProgress(100); setStatus("Access granted."); window.setTimeout(() => onCompleteRef.current(), 400); }; useEffect(() => { setRayId(Math.random().toString(36).substring(2, 10).toUpperCase()); }, []); useEffect(() => { const start = Date.now(); doneRef.current = false; const progressInterval = window.setInterval(() => { const elapsed = Date.now() - start; const pct = Math.min(100, (elapsed / DURATION_MS) * 100); setProgress(pct); if (pct >= 100 || elapsed >= MAX_WAIT_MS) { window.clearInterval(progressInterval); finish(); } }, TICK_MS); const statusUpdates = [ "Checking your browser…", "Verifying client challenge…", "Analyzing request signature…", "Negotiating TLS + Tor circuit…", "Establishing encrypted tunnel…", "Access granted.", ]; let statusIndex = 0; const statusInterval = window.setInterval(() => { if (statusIndex < statusUpdates.length - 1) { statusIndex++; setStatus(statusUpdates[statusIndex]!); } else { clearInterval(statusInterval); } }, 650); const maxTimer = window.setTimeout(() => { if (!doneRef.current) finish(); }, MAX_WAIT_MS); return () => { window.clearInterval(progressInterval); clearInterval(statusInterval); clearTimeout(maxTimer); }; }, []); return (
Origin shield active — wait while we validate your session. Automated requests are throttled at the edge.
Stuck on Tor or slow device? Tap above — no challenge required.
Tor-ready ingress · verify circuit ·{" "} /launch