Skip to content

Commit 94d415f

Browse files
authored
Merge pull request #827 from cmliu/beta2.0
fix: 增强用户ID生成逻辑,支持环境变量UUID格式验证
2 parents f49b43f + 9335ed7 commit 94d415f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

_worker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default {
1111
const 管理员密码 = env.ADMIN || env.admin || env.PASSWORD || env.password || env.pswd || env.TOKEN || env.KEY;
1212
const 加密秘钥 = env.KEY || '勿动此默认密钥,有需求请自行通过添加变量KEY进行修改';
1313
const userIDMD5 = await MD5MD5(管理员密码 + 加密秘钥);
14-
const userID = env.UUID || env.uuid || [userIDMD5.slice(0, 8), userIDMD5.slice(8, 12), '4' + userIDMD5.slice(13, 16), userIDMD5.slice(16, 20), userIDMD5.slice(20)].join('-');
14+
const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
15+
const envUUID = env.UUID || env.uuid;
16+
const userID = (envUUID && uuidRegex.test(envUUID)) ? envUUID.toLowerCase() : [userIDMD5.slice(0, 8), userIDMD5.slice(8, 12), '4' + userIDMD5.slice(13, 16), userIDMD5.slice(16, 20), userIDMD5.slice(20)].join('-');
1517
if (env.PROXYIP) {
1618
const proxyIPs = await 整理成数组(env.PROXYIP);
1719
反代IP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];

0 commit comments

Comments
 (0)