Skip to content

Commit b402d71

Browse files
committed
update:修改一些细节
1 parent 0efbbf4 commit b402d71

19 files changed

+163
-66
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ nodejs作为服务端的drpy实现。全面升级异步写法
1111

1212
## 更新记录
1313

14-
### 20241211
14+
### 20241212
1515

16-
更新至V1.0.8
16+
更新至V1.0.9
1717

18-
1. 满血版央视大全!!!
18+
1. 尝试修复已知问题
1919

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

controllers/decoder.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ export default (fastify, options, done) => {
1111
if (!code || !auth_code) {
1212
return reply.status(400).send({error: 'Missing required parameters: code and auth_code'});
1313
}
14+
// 检查文本大小
15+
const textSize = Buffer.byteLength(code, 'utf8'); // 获取 UTF-8 编码的字节大小
16+
if (textSize > options.MAX_TEXT_SIZE) {
17+
return reply
18+
.status(400)
19+
.send({error: `Text content exceeds the maximum size of ${options.MAX_TEXT_SIZE / 1024} KB`});
20+
}
21+
1422
const authFilePath = path.join(options.rootDir, '.nomedia');
1523

1624
// 检查文件是否存在

controllers/encoder.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export default (fastify, options, done) => {
1010
return reply.status(400).send({error: 'Missing required parameters: code and type'});
1111
}
1212

13+
// 检查文本大小
14+
const textSize = Buffer.byteLength(code, 'utf8'); // 获取 UTF-8 编码的字节大小
15+
if (textSize > options.MAX_TEXT_SIZE) {
16+
return reply
17+
.status(400)
18+
.send({error: `Text content exceeds the maximum size of ${options.MAX_TEXT_SIZE / 1024} KB`});
19+
}
20+
1321
try {
1422
let result;
1523

docs/updateRecord.md

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

3+
### 20241212
4+
5+
更新至V1.0.9
6+
7+
1. drpyS加解密工具增加文本大小限制,目前默认为100KB,防止垃圾大数据恶意攻击接口服务
8+
2. 修复央视大全本地代理接口没有动态获取导致可能外网播放地址出现127开头内网地址无法播放的问题
9+
3. 升级axios单文件版到1.7.9
10+
4. 往libsSanbox注入eval函数(非直接注入,仅针对海阔,直接注入会用不了),暂时解决海阔不支持vm里执行eval的问题,但是问题来了,存在作用域问题不要轻易使用,暂时无法解决。(已检测此eval不可以逃逸vm和直接获取drpyS内的变量,勉强能用)
11+
5. 尝试$.require支持网络导入远程js依赖,要求1s内的数据(千万不要导入自己服务的静态文件,会导致阻塞)
12+
313
### 20241211
414

515
更新至V1.0.8

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {fastify, fileLogger} = fastlogger;
99
// 获取当前路径
1010
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1111
const PORT = 5757;
12+
const MAX_TEXT_SIZE = 100 * 1024; // 设置最大文本大小为 100 KB
1213

1314
// 静态资源
1415
fastify.register(fastifyStatic, {
@@ -25,6 +26,7 @@ registerRoutes(fastify, {
2526
jsDir: path.join(__dirname, 'js'),
2627
viewsDir: path.join(__dirname, 'views'),
2728
PORT,
29+
MAX_TEXT_SIZE,
2830
indexFilePath: path.join(__dirname, 'index.json'),
2931
customFilePath: path.join(__dirname, 'custom.json'),
3032
});

js/_fq2.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// http://localhost:5757/api/番茄小说[书]?ac=list&t=主分类&pg=1
2-
32
const {getRandomFromList} = $.require('./_lib.random.js');
43

54
function testHls() {
@@ -45,7 +44,6 @@ var rule = {
4544
log('oheaders:', oheaders)
4645
log('rule_fetch_params:', rule_fetch_params)
4746
log('type of batchFetch:', batchFetch)
48-
4947
testHls()
5048
// return {}
5149
},

js/_fq3.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const {getIp} = $.require('http://127.0.0.1:5757/public/ip.js');
2+
3+
var rule = {
4+
类型: '小说',
5+
title: '番茄小说[书]',
6+
desc: '番茄小说纯js版本',
7+
host: 'https://fanqienovel.com/',
8+
homeUrl: 'https://fanqienovel.com/api/author/book/category_list/v0/',
9+
url: '/api/author/library/book_list/v0/?page_count=18&page_index=(fypage-1)&gender=-1&category_id=fyclass&creation_status=-1&word_count=-1&sort=0#fyfilter',
10+
class_parse: async () => {
11+
log('ip:', getIp());
12+
},
13+
headers: {
14+
'User-Agent': 'PC_UA',
15+
},
16+
预处理: async () => {
17+
},
18+
一级: async function (tid, pg, filter, extend) {
19+
},
20+
二级: async function () {
21+
return '这是二级:' + rule.title
22+
},
23+
搜索: async function () {
24+
return '这是搜索:' + rule.title
25+
},
26+
lazy: async function () {
27+
return template.getMubans()
28+
},
29+
};

js/_lib.request.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import axios from '../libs_drpy/axios.min.js';
2-
31
async function requestHtml(url, options) {
42
try {
53
let html = (await req(url, options)).content;

js/央视大全[官].js

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

libs/drpyS.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ export async function init(filePath, env, refresh) {
214214
// 创建一个沙箱上下文,注入需要的全局变量和函数
215215
const sandbox = {
216216
console, // 将 console 注入沙箱,便于调试
217+
// eval, // 直接引入原生 eval(不要这样用,环境是隔离的会导致执行不符合预期,需要包装)
218+
WebAssembly, // 允许使用原生 WebAssembly(这里即使不引用也可以在沙箱里用这个变量。写在这里骗骗自己吧)
217219
setTimeout, // 注入定时器方法
218220
setInterval,
219221
clearTimeout,
@@ -226,7 +228,11 @@ export async function init(filePath, env, refresh) {
226228
...drpyCustomSanbox,
227229
...libsSanbox,
228230
};
229-
231+
if (typeof fetchByHiker !== 'undefined'){ // 临时解决海阔不支持eval问题,但是这个eval存在作用域问题,跟非海阔环境的有很大区别,属于残废版本
232+
sandbox.eval = function (code) {
233+
return vm.runInContext(code, sandbox);
234+
};
235+
}
230236
// 创建一个上下文
231237
const context = vm.createContext(sandbox);
232238

0 commit comments

Comments
 (0)