cloudflare
-------- 更新#1 --------
添加重试, 默认请求失败后重试5次
包含nodejs版和python版, python版需要额外安装requests库
代码虽然丑, 但好像可以运行, 还有标题格式是抄来的......(手动划掉)
运行前:
运行后:
以下贴出nodejs版的代码, python版自行在Github拿
把自己的aff填在referrer,循环次数默认十次(10G流量), 建议不要设置的太暴力
不确定会不会翻车, 因为提交的FCM TOKEN是随机生成的字符串, 并不符合Firebase的格式, 可以尝试备份一下原来的数据重新注册个号跑代码
aff id获取方式:
点击软件右上角菜单 => 拉到下面点 "More settings" => 点"Diagnostics" => 在"CLIENT CONFIGURATION"栏中的ID就是
感谢#12楼 @zdszf
Chome: 打开控制台, 切换到Network, 访问你自己的aff链接, 查看回复头的跳转地址, 你的aff id就在地址里
node cloudflare-warp-plus-aff.js |
- // Fake register for referrer to get warp plus bandwidth
- const referrer = "AFF ID复制到这里";
- const timesToLoop = 10; // 循环次数
- const retryTimes = 5; // 重试次数
- const https = require("https");
- const zlib = require("zlib");
- async function init() {
- for (let i = 0; i < timesToLoop; i++) {
- if (await run()) {
- console.log(i + 1, "OK");
- } else {
- console.log(i + 1, "Error");
- for (let r = 0; r < retryTimes; r++) {
- if (await run()) {
- console.log(i + 1, "Retry #" + (r + 1), "OK");
- break;
- } else {
- console.log(i + 1, "Retry #" + (r + 1), "Error");
- if (r === retryTimes - 1) {
- return;
- }
- }
- }
- }
- }
- }
- async function run() {
- return new Promise(resolve => {
- const install_id = genString(11);
- const postData = JSON.stringify({
- key: `${genString(43)}=`,
- install_id: install_id,
- fcm_token: `${install_id}:APA91b${genString(134)}`,
- referrer: referrer,
- warp_enabled: false,
- tos: new Date().toISOString().replace("Z", "+07:00"),
- type: "Android",
- locale: "zh_CN"
- });
- const options = {
- hostname: "api.cloudflareclient.com",
- port: 443,
- path: "/v0a745/reg",
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Host: "api.cloudflareclient.com",
- Connection: "Keep-Alive",
- "Accept-Encoding": "gzip",
- "User-Agent": "okhttp/3.12.1",
- "Content-Length": postData.length
- }
- };
- const req = https.request(options, res => {
- const gzip = zlib.createGunzip();
- // const buffer = [];
- res.pipe(gzip);
- gzip
- .on("data", function(data) {
- // buffer.push(data.toString());
- })
- .on("end", function() {
- // console.dir(JSON.parse(buffer.join("")));
- resolve(true);
- })
- .on("error", function(e) {
- // console.error(e);
- resolve(false);
- });
- });
- req.on("error", error => {
- // console.error(error);
- resolve(false);
- });
- req.write(postData);
- req.end();
- });
- }
- function genString(length) {
- // https://gist.github.com/6174/6062387#gistcomment-2651745
- return [...Array(length)]
- .map(i => (~~(Math.random() * 36)).toString(36))
- .join("");
- }
- init();
|