Update app.py
Browse files
app.py
CHANGED
|
@@ -29,13 +29,38 @@ def install_tools():
|
|
| 29 |
os.chmod(WGCF_BIN, 0o755)
|
| 30 |
|
| 31 |
def start_warp():
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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",
|