Skip to content

Commit

Permalink
修复ADD*变量生成的clash、singbox订阅异常bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu committed Sep 11, 2024
1 parent 5643e80 commit 73714ba
Showing 1 changed file with 39 additions and 31 deletions.
70 changes: 39 additions & 31 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,33 +160,6 @@ export default {
return new Response(`${fakeConfig}`, { status: 200 });
case `/${userID}`: {
await sendMessage(`#获取订阅 ${FileName}`, request.headers.get('CF-Connecting-IP'), `UA: ${UA}</tg-spoiler>\n域名: ${url.hostname}\n<tg-spoiler>入口: ${url.pathname + url.search}</tg-spoiler>`);
if ((!sub || sub == '') && (addresses.length + addressesapi.length + addressesnotls.length + addressesnotlsapi.length + addressescsv.length) == 0){
addresses = [
'Join.my.Telegram.channel.CMLiussss.to.unlock.more.premium.nodes.cf.090227.xyz#加入我的频道t.me/CMLiussss解锁更多优选节点',
'visa.cn:443',
'www.visa.com:8443',
'cis.visa.com:2053',
'africa.visa.com:2083',
'www.visa.com.sg:2087',
'www.visaeurope.at:2096',
'www.visa.com.mt:8443',
'qa.visamiddleeast.com',
'time.is',
'www.wto.org:8443',
'chatgpt.com:2087',
'icook.hk',
//'104.17.0.0#IPv4',
'[2606:4700::]#IPv6'
];
if (request.headers.get('Host').includes(".workers.dev")) addressesnotls = [
'usa.visa.com:2095',
'myanmar.visa.com:8080',
'www.visa.com.tw:8880',
'www.visaeurope.ch:2052',
'www.visa.com.br:2082',
'www.visasoutheasteurope.com:2086'
];
}
const vlessConfig = await getVLESSConfig(userID, request.headers.get('Host'), sub, UA, RproxyIP, url);
const now = Date.now();
//const timestamp = Math.floor(now / 1000);
Expand Down Expand Up @@ -1222,6 +1195,36 @@ async function ADD(envadd) {
return add;
}

function checkSUB(host) {
if ((!sub || sub == '') && (addresses.length + addressesapi.length + addressesnotls.length + addressesnotlsapi.length + addressescsv.length) == 0){
addresses = [
'Join.my.Telegram.channel.CMLiussss.to.unlock.more.premium.nodes.cf.090227.xyz#加入我的频道t.me/CMLiussss解锁更多优选节点',
'visa.cn:443',
'www.visa.com:8443',
'cis.visa.com:2053',
'africa.visa.com:2083',
'www.visa.com.sg:2087',
'www.visaeurope.at:2096',
'www.visa.com.mt:8443',
'qa.visamiddleeast.com',
'time.is',
'www.wto.org:8443',
'chatgpt.com:2087',
'icook.hk',
//'104.17.0.0#IPv4',
'[2606:4700::]#IPv6'
];
if (host.includes(".workers.dev")) addressesnotls = [
'usa.visa.com:2095',
'myanmar.visa.com:8080',
'www.visa.com.tw:8880',
'www.visaeurope.ch:2052',
'www.visa.com.br:2082',
'www.visasoutheasteurope.com:2086'
];
}
}

const 啥啥啥_写的这是啥啊 = 'dmxlc3M=';
function 配置信息(UUID, 域名地址) {
const 协议类型 = atob(啥啥啥_写的这是啥啊);
Expand Down Expand Up @@ -1275,6 +1278,7 @@ let subParams = ['sub','base64','b64','clash','singbox','sb'];
* @returns {Promise<string>}
*/
async function getVLESSConfig(userID, hostName, sub, UA, RproxyIP, _url) {
checkSUB(hostName);
const userAgent = UA.toLowerCase();
const Config = 配置信息(userID , hostName);
const v2ray = Config[0];
Expand Down Expand Up @@ -1680,7 +1684,7 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
const uniqueAddressesnotls = [...new Set(addressesnotls)];

notlsresponseBody = uniqueAddressesnotls.map(address => {
let port = "80";
let port = "-1";
let addressid = address;

const match = addressid.match(regex);
Expand Down Expand Up @@ -1711,13 +1715,15 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
}

const httpPorts = ["8080","8880","2052","2082","2086","2095"];
if (!isValidIPv4(address) && port == "80") {
if (!isValidIPv4(address) && port == "-1") {
for (let httpPort of httpPorts) {
if (address.includes(httpPort)) {
port = httpPort;
break;
}
}
} else if (port == "-1") {
port = "80";
}

let 伪装域名 = host ;
Expand All @@ -1737,7 +1743,7 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
const uniqueAddresses = [...new Set(addresses)];

const responseBody = uniqueAddresses.map(address => {
let port = "443";
let port = "-1";
let addressid = address;

const match = addressid.match(regex);
Expand Down Expand Up @@ -1768,13 +1774,15 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
}

const httpsPorts = ["2053","2083","2087","2096","8443"];
if (!isValidIPv4(address) && port == "443") {
if (!isValidIPv4(address) && port == "-1") {
for (let httpsPort of httpsPorts) {
if (address.includes(httpsPort)) {
port = httpsPort;
break;
}
}
} else if (port == "-1") {
port = "443";
}

let 伪装域名 = host ;
Expand Down

0 comments on commit 73714ba

Please sign in to comment.