dodd869 commited on
Commit
cd367bc
·
verified ·
1 Parent(s): 5d28cee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -5
app.py CHANGED
@@ -29,13 +29,38 @@ def install_tools():
29
  os.chmod(WGCF_BIN, 0o755)
30
 
31
  def start_warp():
32
- install_tools()
33
- if not WARP_CONF.exists():
34
- subprocess.run([WGCF_BIN, "register", "--accept-tos"], cwd=TMP, check=True)
35
- subprocess.run([WGCF_BIN, "generate"], cwd=TMP, check=True)
36
- subprocess.run(["wg-quick", "up", str(WG_CONF)], check=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  time.sleep(3)
38
 
 
39
  def ytdlp_fast(url, out):
40
  subprocess.run([
41
  "yt-dlp", "-f", "bestaudio/best", "--extract-audio",
 
29
  os.chmod(WGCF_BIN, 0o755)
30
 
31
  def start_warp():
32
+ import urllib.request, gzip, shutil, socket, socks
33
+
34
+ wgcf = TMP / "wgcf"
35
+ if not wgcf.exists():
36
+ url = "https://github.com/ViRb3/wgcf/releases/download/v2.2.29/wgcf_2.2.29_linux_amd64"
37
+ urllib.request.urlretrieve(url, wgcf)
38
+ os.chmod(wgcf, 0o755)
39
+
40
+ toml = TMP / "wgcf-account.toml"
41
+ if not toml.exists():
42
+ subprocess.run([wgcf, "register", "--accept-tos"], cwd=TMP, check=True)
43
+ subprocess.run([wgcf, "generate"], cwd=TMP, check=True)
44
+
45
+ # download userspace wireguard-go
46
+ wggo = TMP / "wireguard-go"
47
+ if not wggo.exists():
48
+ gz = TMP / "wggo.gz"
49
+ urllib.request.urlretrieve(
50
+ "https://github.com/WireGuard/wireguard-go/releases/download/v0.0.20230223/wireguard-go_0.0.20230223_linux_amd64.gz", gz
51
+ )
52
+ with gzip.open(gz, "rb") as f_in:
53
+ with open(wggo, "wb") as f_out:
54
+ shutil.copyfileobj(f_in, f_out)
55
+ os.chmod(wggo, 0o755)
56
+ gz.unlink(missing_ok=True)
57
+
58
+ # jalankan userspace WireGuard (tanpa root, tanpa wg-quick)
59
+ conf = TMP / "wgcf-profile.conf"
60
+ subprocess.Popen([wggo, "-f", str(conf)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
61
  time.sleep(3)
62
 
63
+
64
  def ytdlp_fast(url, out):
65
  subprocess.run([
66
  "yt-dlp", "-f", "bestaudio/best", "--extract-audio",