Skip to content

Commit c0a5f08

Browse files
committed
update:更新一大堆内容,不想描述了。
1 parent 7689110 commit c0a5f08

32 files changed

+974
-375
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
/local/

Diff for: .nomedia

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
hjdhnx
1+
DM8U8pJ0qw0O5YK/a9FfWRh7mj3m+j9WtKTfOMvdDFUrbU1kT+yeBvoxwGdrZ1KXVfDJ/Smh4LSq3+A07ebBNwfxy7V3aRJuEAJQ9gLETBJ1oYahMY2WOwmxl8yeqUcBzcbaI45HpFKzqYnsZrV34ddBzRIac11sammtk4UbppFzfoSSOY0HdcLahBWc7UOBV+t/CSl1y5ut5qXdbKorYOK+t789Ifb7fTrhzpmG21l4y+AqwGLKyDiHAWQA76nMVBWyJSdNRu9EQ8CtRPBnpTi03h8eQNWopr8KUs8ghbTLEndyn/q/mBkrQ5i05DilDexDN3DRq4p3UpNli00piWSwTm+P8OnYiENoOVMAMc3F87CQkdTwTxmnPCZsrIM5VM7Dgaea4KCsIwsLxnZ9o5lZ02AWPB/3a9GPEBwOEQeuOW2sz7LD7nuSWxOA4fujjSTQogdfrMzyUtJbSNr/iTBm6XhFAlokvJpNX7HzjDXanq9CVhp1bOw3qQ7WsOloke95ITC6Ou89n+qg6A/2oMzvms94E9CZ1JzoR7EG2WM6djeAugx79Sd3+jH6uSkfYP1qiSUK48mtrQUooxJ7SzEVGHkD33Q3bxX2K2rnX5SdtgYlS99JsoMmjOPaSHsnaK6Y7OTi1hZl1jPcwYT54UutJwAc2XgWhgmOXRpI7RU9qFvPbYnLvplCIjAtsSnRdrJTOIjkDwm3IoNaevIdHZ2y9/lR/u2WH2gFJEzOLuqLS8rSY7uBSq3tzpay8hPqo6KB1eOos7hp3/zdOlABVUaJHkZ+WSCWPmzXUW0WTKKQiOOrIFXeFmccnmljR33iKPecMVugHxr3+2xgDY487Qt9F1EUHZwcVJ6CeVYhpsZUSnsyyJ6iNfNiG33+KA9q5/+pMKQgf2iaB0uJmeI+/pwmfd8hZrDxskRYy23wPVv5fz/GOoTk7ply/keZpF4iJHW/hI5wbhgjhq4kgvkcA8vY7nKhhTvlPStZ8o+jDqB3lOxyzpCzrfd2mwdOCDRDUF7Jy6ljB2ABizIYDMlyPMaiV2QjIAUGv+va0k1E2EKsPgefezQ9q7io+RNY6vUHcILCFw2duBixZnBGZPIJ70srGS6UsLN+AmMkeTCMH1j4k6q/JnQFE1qQGL+m2kM5BYun+pFvwHwrBw3SmQVq2ProW2LLFw/5nuNTePHXpJSc3kQNZ0RDCn202HRG6495DHS3q9cFF74RP+PpJmlYnxuGgjGUqkyg3Fro37fgW2m1Etqprs9ZIuDxvOGhz5DkqIf9swzMpW8VUU+qQD2TB/nRncHLA/qhmReh87YyyMHzxLsMt3A5Q+LdFnBxlGAFjpL2+2FnsSalgf2jwVGKecO1iyzePzvJWM+pQQTrt6RW6Y7PWEZQlLwTZd5US8RI4EprbhS7sVFwyH6MnbaiIM0BJekVk0PGbcIqSbFjdLQNNcdAt6Zvh2s0mSQwIcAjZ2f3/ZA31RrNS76lGUEI0A==

Diff for: README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ nodejs作为服务端的drpy实现。全面升级异步写法
66
* [本地配置接口-动态外网/局域网](/config/1)
77
* [本地配置接口-静态](/index)
88
* [代码加解密工具](/admin/encoder)
9+
* [V我50支付凭证生成器](/authcoder?len=10&number=1)
10+
* [接口压测教程](/docs/httpTest.md)
911

1012
## 更新记录
1113

12-
### 20241206
14+
### 20241207
1315

14-
1. 增加源加密功能
16+
更新至V1.0.4
17+
18+
1. 修复黑料搜索
1519

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

@@ -33,8 +37,11 @@ todo:
3337
4. pino-pretty
3438
5. deasync
3539

36-
3740
## 参考资料
3841

3942
* [crypto-js-wasm使用教程](docs/crypto-js-wasm/readme-CN.md)
4043
* [puppeteer使用教程](docs/pupInstall.md)
44+
45+
## 问题说明
46+
47+
1. windows上直接运行index.js可能会发现运行过程中的日志打印出中文乱码。建议通过yarn dev运行或者在package.json里点击dev脚本运行

Diff for: controllers/api.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default (fastify, options, done) => {
8181
// console.error('Error processing request:', error);
8282
// reply.status(500).send({error: `Failed to process request for module ${moduleName}: ${error.message}`});
8383

84-
fastify.log.error(`Error processing module ${moduleName}:`, error);
84+
fastify.log.error(`Error proxy module ${moduleName}:${error.message}`);
8585
reply.status(500).send({error: `Failed to process module ${moduleName}: ${error.message}`});
8686
}
8787
});
@@ -95,7 +95,7 @@ export default (fastify, options, done) => {
9595
return;
9696
}
9797
const proxy_url = request.params['*']; // 捕获整个路径
98-
fastify.log.info(`try proxy for ${moduleName} -> ${proxy_url}:`);
98+
fastify.log.info(`try proxy for ${moduleName} -> ${proxy_url}: ${JSON.stringify(query)}`);
9999
const protocol = request.protocol;
100100
const hostname = request.hostname;
101101
const proxyUrl = `${protocol}://${hostname}${request.url}`.split('?')[0].replace(proxy_url, '') + '?do=js';
@@ -152,7 +152,7 @@ export default (fastify, options, done) => {
152152
}
153153

154154
} catch (error) {
155-
fastify.log.error(`Error proxy module ${moduleName}:`, error);
155+
fastify.log.error(`Error proxy module ${moduleName}:${error.message}`);
156156
reply.status(500).send({error: `Failed to proxy module ${moduleName}: ${error.message}`});
157157
}
158158
});

Diff for: controllers/authcoder.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as misc from '../utils/misc.js';
2+
3+
export default (fastify, options, done) => {
4+
// 注册 /authcoder 路由
5+
fastify.get('/authcoder', async (request, reply) => {
6+
const {len, number} = request.query;
7+
8+
// 参数校验
9+
if (!len || !number || isNaN(len) || isNaN(number)) {
10+
return reply.status(400).send('Missing or invalid required parameters: len and number');
11+
}
12+
13+
const length = parseInt(len, 10);
14+
const count = parseInt(number, 10);
15+
16+
if (length <= 0 || count <= 0) {
17+
return reply.status(400).send('Parameters len and number must be positive integers.');
18+
}
19+
20+
try {
21+
// 生成随机字符串集合
22+
const result = Array.from({length: count}, () => misc.randStr(length)).join('\n');
23+
24+
// 返回 text/plain 响应
25+
reply.type('text/plain').send(result);
26+
} catch (error) {
27+
// 异常处理
28+
fastify.log.error(error);
29+
reply.status(500).send('An error occurred while generating strings.');
30+
}
31+
});
32+
33+
done();
34+
};

Diff for: controllers/decoder.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {getOriginalJs} from '../libs/drpyS.js';
1+
import {getOriginalJs, jsDecoder} from '../libs/drpyS.js';
22
import {readFileSync, existsSync} from 'fs';
33
import path from "path";
44

@@ -17,11 +17,16 @@ export default (fastify, options, done) => {
1717
if (!existsSync(authFilePath)) {
1818
return reply.status(404).send({error: '.nomedia file not found'});
1919
}
20-
const local_auto_code = readFileSync(authFilePath, 'utf-8').trim();
21-
console.log('local_auto_code:',local_auto_code);
22-
console.log('auth_code:',auth_code);
23-
if (auth_code !== local_auto_code) {
24-
return reply.status(200).send({error: 'your auth_code is not correct'});
20+
try {
21+
const local_auto_code = readFileSync(authFilePath, 'utf-8').trim();
22+
const auth_codes = jsDecoder.aes_decrypt(local_auto_code).trim().split('\n');
23+
// console.log('auth_codes:',auth_codes);
24+
// console.log('auth_code:', auth_code);
25+
if (!auth_codes.includes(auth_code)) {
26+
return reply.status(200).send({error: 'your auth_code is not correct'});
27+
}
28+
} catch (error) {
29+
return reply.status(200).send({error: error.message});
2530
}
2631

2732
try {

Diff for: controllers/fastlogger.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import fs from "fs";
2+
import path from 'path';
3+
import pino from "pino";
4+
import Fastify from "fastify";
5+
import {fileURLToPath} from 'url';
6+
import {createStream} from 'rotating-file-stream';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const logDirectory = path.join(__dirname, '../logs');
11+
if (!fs.existsSync(logDirectory)) {
12+
fs.mkdirSync(logDirectory);
13+
}
14+
// 自定义时间戳函数,格式为 YYYY-MM-DD HH:mm:ss
15+
const customTimestamp = () => {
16+
const now = new Date();
17+
const yyyy = now.getFullYear();
18+
const mm = String(now.getMonth() + 1).padStart(2, '0');
19+
const dd = String(now.getDate()).padStart(2, '0');
20+
const hours = String(now.getHours()).padStart(2, '0');
21+
const minutes = String(now.getMinutes()).padStart(2, '0');
22+
const seconds = String(now.getSeconds()).padStart(2, '0');
23+
const formattedTime = `${yyyy}-${mm}-${dd} ${hours}:${minutes}:${seconds}`;
24+
return `,"time":"${formattedTime}"`; // 返回格式化后的时间戳
25+
};
26+
27+
// const logStream = fs.createWriteStream(path.join(logDirectory, 'output.log'), {
28+
// flags: 'a',
29+
// encoding: 'utf8',
30+
// });
31+
// 配置日志文件的轮转
32+
33+
const logStream = createStream(path.join(logDirectory, 'output.log'), {
34+
size: '500M', // 设置最大文件大小为 500MB
35+
compress: true, // 自动压缩旧的日志文件
36+
encoding: 'utf8', // 设置日志文件的编码为 utf8
37+
interval: '1d' // 每天轮转一次日志
38+
});
39+
export const fileLogger = pino(
40+
{
41+
// 使用标准的时间戳函数并格式化为 ISO 格式
42+
// timestamp: pino.stdTimeFunctions.isoTime,
43+
timestamp: customTimestamp,
44+
},
45+
logStream
46+
);
47+
48+
// 创建两个 logger 实例
49+
const consoleLogger = pino({
50+
level: "debug", // 设置记录的最低日志级别
51+
serializers: {
52+
req: pino.stdSerializers.req, // 标准请求序列化器
53+
res: pino.stdSerializers.res, // 标准响应序列化器
54+
},
55+
// timestamp: pino.stdTimeFunctions.isoTime,
56+
timestamp: customTimestamp,
57+
// transport: {
58+
// target: 'pino-pretty',
59+
// options: {
60+
// translateTime: true,
61+
// singleLine: true, // 强制单行输出
62+
// colorize: false, // 禁用颜色,保持纯 JSON
63+
// ignore: 'reqId,remoteAddress,remotePort',
64+
// },
65+
// },
66+
}, logStream);
67+
// const fastify = Fastify({logger: true});
68+
// 初始化 Fastify 实例,使用 consoleLogger 输出控制台日志
69+
export const fastify = Fastify({
70+
logger: consoleLogger,
71+
});

Diff for: controllers/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import apiController from './api.js';
44
import rootController from './root.js';
55
import encoderController from './encoder.js';
66
import decoderController from './decoder.js';
7+
import authCoderController from './authcoder.js';
78
import webController from './web.js';
89

910
export const registerRoutes = (fastify, options) => {
@@ -13,5 +14,6 @@ export const registerRoutes = (fastify, options) => {
1314
fastify.register(rootController, options);
1415
fastify.register(encoderController, options);
1516
fastify.register(decoderController, options);
17+
fastify.register(authCoderController, options);
1618
fastify.register(webController, options);
1719
};

Diff for: custom.json

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"sites": [
3+
{
4+
"key": "drpyS_xvideos[密]",
5+
"name": "xvideos[密](drpyS)",
6+
"type": 4,
7+
"api": "http://192.168.31.49:5757/api/xvideos[密]",
8+
"searchable": 1,
9+
"ext": ""
10+
},
311
{
412
"key": "drpyS_人人视频",
513
"name": "人人视频(drpyS)",
@@ -8,6 +16,14 @@
816
"searchable": 1,
917
"ext": ""
1018
},
19+
{
20+
"key": "drpyS_动漫巴士[漫]",
21+
"name": "动漫巴士[漫](drpyS)",
22+
"type": 4,
23+
"api": "http://192.168.31.49:5757/api/动漫巴士[漫]",
24+
"searchable": 1,
25+
"ext": ""
26+
},
1127
{
1228
"key": "drpyS_星芽短剧",
1329
"name": "星芽短剧(drpyS)",

Diff for: docs/authCoder.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# V我50支付凭证生成工具
2+
3+
1. 访问 http://localhost:5757/authcoder?len=10&number=1
4+
2. 将生成的结果复制到加密工具,选择aes加密
5+
3. 将加密后的结果放到凭证验证文件里

Diff for: docs/httpTest.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 压测说明
2+
3+
仅限windows设备上运行
4+
5+
1. 打开soft目录runnerGo_win_x64.exe
6+
2. 使用谷歌浏览器访问 https://runnergo.apipost.cn/
7+
8+
根据页面提示进行接口并发能力和压力测试

Diff for: docs/updateRecord.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# drpyS更新记录
22

3+
### 20241207
4+
5+
更新至V1.0.4
6+
7+
1. 添加源【动漫巴士】
8+
2. 修改headless-util.js
9+
3. 增加hostJs异步函数,使用示例:
10+
4. 优化会员解密功能
11+
5. 优化访问日志输出到本地文件并自动轮转
12+
6. 黑料源使用CryptoJSW提高图片解密速度
13+
7. 优化yarn dev解决控制台日志乱码问题
14+
8. 移植原drpy2的request、post、fetch、reqCookie、getCode、checkHtml、verifyCode等方法并改为异步
15+
9. 增加原drpy2的同步函数 setItem、getItem、clearItem
16+
10. 增加_lib.request.js依赖库,实现了 `requestHtml``requestJson`简单封装
17+
11. 在常用一级、二级、搜索等函数里的this里增加jsp、pd、pdfa、pdfh确保指向的链接为当前this的MY_URL
18+
12. 修复pd系列函数取不到属性的问题。新增xvideos源,重写黑料里不正确的pd用法,修复黑料的搜索
19+
20+
```javascript
21+
var rule = {
22+
hostJs: async function () {
23+
let {HOST} = this;
24+
log('HOST:', HOST);
25+
return 'https://www.baidu.com';
26+
}
27+
}
28+
```
29+
330
### 20241206
431

532
更新至V1.0.3
@@ -41,7 +68,7 @@ let vod_url = getProxyUrl() + '&url=' + 'https://hls09.cntv.myhwcdn.cn/asp/hls/2
4168
8. 增加本地代理功能,示例(跳转百度):
4269

4370
```javascript
44-
{
71+
var rule = {
4572
proxy_rule: async function (params) {
4673
// log(this);
4774
let {input, MY_URL} = this;

Diff for: index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import Fastify from 'fastify';
21
import fastifyStatic from '@fastify/static';
2+
import * as fastlogger from './controllers/fastlogger.js'
33
import path from 'path';
44
import os from 'os';
55
import {fileURLToPath} from 'url';
66

7-
// 初始化 Fastify
8-
const fastify = Fastify({logger: true});
7+
const {fastify, fileLogger} = fastlogger;
98

109
// 获取当前路径
1110
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -56,6 +55,7 @@ const start = async () => {
5655
console.log(`- PLATFORM: ${process.platform}`);
5756
} catch (err) {
5857
fastify.log.error(err);
58+
fileLogger.error(err);
5959
process.exit(1);
6060
}
6161
};

Diff for: index.json

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"sites": [
3+
{
4+
"key": "drpyS_xvideos[密]",
5+
"name": "xvideos[密](drpyS)",
6+
"type": 4,
7+
"api": "http://192.168.31.49:5757/api/xvideos[密]",
8+
"searchable": 1,
9+
"ext": ""
10+
},
311
{
412
"key": "drpyS_人人视频",
513
"name": "人人视频(drpyS)",
@@ -8,6 +16,14 @@
816
"searchable": 1,
917
"ext": ""
1018
},
19+
{
20+
"key": "drpyS_动漫巴士[漫]",
21+
"name": "动漫巴士[漫](drpyS)",
22+
"type": 4,
23+
"api": "http://192.168.31.49:5757/api/动漫巴士[漫]",
24+
"searchable": 1,
25+
"ext": ""
26+
},
1127
{
1228
"key": "drpyS_星芽短剧",
1329
"name": "星芽短剧(drpyS)",

Diff for: js/_fq.js

+9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ var rule = {
1212
log(btoa('123456'));
1313
log(misc.randMAC());
1414
log(getRandomFromList(['drpy','drpyS','hipy']));
15+
// return {}
16+
},
17+
headers:{
18+
'User-Agent':'PC_UA',
1519
},
1620
预处理: async () => {
1721
},
1822
推荐: async () => {
23+
// globalThis.fetch_params = {'ua':'xxxx'} // 移除fetch_params,因为不能局部变量,全局变量会导致串数据
24+
// let html = await request('https://www.baidu.com/')
25+
// log(html)
26+
log(typeof RULE_CK,RULE_CK);
27+
RULE_CK = 'xxx2';
1928
return []
2029
},
2130
一级: async (tid, pg, filter, extend) => {

0 commit comments

Comments
 (0)