├── README.md ├── requirements.txt └── warp-2.2.1.py /README.md: -------------------------------------------------------------------------------- 1 | # WARP-PLUS-FIX 2 | warp plus script | 在原ALIILAPRO大佬的基础上, 加入了超时和速度检测 3 | 4 | ## 联动 5 | [WARP-PLUS-HKG](https://github.com/Windla/WARP-PLUS-HKG) | 将Cloudflare WARP的主机托管中心锁定为HKG(香港), 以换取低延时warp+(随缘) 6 | 7 | ## 0.注意 8 | > 请认真查看py文件内的设置说明! 9 | 10 | 孩子啥也不会, 瞎写的 11 | 12 | 坚持能用就行原则 你说得对 13 | 14 | 15 | ## 1.下载 16 | [Clone](https://github.com/Windla/WARP-PLUS-FIX/archive/refs/heads/main.zip) 17 | 18 | ## 2.安装 19 | 20 | ``` 21 | pip install -r requirements.txt 22 | ``` 23 | or 24 | ``` 25 | pip install requests 26 | ``` 27 | 28 | ## 3.使用 29 | 30 | 运行 `warp-*.*.*.py` 31 | 32 | ## Star! 33 | 34 | [![Stargazers over time](https://starchart.cc/Windla/WARP-PLUS-FIX.svg)](https://starchart.cc/Windla/WARP-PLUS-FIX) 35 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | -------------------------------------------------------------------------------- /warp-2.2.1.py: -------------------------------------------------------------------------------- 1 | # coding = uft-8 2 | import json 3 | import datetime 4 | import random 5 | import string 6 | import time 7 | import os 8 | import sys 9 | 10 | import requests 11 | 12 | 13 | # ID [偏好设置-常规-设备ID] 14 | referrer = "" 15 | 16 | # 是否在Actions中运行 | 0:否(不间断运行) 1:是(运行6h自动停止) 17 | actions = 0 18 | 19 | # 快速启动 0:否 1:是 | 开启后刚开始速度会不准 20 | fast_start = 1 21 | 22 | # 超时时间设定 23 | timeout = 10 24 | 25 | 26 | # Author: ALIILAPRO 27 | def gen_string(string_length): 28 | try: 29 | letters = string.ascii_letters + string.digits 30 | return ''.join(random.choice(letters) for _ in range(string_length)) 31 | except Exception as error: 32 | print(error) 33 | 34 | 35 | # Author: ALIILAPRO 36 | def digit_string(string_length): 37 | try: 38 | digit = string.digits 39 | return ''.join((random.choice(digit) for _ in range(string_length))) 40 | except Exception as error: 41 | print(error) 42 | 43 | 44 | # Author: ALIILAPRO 45 | def run_requests(): 46 | try: 47 | url = f'https://api.cloudflareclient.com/v0a{digit_string(3)}/reg' 48 | install_id = gen_string(22) 49 | body = {"key": "{}=".format(gen_string(43)), 50 | "install_id": install_id, 51 | "fcm_token": "{}=".format(gen_string(134)), 52 | "referrer": referrer, 53 | "warp_enabled": False, 54 | "tos": datetime.datetime.now().isoformat()[:-3] + "+02:00", 55 | "type": "Android", 56 | "locale": "es_ES"} 57 | data = json.dumps(body).encode('utf8') 58 | headers = {'Content-Type': 'application/json; charset=UTF-8', 59 | 'Host': 'api.cloudflareclient.com', 60 | 'Connection': 'Keep-Alive', 61 | 'Accept-Encoding': 'gzip', 62 | 'User-Agent': 'okhttp/3.12.1'} 63 | response = requests.post(url=url, headers=headers, data=data, timeout=timeout) 64 | status_code = response.status_code 65 | return status_code 66 | except requests.exceptions.RequestException: 67 | print("[warn]连接超时") 68 | 69 | except Exception as error: 70 | print(error) 71 | 72 | 73 | def main(): 74 | t0 = time.time() # 入点 75 | g = 0 # 成功 76 | b = 0 # 失败 77 | t1 = 0 # 计时 78 | 79 | os.system("title WARP-PLUS-FIX By ALIILAPRO + Windla(fix)") 80 | print("WARP-PLUS-FIX By ALIILAPRO + Windla(fix)") 81 | if referrer == "": 82 | print("你还未设置你的设备ID!\n请检查你的py文件内设置\n将在20s后自动退出!") 83 | time.sleep(20) 84 | exit() 85 | elif actions == 0 and fast_start == 0: 86 | print("将在20s后继续运行") 87 | time.sleep(20) 88 | 89 | while True: 90 | # 针对Workflows 6h的限制 保留100s冗余 91 | if actions == 1 and t1 >= 21500: 92 | sys.exit() 93 | 94 | result = run_requests() 95 | 96 | if result == 200: 97 | g = g + 1 98 | os.system('cls' if os.name == 'nt' else 'clear') 99 | 100 | t = time.time() - t0 # 已用时间 101 | t2 = t - t1 # 距离上一次触发的时间 102 | t1 = t # 更新已用时间 103 | print("--------------------------------------------------------") 104 | print(f"[info]已用时间: {int(t1)} s") 105 | print(f"[info]当前速度: {int(t2)} s/GB") 106 | print(f"[info]平均速度: {int(g / t1 * 21600)} GB/6h") 107 | print(f"[info]运行结果: {g} Good {b} Bad") 108 | print("--------------------------------------------------------") 109 | time.sleep(10) 110 | print("[info]Ready") 111 | time.sleep(10) 112 | print("[info]Running") 113 | else: 114 | b = b + 1 115 | os.system('cls' if os.name == 'nt' else 'clear') 116 | 117 | t = time.time() - t0 # 已用时间 118 | t1 = t # 更新已用时间 119 | print("--------------------------------------------------------") 120 | print(f"[info]已用时间: {int(t1)} s") 121 | print(f"[info]当前速度: 0 s/GB") 122 | print(f"[info]平均速度: {int(g / t1 * 21600)} GB/6h") 123 | print(f"[info]运行结果: {g} Good {b} Bad") 124 | print("--------------------------------------------------------") 125 | print("[info]Ready") 126 | time.sleep(1) 127 | print("[info]Running") 128 | 129 | 130 | if __name__ == "__main__": 131 | main() 132 | --------------------------------------------------------------------------------