mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
Update _worker.js
修复无法生成本地noTLS节点的错误; 添加对未开启https的订阅转换后端的支持。
This commit is contained in:
21
_worker.js
21
_worker.js
@@ -11,7 +11,7 @@ let proxyIP = '';// 小白勿动,该地址并不影响你的网速,这是给
|
||||
let sub = '';// 留空则使用内置订阅
|
||||
let subconverter = 'subapi-loadbalancing.pages.dev';// clash订阅转换后端,目前使用CM的订阅转换功能。自带虚假uuid和host订阅。
|
||||
let subconfig = "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini"; //订阅配置文件
|
||||
|
||||
let subProtocol = 'https';
|
||||
// The user name and password do not contain special characters
|
||||
// Setting the address will ignore proxyIP
|
||||
// Example: user:pass@host:port or host:port
|
||||
@@ -70,6 +70,12 @@ export default {
|
||||
socks5Address = env.SOCKS5 || socks5Address;
|
||||
sub = env.SUB || sub;
|
||||
subconverter = env.SUBAPI || subconverter;
|
||||
if( subconverter.includes("http://") ){
|
||||
subconverter = subconverter.split("//")[1];
|
||||
subProtocol = 'http';
|
||||
} else {
|
||||
subconverter = subconverter.split("//")[1] || subconverter;
|
||||
}
|
||||
subconfig = env.SUBCONFIG || subconfig;
|
||||
if (socks5Address) {
|
||||
try {
|
||||
@@ -1339,10 +1345,10 @@ https://github.com/cmliu/edgetunnel
|
||||
|
||||
if (!userAgent.includes(('CF-Workers-SUB').toLowerCase())){
|
||||
if ((userAgent.includes('clash') && !userAgent.includes('nekobox')) || ( _url.searchParams.has('clash') && !userAgent.includes('subconverter'))) {
|
||||
url = `https://${subconverter}/sub?target=clash&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||
url = `${subProtocol}://${subconverter}/sub?target=clash&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||
isBase64 = false;
|
||||
} else if (userAgent.includes('sing-box') || userAgent.includes('singbox') || (( _url.searchParams.has('singbox') || _url.searchParams.has('sb')) && !userAgent.includes('subconverter'))) {
|
||||
url = `https://${subconverter}/sub?target=singbox&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||
url = `${subProtocol}://${subconverter}/sub?target=singbox&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||
isBase64 = false;
|
||||
}
|
||||
}
|
||||
@@ -1358,8 +1364,11 @@ https://github.com/cmliu/edgetunnel
|
||||
}});
|
||||
content = await response.text();
|
||||
}
|
||||
if (!_url.pathname.includes(`/${fakeUserID}`)) content = revertFakeInfo(content, userID, hostName, isBase64);
|
||||
return content;
|
||||
|
||||
if (_url.pathname == `/${fakeUserID}`) return content;
|
||||
|
||||
return revertFakeInfo(content, userID, hostName, isBase64);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching content:', error);
|
||||
return `Error fetching content: ${error.message}`;
|
||||
@@ -1686,7 +1695,7 @@ function subAddresses(host,UUID,noTLS,newAddressesapi,newAddressescsv,newAddress
|
||||
}).join('\n');
|
||||
|
||||
let base64Response = responseBody; // 重新进行 Base64 编码
|
||||
if(noTLS == 'true') base64Response += `\nnotlsresponseBody`;
|
||||
if(noTLS == 'true') base64Response += `\n${notlsresponseBody}`;
|
||||
return btoa(base64Response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user