Skip to content

Commit

Permalink
更改添加proxyIPPool的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu committed Oct 6, 2024
1 parent fb9553c commit 2294d0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Telegram交流群:[@CMLiussss](https://t.me/CMLiussss),**感谢[Alice Networ
| URL | `https://blog.cmliussss.com` | 主页反代伪装(支持多url, url之间使用`,``换行`作间隔, 乱设容易触发反诈) |
| CFEMAIL | `[email protected]` | CF账户邮箱(与`CFKEY`都填上后, 订阅信息将显示请求使用量, 小白别用) |
| CFKEY | `c6a944b5c956b6c18c2352880952bced8b85e` | CF账户Global API Key(与`CFEMAIL`都填上后, 订阅信息将显示请求使用量, 小白别用) |
| CFPORTS | `2053`,`2096`,`8443` | CF账户标准端口列表 |

**注意: 填入`SOCKS5`后将不再启用`PROXYIP`!请二选一使用!!!**

Expand Down
4 changes: 2 additions & 2 deletions _worker.js

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions _worker.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (!isValidSHA224(sha224Password)) {

let parsedSocks5Address = {};
let enableSocks = false;

let httpsPorts = ["2053","2083","2087","2096","8443"];
export default {
async fetch(request, env, ctx) {
try {
Expand All @@ -88,7 +88,7 @@ export default {
socks5s = await ADD(socks5Address);
socks5Address = socks5s[Math.floor(Math.random() * socks5s.length)];
socks5Address = socks5Address.split('//')[1] || socks5Address;

if (env.CFPORTS) httpsPorts = await ADD(env.CFPORTS);
sub = env.SUB || sub;
subconverter = env.SUBAPI || subconverter;
if( subconverter.includes("http://") ){
Expand Down Expand Up @@ -948,7 +948,8 @@ 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}`;
const matchingProxyIP = proxyIPPool.find(proxyIP => proxyIP.includes(address));
if (matchingProxyIP) 最终路径 += `&proxyip=${matchingProxyIP}`;
let 密码 = pw;
if (!userAgent.includes('subconverter')) 密码 = encodeURIComponent(pw);

Expand Down Expand Up @@ -1000,8 +1001,16 @@ async function getAddressesapi(api) {
// 如果URL带有'proxyip=true',则将内容添加到proxyIPPool
proxyIPPool = proxyIPPool.concat((await ADD(content)).map(item => {
const baseItem = item.split('#')[0] || item;
return baseItem.includes(':') ? baseItem : `${baseItem}:443`;
}));
if (baseItem.includes(':')) {
const port = baseItem.split(':')[1];
if (!httpsPorts.includes(port)) {
return baseItem;
}
} else {
return `${baseItem}:443`;
}
return null; // 不符合条件时返回 null
}).filter(Boolean)); // 过滤掉 null 值
}
// 将内容添加到newapi中
newapi += content + '\n';
Expand Down Expand Up @@ -1069,7 +1078,7 @@ async function getAddressescsv(tls) {

const formattedAddress = `${ipAddress}:${port}#${dataCenter}`;
newAddressescsv.push(formattedAddress);
if (csvUrl.includes('proxyip=true') && columns[tlsIndex].toUpperCase() == 'true') {
if (csvUrl.includes('proxyip=true') && columns[tlsIndex].toUpperCase() == 'true' && !httpsPorts.includes(port)) {
// 如果URL带有'proxyip=true',则将内容添加到proxyIPPool
proxyIPPool.push(`${ipAddress}:${port}`);
}
Expand Down

0 comments on commit 2294d0f

Please sign in to comment.