From ad562ab9c8fe1fd51e379067cd7b9351073972a1 Mon Sep 17 00:00:00 2001 From: cmliu Date: Thu, 3 Oct 2024 03:36:13 +0800 Subject: [PATCH] =?UTF-8?q?ADDAPI=E5=8F=AF=E4=BD=9C=E4=B8=BAPROXYIP?= =?UTF-8?q?=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 22 ++++++++++++++++------ _worker.js | 30 ++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 31334cd..d25b160 100644 --- a/README.md +++ b/README.md @@ -191,17 +191,27 @@ Telegram交流群:[@CMLiussss](https://t.me/CMLiussss),**感谢[Alice Networ /socks5://user:password@127.0.0.1:1080 ``` +**当你的`ADDAPI`可作为`PROXYIP`时,可在`ADDAPI`变量末位添加`?proxyip=true`,即可在生成节点时使用优选IP自身作为`PROXYIP`** +- 指定 `ADDAPI` 作为 `PROXYIP` 案例 + ```url + https://raw.githubusercontent.com/cmliu/WorkerVless2sub/main/addressesapi.txt?proxyip=true + ``` ## Star 星星走起 [![Stargazers over time](https://starchart.cc/cmliu/edgetunnel.svg?variant=adaptive)](https://starchart.cc/cmliu/edgetunnel) -## 已适配自适应订阅内容 +## 已适配客户端 +### Windows - [v2rayN](https://github.com/2dust/v2rayN) - - clash.meta([clash-verge-rev -](https://github.com/clash-verge-rev/clash-verge-rev),[Clash Nyanpasu](https://github.com/keiko233/clash-nyanpasu),~[clash-verge](https://github.com/zzzgydi/clash-verge/tree/main)~,ClashX Meta) - - sing-box(SFI) - - + - clash.meta([FlClash](https://github.com/chen08209/FlClash),[clash-verge-rev](https://github.com/clash-verge-rev/clash-verge-rev),[Clash Nyanpasu](https://github.com/keiko233/clash-nyanpasu)) +### IOS + - Surge,小火箭 + - sing-box([SFI](https://sing-box.sagernet.org/zh/clients/apple/)) +### 安卓 + - clash.meta([ClashMetaForAndroid](https://github.com/MetaCubeX/ClashMetaForAndroid),[FlClash](https://github.com/chen08209/FlClash)) + - sing-box([SFA](https://github.com/SagerNet/sing-box)) +### MacOS + - clash.meta([FlClash](https://github.com/chen08209/FlClash)) # 感谢 [zizifn](https://github.com/zizifn/edgetunnel)、[3Kmfi6HP](https://github.com/3Kmfi6HP/EDtunnel)、[Stanley-baby](https://github.com/Stanley-baby)、[ACL4SSR](https://github.com/ACL4SSR/ACL4SSR/tree/master/Clash/config)、[SHIJS1999](https://github.com/SHIJS1999/cloudflare-worker-vless-ip)、Alice Networks LTD、 diff --git a/_worker.js b/_worker.js index 2e6f45c..c3215b4 100644 --- a/_worker.js +++ b/_worker.js @@ -150,7 +150,12 @@ export default { case '/': if (env.URL302) return Response.redirect(env.URL302, 302); else if (env.URL) return await proxyURL(env.URL, url); - else return new Response(JSON.stringify(request.cf, null, 4), { status: 200 }); + else return new Response(JSON.stringify(request.cf, null, 4), { + status: 200, + headers: { + 'content-type': 'application/json', + }, + }); case `/${fakeUserID}`: const fakeConfig = await getVLESSConfig(userID, request.headers.get('Host'), sub, 'CF-Workers-SUB', RproxyIP, url); return new Response(`${fakeConfig}`, { status: 200 }); @@ -1610,11 +1615,9 @@ async function getSum(accountId, accountIndex, email, key, startDate, endDate) { return [ 0,0 ]; } } - +let proxyIPPool = []; async function getAddressesapi(api) { - if (!api || api.length === 0) { - return []; - } + if (!api || api.length === 0) return []; let newapi = ""; @@ -1638,11 +1641,21 @@ async function getAddressesapi(api) { }).then(response => response.ok ? response.text() : Promise.reject()))); // 遍历所有响应 - for (const response of responses) { + for (const [index, response] of responses.entries()) { // 检查响应状态是否为'fulfilled',即请求成功完成 if (response.status === 'fulfilled') { // 获取响应的内容 const content = await response.value; + + // 验证当前apiUrl是否带有'proxyip=true' + if (api[index].includes('proxyip=true')) { + // 如果URL带有'proxyip=true',则将内容添加到proxyIPPool + proxyIPPool = proxyIPPool.concat((await ADD(content)).map(item => { + const baseItem = item.split('#')[0] || item; + return baseItem.includes(':') ? baseItem : `${baseItem}:443`; + })); + } + // 将内容添加到newapi中 newapi += content + '\n'; } } @@ -1708,6 +1721,10 @@ async function getAddressescsv(tls) { const formattedAddress = `${ipAddress}:${port}#${dataCenter}`; newAddressescsv.push(formattedAddress); + if (csvUrl.includes('proxyip=true') && columns[tlsIndex].toUpperCase() == 'true') { + // 如果URL带有'proxyip=true',则将内容添加到proxyIPPool + proxyIPPool.push(`${ipAddress}:${port}`); + } } } } catch (error) { @@ -1832,6 +1849,7 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress let 伪装域名 = host ; let 最终路径 = '/?ed=2560' ; let 节点备注 = ''; + if (proxyIPPool.includes(`${address}:${port}`) && !httpsPorts.includes(port)) 最终路径 += `&proxyip=${address}:${port}`; if(proxyhosts.length > 0 && (伪装域名.includes('.workers.dev') || 伪装域名.includes('pages.dev'))) { 最终路径 = `/${伪装域名}${最终路径}`;