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 23daa0e commit fb9553c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,19 @@ 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/epeius.svg?variant=adaptive)](https://starchart.cc/cmliu/epeius)

## 已适配客户端
### Windows
- [v2rayN](https://github.com/2dust/v2rayN)
- 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))
- 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/))
Expand Down
4 changes: 2 additions & 2 deletions _worker.js

Large diffs are not rendered by default.

31 changes: 24 additions & 7 deletions _worker.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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 getTrojanConfig(password, request.headers.get('Host'), sub, 'CF-Workers-SUB', RproxyIP, url);
return new Response(`${fakeConfig}`, { status: 200 });
Expand Down Expand Up @@ -885,7 +890,7 @@ async function sendMessage(type, ip, add_data = "") {
});
}
}

let proxyIPPool = [];
function subAddresses(host,pw,userAgent,newAddressesapi,newAddressescsv) {
addresses = addresses.concat(newAddressesapi);
addresses = addresses.concat(newAddressescsv);
Expand Down Expand Up @@ -943,7 +948,7 @@ function subAddresses(host,pw,userAgent,newAddressesapi,newAddressescsv) {
伪装域名 = proxyhosts[Math.floor(Math.random() * proxyhosts.length)];
节点备注 = ` 已启用临时域名中转服务,请尽快绑定自定义域!`;
}

if (proxyIPPool.includes(`${address}:${port}`) && !httpsPorts.includes(port)) 最终路径 += `&proxyip=${address}:${port}`;
let 密码 = pw;
if (!userAgent.includes('subconverter')) 密码 = encodeURIComponent(pw);

Expand All @@ -960,9 +965,7 @@ function subAddresses(host,pw,userAgent,newAddressesapi,newAddressescsv) {
}

async function getAddressesapi(api) {
if (!api || api.length === 0) {
return [];
}
if (!api || api.length === 0) return [];

let newapi = "";

Expand All @@ -986,11 +989,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 @@ -1056,6 +1069,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

0 comments on commit fb9553c

Please sign in to comment.