Skip to content

Commit 818ea9b

Browse files
committed
update:增加源加密功能
1 parent c3f4854 commit 818ea9b

19 files changed

+520
-68
lines changed

.nomedia

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hjdhnx

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ nodejs作为服务端的drpy实现。全面升级异步写法
55
* [本地配置接口-动态本地](/config)
66
* [本地配置接口-动态外网/局域网](/config/1)
77
* [本地配置接口-静态](/index)
8+
* [代码加密工具](/admin/encoder)
89

910
## 更新记录
1011

11-
### 20241205
12+
### 20241206
1213

13-
1. 完善本地代理功能
14+
1. 增加源加密功能
1415

1516
[点此查看完整更新记录](docs/updateRecord.md)
1617

controllers/encoder.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {jsEncoder} from '../libs/drpyS.js';
2+
3+
// 仅仅支持json post 如: {"type":"gzip","code":"xxx"}
4+
export default (fastify, options, done) => {
5+
// 注册 POST 路由
6+
fastify.post('/encoder', async (request, reply) => {
7+
const {code, type} = request.body;
8+
9+
if (!code || !type) {
10+
return reply.status(400).send({error: 'Missing required parameters: code and type'});
11+
}
12+
13+
try {
14+
let result;
15+
16+
switch (type) {
17+
case 'base64':
18+
result = jsEncoder.base64Encode(code);
19+
break;
20+
case 'gzip':
21+
result = jsEncoder.gzip(code);
22+
break;
23+
case 'aes':
24+
result = jsEncoder.aes_encrypt(code);
25+
break;
26+
case 'rsa':
27+
result = jsEncoder.rsa_encode(code);
28+
break;
29+
default:
30+
throw new Error(`Unsupported type: ${type}`);
31+
}
32+
33+
reply.send({success: true, result});
34+
} catch (error) {
35+
reply.status(500).send({error: error.message});
36+
}
37+
});
38+
done();
39+
};

controllers/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import docsController from './docs.js';
22
import configController from './config.js';
33
import apiController from './api.js';
44
import rootController from './root.js';
5+
import encoderController from './encoder.js';
6+
import webController from './web.js';
57

68
export const registerRoutes = (fastify, options) => {
79
fastify.register(docsController, options);
810
fastify.register(configController, options);
911
fastify.register(apiController, options);
1012
fastify.register(rootController, options);
13+
fastify.register(encoderController, options);
14+
fastify.register(webController, options);
1115
};

controllers/web.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {readFileSync, existsSync} from 'fs';
2+
import path from 'path';
3+
4+
export default (fastify, options, done) => {
5+
// 读取 views 目录下的 encoder.html 文件并返回
6+
fastify.get('/admin/encoder', async (request, reply) => {
7+
const encoderFilePath = path.join(options.viewsDir, 'encoder.html'); // 获取 encoder.html 文件的路径
8+
9+
// 检查文件是否存在
10+
if (!existsSync(encoderFilePath)) {
11+
return reply.status(404).send({error: 'encoder.html not found'});
12+
}
13+
14+
try {
15+
// 读取 HTML 文件内容
16+
const htmlContent = readFileSync(encoderFilePath, 'utf-8');
17+
reply.type('text/html').send(htmlContent); // 返回 HTML 文件内容
18+
} catch (error) {
19+
fastify.log.error(`Failed to read encoder.html: ${error.message}`);
20+
return reply.status(500).send({error: 'Failed to load encoder page'});
21+
}
22+
});
23+
24+
done();
25+
};

docs/updateRecord.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# drpyS更新记录
22

3+
### 20241206
4+
5+
更新至V1.0.3
6+
7+
1. 完善图片代理相关函数与功能
8+
2. 增加加密源的数据解析
9+
3. crypto-js-wasm.js兼容海阔调用CryptoJSW对象
10+
4. 更新金牌影视,本地代理修复播放问题
11+
5. 暴露更多函数给drpyS源使用。如gzip、ungzip等等
12+
6. 增加源加密功能
13+
7. 根目录增加.nomedia规避手机相册识别ts文件为媒体图片问题
14+
315
### 20241205
416

517
更新至V1.0.2

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ registerRoutes(fastify, {
2424
rootDir: __dirname,
2525
docsDir: path.join(__dirname, 'docs'),
2626
jsDir: path.join(__dirname, 'js'),
27+
viewsDir: path.join(__dirname, 'views'),
2728
PORT,
2829
indexFilePath: path.join(__dirname, 'index.json'),
2930
customFilePath: path.join(__dirname, 'custom.json'),

index.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,55 @@
44
"key": "drpyS_人人视频",
55
"name": "人人视频(drpyS)",
66
"type": 4,
7-
"api": "http://localhost:5757/api/人人视频",
7+
"api": "http://127.0.0.1:5757/api/人人视频",
88
"searchable": 1,
99
"ext": ""
1010
},
1111
{
1212
"key": "drpyS_星芽短剧",
1313
"name": "星芽短剧(drpyS)",
1414
"type": 4,
15-
"api": "http://localhost:5757/api/星芽短剧",
15+
"api": "http://127.0.0.1:5757/api/星芽短剧",
1616
"searchable": 1,
1717
"ext": ""
1818
},
1919
{
2020
"key": "drpyS_番茄小说[书]",
2121
"name": "番茄小说[书](drpyS)",
2222
"type": 4,
23-
"api": "http://localhost:5757/api/番茄小说[书]",
23+
"api": "http://127.0.0.1:5757/api/番茄小说[书]",
24+
"searchable": 1,
25+
"ext": ""
26+
},
27+
{
28+
"key": "drpyS_色花堂[密+]",
29+
"name": "色花堂[密+](drpyS)",
30+
"type": 4,
31+
"api": "http://127.0.0.1:5757/api/色花堂[密+]",
32+
"searchable": 1,
33+
"ext": ""
34+
},
35+
{
36+
"key": "drpyS_草榴社区[密]",
37+
"name": "草榴社区[密](drpyS)",
38+
"type": 4,
39+
"api": "http://127.0.0.1:5757/api/草榴社区[密]",
2440
"searchable": 1,
2541
"ext": ""
2642
},
2743
{
2844
"key": "drpyS_金牌影院",
2945
"name": "金牌影院(drpyS)",
3046
"type": 4,
31-
"api": "http://localhost:5757/api/金牌影院",
47+
"api": "http://127.0.0.1:5757/api/金牌影院",
48+
"searchable": 1,
49+
"ext": ""
50+
},
51+
{
52+
"key": "drpyS_黑料不打烊[密]",
53+
"name": "黑料不打烊[密](drpyS)",
54+
"type": 4,
55+
"api": "http://127.0.0.1:5757/api/黑料不打烊[密]",
3256
"searchable": 1,
3357
"ext": ""
3458
}

js/色花堂[密+].js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/草榴社区[密].js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)