const http = require('http'); const httpProxy = require('http-proxy'); const { spawn } = require('child_process'); const fs = require('fs'); // 1. SIAPKAN DNS PALSU (Nancep Langsung) if (!fs.existsSync('/tmp/dns')) fs.mkdirSync('/tmp/dns', { recursive: true }); fs.writeFileSync('/tmp/dns/resolv.conf', "nameserver 8.8.8.8\nnameserver 1.1.1.1"); // 2. JALANKAN TTYD (Internal Port 8080) // Kita pake proot biar DNS nancep nyata di /etc/resolv.conf const ttyd = spawn('ttyd', [ '-p', '8080', '-W', 'proot', '-b', '/tmp/dns/resolv.conf:/etc/resolv.conf', 'bash' ]); const proxy = httpProxy.createProxyServer({ ws: true }); // 3. GATEWAY PORT 7860 (Satu-satunya pintu HF) const server = http.createServer((req, res) => { if (req.url.startsWith('/terminal')) { req.url = req.url.replace('/terminal', ''); proxy.web(req, res, { target: 'http://127.0.0.1:8080' }); } else { // PENYAMARAN: Halaman Riset AI res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(`
Status: Operational
DNS: Secured (8.8.8.8)