Skip to content

Commit c0a5f08

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

32 files changed

+974
-375
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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/

.nomedia

Lines changed: 1 addition & 1 deletion
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==

README.md

Lines changed: 10 additions & 3 deletions
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脚本运行

controllers/api.js

Lines changed: 3 additions & 3 deletions
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
});

controllers/authcoder.js

Lines changed: 34 additions & 0 deletions
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+
};

controllers/decoder.js

Lines changed: 11 additions & 6 deletions
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 {

controllers/fastlogger.js

Lines changed: 71 additions & 0 deletions
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+
});

controllers/index.js

Lines changed: 2 additions & 0 deletions
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
};

custom.json

Lines changed: 16 additions & 0 deletions
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)",

docs/authCoder.md

Lines changed: 5 additions & 0 deletions
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. 将加密后的结果放到凭证验证文件里

0 commit comments

Comments
 (0)