@@ -33,105 +33,32 @@ jobs:
3333 process.exit(1);
3434 }
3535
36+ // --- 最终平衡型混淆配置 ---
3637 const obfuscationOptions = {
3738 compact: true,
38- minify: true,
39- controlFlowFlattening: false,
40- deadCodeInjection: false,
41- stringArray: true,
42- stringArrayEncoding: ['base64'],
43- stringArrayThreshold: 0.8,
44- renameGlobals: true,
45- identifierNamesGenerator: 'mangled',
46- transformObjectKeys: true,
47- unicodeEscapeSequence: false,
48- numbersToExpressions: true,
49- splitStrings: true,
50- splitStringsChunkLength: 10,
51- selfDefending: false,
52- debugProtection: false
53- };
54-
55- const obfuscatedCode = JavaScriptObfuscator.obfuscate(originalCode, obfuscationOptions).getObfuscatedCode();
56-
57- fs.writeFileSync('./少年你相信光吗', obfuscatedCode, 'utf8');
58- "
59- env :
60- SOURCE_CODE : ${{ secrets.WORKER_SOURCE_CODE }}
39+ // 启用轻度的逻辑混淆,以平衡安全与性能
40+ controlFlowFlattening: true,
41+ controlFlowFlatteningThreshold: 0.75,
42+ deadCodeInjection: true,
43+ deadCodeInjectionThreshold: 0.4,
6144
62- - name : Commit and push the obfuscated file
63- run : |
64- git config --global user.name 'GitHub Actions Bot'
65- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
66- git add '少年你相信光吗'
67- if git diff --staged --quiet; then
68- echo "No changes to commit, the obfuscated file is already up-to-date."
69- else
70- git commit -m "build: Generate and obfuscate worker script"
71- git push
72- fi const obfuscationOptions = {
73- compact: true,
74- minify: true, // 启用代码压缩
75-
76- // 禁用最高消耗的功能
77- controlFlowFlattening: false,
78- deadCodeInjection: false,
79-
80- // 启用借鉴自新配置的高效保护功能
45+ // 借鉴自新配置的高效保护功能
8146 stringArray: true,
8247 stringArrayEncoding: ['base64'],
83- stringArrayThreshold: 0.8 ,
48+ stringArrayThreshold: 0.75 ,
8449
85- renameGlobals: true, // 重命名全局变量
50+ renameGlobals: true,
8651 identifierNamesGenerator: 'mangled', // 使用更短的混淆名称
8752
88- transformObjectKeys: true,
89- unicodeEscapeSequence: false,
90-
91- // 新增:借鉴自新配置的轻量级混淆技术
9253 numbersToExpressions: true, // 数字转为表达式
9354 splitStrings: true, // 分割字符串
9455 splitStringsChunkLength: 10,
9556
96- // 禁用对性能有潜在影响的选项
97- selfDefending: false,
98- debugProtection: false
99- };
100-
101- const obfuscatedCode = JavaScriptObfuscator.obfuscate(originalCode, obfuscationOptions).getObfuscatedCode();
102-
103- fs.writeFileSync('./少年你相信光吗', obfuscatedCode, 'utf8');
104- "
105- env :
106- SOURCE_CODE : ${{ secrets.WORKER_SOURCE_CODE }}
57+ transformObjectKeys: true,
10758
108- - name : Commit and push the obfuscated file
109- run : |
110- git config --global user.name 'GitHub Actions Bot'
111- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
112- git add '少年你相信光吗'
113- if git diff --staged --quiet; then
114- echo "No changes to commit, the obfuscated file is already up-to-date."
115- else
116- git commit -m "build: Generate and obfuscate worker script"
117- git push
118- fi const obfuscationOptions = {
119- compact: true,
120- // 已禁用:以下是导致 CPU 超时的主要原因
121- controlFlowFlattening: false,
122- deadCodeInjection: false,
123- debugProtection: false,
59+ // 禁用对性能影响最大的选项
12460 selfDefending: false,
125-
126- // 依然保留的核心保护功能
127- disableConsoleOutput: true,
128- identifierNamesGenerator: 'hexadecimal',
129- renameGlobals: true,
130- stringArray: true,
131- stringArrayEncoding: ['base64'],
132- stringArrayThreshold: 1, // 100% 的字符串都将被隐藏
133- transformObjectKeys: true,
134- unicodeEscapeSequence: false
61+ debugProtection: false
13562 };
13663
13764 const obfuscatedCode = JavaScriptObfuscator.obfuscate(originalCode, obfuscationOptions).getObfuscatedCode();
0 commit comments