Skip to content

Commit

Permalink
ADDAPI可作为PROXYIP使用
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu committed Oct 2, 2024
1 parent 2201376 commit ad562ab
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,27 @@ Telegram交流群:[@CMLiussss](https://t.me/CMLiussss),**感谢[Alice Networ
/socks5://user:[email protected]: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)、<a href="https://url.cmliussss.com/alice"><img src="https://alicenetworks.net/templates/lagom2/assets/img/logo/logo_big.194980063.png" width="150" height="75" alt="Alice Networks LTD"/></a>、
30 changes: 24 additions & 6 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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 = "";

Expand All @@ -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';
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'))) {
最终路径 = `/${伪装域名}${最终路径}`;
Expand Down

0 comments on commit ad562ab

Please sign in to comment.