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 ad562ab commit 7c9ab87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,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
21 changes: 15 additions & 6 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ let ChatID ='';
let proxyhosts = [];//本地代理域名池
let proxyhostsURL = 'https://raw.githubusercontent.com/cmliu/CFcdnVmess2sub/main/proxyhosts';//在线代理域名池URL
let RproxyIP = 'false';
let httpsPorts = ["2053","2083","2087","2096","8443"];
export default {
/**
* @param {import("@cloudflare/workers-types").Request} request
Expand Down Expand Up @@ -105,7 +106,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 @@ -1652,8 +1653,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 @@ -1721,7 +1730,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 Expand Up @@ -1835,7 +1844,6 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
addressid = match[3] || address;
}

const httpsPorts = ["2053","2083","2087","2096","8443"];
if (!isValidIPv4(address) && port == "-1") {
for (let httpsPort of httpsPorts) {
if (address.includes(httpsPort)) {
Expand All @@ -1849,7 +1857,8 @@ 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}`;
const matchingProxyIP = proxyIPPool.find(proxyIP => proxyIP.includes(address));
if (matchingProxyIP) 最终路径 += `&proxyip=${matchingProxyIP}`;

if(proxyhosts.length > 0 && (伪装域名.includes('.workers.dev') || 伪装域名.includes('pages.dev'))) {
最终路径 = `/${伪装域名}${最终路径}`;
Expand Down

0 comments on commit 7c9ab87

Please sign in to comment.