Hosdroid commited on
Commit
c8b8ab9
·
verified ·
1 Parent(s): 25e8275

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -43
app.py CHANGED
@@ -1,47 +1,50 @@
1
  import gradio as gr
2
  import httpx
3
- import asyncio
4
  import uuid
 
5
 
6
- # لیست IPهای Cloudflare
7
- IPS = ['104.16.0.1', '104.16.1.1', '104.17.0.1', '104.17.1.1',
8
- '104.18.0.1', '104.18.1.1', '104.19.0.1', '104.19.1.1',
9
- '104.20.0.1', '104.20.1.1', '172.64.0.1', '172.64.1.1',
10
- '172.65.0.1', '172.65.1.1', '172.66.0.1', '172.66.1.1']
11
-
12
- best_ip = None
13
- best_ping = 9999
14
-
15
- async def scan_ip(ip):
16
- try:
17
- start = asyncio.get_event_loop().time()
18
- async with httpx.AsyncClient(timeout=3) as client:
19
- await client.get(f'https://{ip}')
20
- ping = int((asyncio.get_event_loop().time() - start) * 1000)
21
- return {'ip': ip, 'ping': ping}
22
- except:
23
- return {'ip': ip, 'ping': 9999}
24
-
25
- def scan_all():
26
- global best_ip, best_ping
27
- loop = asyncio.new_event_loop()
28
- results = loop.run_until_complete(asyncio.gather(*[scan_ip(ip) for ip in IPS]))
29
- loop.close()
30
 
31
- results = sorted([r for r in results if r['ping'] < 9999], key=lambda x: x['ping'])
 
 
 
 
 
 
 
 
 
32
 
33
- if results:
34
- best_ip = results[0]['ip']
35
- best_ping = results[0]['ping']
36
 
37
  text = "🎯 IPهای سریع:\n\n"
38
- for i, r in enumerate(results[:5], 1):
39
- text += f"{i}. {r['ip']} - {r['ping']}ms\n"
 
 
 
 
40
  return text
41
 
42
- def make_config():
 
 
 
 
 
 
 
 
 
43
  if not best_ip:
44
- return "❌ اول اسکن کن!"
45
 
46
  my_uuid = str(uuid.uuid4())
47
  config = f"vless://{my_uuid}@{best_ip}:443?encryption=none&security=tls&sni=www.speedtest.net&type=ws&path=/?ed=2048#Meta-Protocol"
@@ -49,25 +52,23 @@ def make_config():
49
  return f"""✅ کانفیگ آماده:
50
 
51
  **IP:** {best_ip}
52
- **پینگ:** {best_ping}ms
53
  {config}
54
  **روش استفاده:**
55
  1. لینک بالا رو کپی کن
56
  2. برو تو Npv Tunnel
57
- 3. More → Import from Clipboard
58
  4. وصل شو!"""
59
 
60
- with gr.Blocks(title="Meta Protocol ") as demo:
61
  gr.Markdown("# 🚀 Meta Protocol\n**اسکن IP و ساخت کانفیگ برای گیم**")
62
 
63
- btn1 = gr.Button("🔍 اسکن IPها", variant="primary")
64
- out1 = gr.Textbox(label="نتایج", lines=8)
65
 
66
- btn2 = gr.Button("⚡ ساخت کانفیگ", variant="secondary")
67
  out2 = gr.Markdown()
68
 
69
- btn1.click(scan_all, outputs=out1)
70
- btn2.click(make_config, outputs=out2)
71
 
72
- demo.launch()
73
-
 
1
  import gradio as gr
2
  import httpx
 
3
  import uuid
4
+ import spaces
5
 
6
+ @spaces.GPU
7
+ def scan_ips():
8
+ """اسکن IPهای Cloudflare"""
9
+ ips = ['104.16.0.1', '104.16.1.1', '104.17.0.1', '104.17.1.1',
10
+ '104.18.0.1', '104.18.1.1', '104.19.0.1', '104.19.1.1',
11
+ '104.20.0.1', '104.20.1.1', '172.64.0.1', '172.64.1.1',
12
+ '172.65.0.1', '172.65.1.1', '172.66.0.1', '172.66.1.1']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ results = []
15
+ for ip in ips:
16
+ try:
17
+ import time
18
+ start = time.time()
19
+ r = httpx.get(f'https://{ip}', timeout=3, verify=False)
20
+ ping = int((time.time() - start) * 1000)
21
+ results.append((ip, ping))
22
+ except:
23
+ pass
24
 
25
+ results.sort(key=lambda x: x[1])
 
 
26
 
27
  text = "🎯 IPهای سریع:\n\n"
28
+ for i, (ip, ping) in enumerate(results[:5], 1):
29
+ text += f"{i}. {ip} - {ping}ms\n"
30
+
31
+ if results:
32
+ text += f"\n✅ بهترین IP: {results[0][0]} ({results[0][1]}ms)"
33
+
34
  return text
35
 
36
+ def make_config(ip_text):
37
+ """ساخت کانفیگ VLESS"""
38
+ lines = ip_text.split('\n')
39
+ best_ip = None
40
+
41
+ for line in lines:
42
+ if '✅ بهترین IP:' in line:
43
+ best_ip = line.split(':')[1].split('(')[0].strip()
44
+ break
45
+
46
  if not best_ip:
47
+ return "❌ اول IPها رو اسکن کن!"
48
 
49
  my_uuid = str(uuid.uuid4())
50
  config = f"vless://{my_uuid}@{best_ip}:443?encryption=none&security=tls&sni=www.speedtest.net&type=ws&path=/?ed=2048#Meta-Protocol"
 
52
  return f"""✅ کانفیگ آماده:
53
 
54
  **IP:** {best_ip}
 
55
  {config}
56
  **روش استفاده:**
57
  1. لینک بالا رو کپی کن
58
  2. برو تو Npv Tunnel
59
+ 3. Subs → From URL → لینک رو پیست کن
60
  4. وصل شو!"""
61
 
62
+ with gr.Blocks(title="Meta Protocol 🚀") as demo:
63
  gr.Markdown("# 🚀 Meta Protocol\n**اسکن IP و ساخت کانفیگ برای گیم**")
64
 
65
+ btn1 = gr.Button("🔍 اسکن IPها", variant="primary", size="lg")
66
+ out1 = gr.Textbox(label="نتایج اسکن", lines=10)
67
 
68
+ btn2 = gr.Button("⚡ ساخت کانفیگ", variant="secondary", size="lg")
69
  out2 = gr.Markdown()
70
 
71
+ btn1.click(scan_ips, outputs=out1)
72
+ btn2.click(make_config, inputs=out1, outputs=out2)
73
 
74
+ demo.launch()