Skip to content

Commit 4791204

Browse files
committed
fix: 更新读取config_JSON函数,优化反代参数处理逻辑以支持更灵活的路径配置
1 parent 0003e25 commit 4791204

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

_worker.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,13 +1446,15 @@ async function 读取config_JSON(env, hostname, userID, 重置配置 = false) {
14461446
if (env.PATH) config_JSON.PATH = env.PATH.startsWith('/') ? env.PATH : '/' + env.PATH;
14471447
else if (!config_JSON.PATH) config_JSON.PATH = '/';
14481448

1449-
const { SOCKS5, PROXYIP } = config_JSON.反代;
1450-
const PATH反代参数 = SOCKS5.启用 ? `${SOCKS5.启用}${SOCKS5.全局 ? '://' : '='}${SOCKS5.账号}` : (PROXYIP === 'auto' ? '' : `proxyip=${PROXYIP}`);
1451-
config_JSON.PATH = config_JSON.PATH.replace(PATH反代参数, '').replace('//', '/');
1449+
const { SOCKS5: 袜子五, PROXYIP: 反代挨批 } = config_JSON.反代;
1450+
const 路径反代参数 = 袜子五.启用
1451+
? `${袜子五.启用}${袜子五.全局 ? '://' : '='}${袜子五.账号}`
1452+
: 反代挨批 !== 'auto' ? `proxyip=${反代挨批}` : '';
1453+
config_JSON.PATH = config_JSON.PATH.replace(路径反代参数, '').replace('//', '/');
14521454
const normalizedPath = config_JSON.PATH === '/' ? '' : config_JSON.PATH.replace(/\/+(?=\?|$)/, '').replace(/\/+$/, '');
14531455
const [路径部分, ...查询数组] = normalizedPath.split('?');
14541456
const 查询部分 = 查询数组.length ? '?' + 查询数组.join('?') : '';
1455-
config_JSON.完整节点路径 = (路径部分 || '/') + (路径部分 && PATH反代参数 ? '/' : '') + PATH反代参数 + 查询部分 + (config_JSON.启用0RTT ? (查询部分 ? '&' : '?') + 'ed=2560' : '');
1457+
config_JSON.完整节点路径 = (路径部分 || '/') + (路径部分 && 路径反代参数 ? '/' : '') + 路径反代参数 + 查询部分 + (config_JSON.启用0RTT ? (查询部分 ? '&' : '?') + 'ed=2560' : '');
14561458

14571459
if (!config_JSON.TLS分片 && config_JSON.TLS分片 !== null) config_JSON.TLS分片 = null;
14581460
const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : '';

0 commit comments

Comments
 (0)