Skip to content

Commit 79ab969

Browse files
committed
feat: 更新订阅转换逻辑,使用临时TOKEN避免真实地址泄露
1 parent 986cf73 commit 79ab969

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [2.1.20260508190728] - 2026-05-08 19:07:28
2+
3+
### Change
4+
5+
- 订阅转换时将提交临时 `TOKEN` 用于转换,避免真实订阅地址泄露。
6+
17
## [2.1.20260508041513] - 2026-05-08 04:15:13
28

39
### Change

_worker.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Version = '2026-05-08 04:15:13';
1+
const Version = '2026-05-08 19:07:28';
22
/*In our project workflow, we first*/ import //the necessary modules,
33
/*then*/ { connect }//to the central server,
44
/*and all data flows*/ from//this single source.
@@ -276,7 +276,16 @@ export default {
276276
return 响应;
277277
} else if (访问路径 === 'sub') {//处理订阅请求
278278
const 订阅TOKEN = await MD5MD5(host + userID), 作为优选订阅生成器 = ['1', 'true'].includes(env.BEST_SUB) && url.searchParams.get('host') === 'example.com' && url.searchParams.get('uuid') === '00000000-0000-4000-8000-000000000000' && UA.toLowerCase().includes('tunnel (https://github.com/cmliu/edge');
279-
if (url.searchParams.get('token') === 订阅TOKEN || 作为优选订阅生成器) {
279+
const 请求TOKEN = url.searchParams.get('token');
280+
const 用户客户端请求订阅 = 请求TOKEN === 订阅TOKEN;
281+
const 当前日序号 = Math.floor(Date.now() / 86400000);
282+
const 订阅转换后端TOKEN种子 = base64SecretEncode(订阅TOKEN, userID);
283+
const [今日订阅转换后端专属TOKEN, 昨日订阅转换后端专属TOKEN] = await Promise.all([
284+
MD5MD5(订阅转换后端TOKEN种子 + 当前日序号),
285+
MD5MD5(订阅转换后端TOKEN种子 + (当前日序号 - 1)),
286+
]);
287+
const 订阅转换后端请求订阅 = 请求TOKEN === 今日订阅转换后端专属TOKEN || 请求TOKEN === 昨日订阅转换后端专属TOKEN;
288+
if (用户客户端请求订阅 || 订阅转换后端请求订阅 || 作为优选订阅生成器) {
280289
config_JSON = await 读取config_JSON(env, host, userID, UA);
281290
if (作为优选订阅生成器) ctx.waitUntil(请求日志记录(env, request, 访问IP, 'Get_Best_SUB', config_JSON, false));
282291
else ctx.waitUntil(请求日志记录(env, request, 访问IP, 'Get_SUB', config_JSON));
@@ -420,7 +429,7 @@ export default {
420429
}
421430
}).filter(item => item !== null).join('\n');
422431
} else { // 订阅转换
423-
const 订阅转换URL = `${config_JSON.订阅转换配置.SUBAPI}/sub?target=${订阅类型}&url=${encodeURIComponent(url.protocol + '//' + url.host + '/sub?target=mixed&token=' + 订阅TOKEN + (url.searchParams.has('sub') && url.searchParams.get('sub') != '' ? `&sub=${url.searchParams.get('sub')}` : ''))}&config=${encodeURIComponent(config_JSON.订阅转换配置.SUBCONFIG)}&emoji=${config_JSON.订阅转换配置.SUBEMOJI}&scv=${config_JSON.跳过证书验证}`;
432+
const 订阅转换URL = `${config_JSON.订阅转换配置.SUBAPI}/sub?target=${订阅类型}&url=${encodeURIComponent(url.protocol + '//' + url.host + '/sub?target=mixed&token=' + 今日订阅转换后端专属TOKEN + (url.searchParams.has('sub') && url.searchParams.get('sub') != '' ? `&sub=${url.searchParams.get('sub')}` : ''))}&config=${encodeURIComponent(config_JSON.订阅转换配置.SUBCONFIG)}&emoji=${config_JSON.订阅转换配置.SUBEMOJI}&scv=${config_JSON.跳过证书验证}`;
424433
try {
425434
const response = await fetch(订阅转换URL, { headers: { 'User-Agent': 'Subconverter for ' + 订阅类型 + ' edge' + 'tunnel (https://github.com/cmliu/edge' + 'tunnel)' } });
426435
if (response.ok) {
@@ -432,7 +441,7 @@ export default {
432441
}
433442
}
434443

435-
if (!ua.includes('subconverter') && !作为优选订阅生成器) {
444+
if (!ua.includes('subconverter') && 用户客户端请求订阅) {
436445
const 打乱后HOSTS = [...config_JSON.HOSTS].sort(() => Math.random() - 0.5);
437446
let 替换域名计数 = 0, 当前随机HOST = null;
438447
订阅内容 = 订阅内容

0 commit comments

Comments
 (0)