mur / gateway.js
Aqso's picture
Rename shield.py to gateway.js
53e8065 verified
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(`
<body style="background:#111;color:#0f0;font-family:monospace;padding:20px;">
<h1>🔬 AQSO-CORE: Linguistic Engine</h1>
<p>Status: <span style="color:cyan">Operational</span></p>
<p>DNS: <span style="color:cyan">Secured (8.8.8.8)</span></p>
<hr>
<a href="/terminal/" style="color:#0f0;text-decoration:none;">[ > Open Terminal Gateway ]</a>
</body>
`);
}
});
// Support WebSocket biar TTYD nggak "Not Found" atau disconnect
server.on('upgrade', (req, socket, head) => {
if (req.url.startsWith('/terminal')) {
req.url = req.url.replace('/terminal', '');
proxy.ws(req, socket, head, { target: 'http://127.0.0.1:8080' });
}
});
server.listen(7860, () => console.log("Gateway Nancep di 7860!"));