Aqso commited on
Commit
53e8065
·
verified ·
1 Parent(s): d60dc4c

Rename shield.py to gateway.js

Browse files
Files changed (2) hide show
  1. gateway.js +49 -0
  2. shield.py +0 -44
gateway.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const http = require('http');
2
+ const httpProxy = require('http-proxy');
3
+ const { spawn } = require('child_process');
4
+ const fs = require('fs');
5
+
6
+ // 1. SIAPKAN DNS PALSU (Nancep Langsung)
7
+ if (!fs.existsSync('/tmp/dns')) fs.mkdirSync('/tmp/dns', { recursive: true });
8
+ fs.writeFileSync('/tmp/dns/resolv.conf', "nameserver 8.8.8.8\nnameserver 1.1.1.1");
9
+
10
+ // 2. JALANKAN TTYD (Internal Port 8080)
11
+ // Kita pake proot biar DNS nancep nyata di /etc/resolv.conf
12
+ const ttyd = spawn('ttyd', [
13
+ '-p', '8080',
14
+ '-W',
15
+ 'proot', '-b', '/tmp/dns/resolv.conf:/etc/resolv.conf',
16
+ 'bash'
17
+ ]);
18
+
19
+ const proxy = httpProxy.createProxyServer({ ws: true });
20
+
21
+ // 3. GATEWAY PORT 7860 (Satu-satunya pintu HF)
22
+ const server = http.createServer((req, res) => {
23
+ if (req.url.startsWith('/terminal')) {
24
+ req.url = req.url.replace('/terminal', '');
25
+ proxy.web(req, res, { target: 'http://127.0.0.1:8080' });
26
+ } else {
27
+ // PENYAMARAN: Halaman Riset AI
28
+ res.writeHead(200, { 'Content-Type': 'text/html' });
29
+ res.end(`
30
+ <body style="background:#111;color:#0f0;font-family:monospace;padding:20px;">
31
+ <h1>🔬 AQSO-CORE: Linguistic Engine</h1>
32
+ <p>Status: <span style="color:cyan">Operational</span></p>
33
+ <p>DNS: <span style="color:cyan">Secured (8.8.8.8)</span></p>
34
+ <hr>
35
+ <a href="/terminal/" style="color:#0f0;text-decoration:none;">[ > Open Terminal Gateway ]</a>
36
+ </body>
37
+ `);
38
+ }
39
+ });
40
+
41
+ // Support WebSocket biar TTYD nggak "Not Found" atau disconnect
42
+ server.on('upgrade', (req, socket, head) => {
43
+ if (req.url.startsWith('/terminal')) {
44
+ req.url = req.url.replace('/terminal', '');
45
+ proxy.ws(req, socket, head, { target: 'http://127.0.0.1:8080' });
46
+ }
47
+ });
48
+
49
+ server.listen(7860, () => console.log("Gateway Nancep di 7860!"));
shield.py DELETED
@@ -1,44 +0,0 @@
1
- import subprocess
2
- import os
3
- import gradio as gr
4
-
5
- def start_all():
6
- # 1. SIAPKAN DNS PALSU
7
- dns_content = "nameserver 8.8.8.8\nnameserver 1.1.1.1"
8
- os.makedirs("/tmp/dns", exist_ok=True)
9
- with open("/tmp/dns/resolv.conf", "w") as f:
10
- f.write(dns_content)
11
-
12
- # 2. JALANKAN TTYD (Tambahin base-path biar gak Not Found)
13
- # Kita pake --base-path /proxy/8080 biar sinkron sama HF
14
- ttyd_cmd = [
15
- "ttyd", "-p", "8080",
16
- "-W",
17
- "proot", "-b", "/tmp/dns/resolv.conf:/etc/resolv.conf",
18
- "bash"
19
- ]
20
- subprocess.Popen(ttyd_cmd)
21
-
22
- # 3. DECOY INTERFACE
23
- def fake_ai(text): return f"Linguistic Analysis: {text}"
24
-
25
- with gr.Blocks(title="AQSO-CORE Research") as demo:
26
- gr.Markdown("# 🔬 AQSO-CORE Linguistic Research")
27
-
28
- # LINK SAKTI: Wajib pake garis miring di akhir /
29
- space_id = os.getenv('SPACE_ID', 'Aqso/mur').replace('/', '-')
30
- direct_url = f"https://{space_id}.hf.space/proxy/8080/"
31
-
32
- gr.Markdown(f"## 🛠️ [KLIK DISINI MASUK TERMINAL]({direct_url})")
33
- gr.Markdown("> **PENTING:** Kalau muncul Not Found, tambahin sendiri '/' di ujung URL browser lu.")
34
-
35
- inp = gr.Textbox(label="Data Input")
36
- out = gr.Textbox(label="Result")
37
- btn = gr.Button("Analyze")
38
- btn.click(fake_ai, inp, out)
39
-
40
- demo.launch(server_name="0.0.0.0", server_port=7860)
41
-
42
- if __name__ == "__main__":
43
- start_all()
44
-