| const http = require('http'); |
| const httpProxy = require('http-proxy'); |
| const { spawn } = require('child_process'); |
| const fs = require('fs'); |
|
|
| |
| 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"); |
|
|
| |
| |
| const ttyd = spawn('ttyd', [ |
| '-p', '8080', |
| '-W', |
| 'proot', '-b', '/tmp/dns/resolv.conf:/etc/resolv.conf', |
| 'bash' |
| ]); |
|
|
| const proxy = httpProxy.createProxyServer({ ws: true }); |
|
|
| |
| 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 { |
| |
| 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> |
| `); |
| } |
| }); |
|
|
| |
| 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!")); |
|
|