Skip to content

Commit 88d713c

Browse files
author
Taois
committed
feat: 发布新版本,更加激进,容易出现bug
1 parent aec7613 commit 88d713c

File tree

15 files changed

+752
-303
lines changed

15 files changed

+752
-303
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ nodejs作为服务端的drpy实现。全面升级异步写法
5454

5555
## 更新记录
5656

57+
### 20251013
58+
59+
更新至V1.3.11
60+
5761
### 20251012
5862

5963
更新至V1.3.10

apps/drplayer/assets/LocalBookReader-D8SFu121.js renamed to apps/drplayer/assets/LocalBookReader-CNs5JsEN.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.

apps/drplayer/assets/NovelDownloader-CVJbG4KZ.js renamed to apps/drplayer/assets/NovelDownloader-Dg3_tE4m.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.

apps/drplayer/assets/index-OtG8Py8T.js renamed to apps/drplayer/assets/index-BBpMofy9.js

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

apps/drplayer/assets/index-CNRYp7Q4.css renamed to apps/drplayer/assets/index-BlBJvWTA.css

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

apps/drplayer/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta name="referrer" content="no-referrer" />
88
<title>DrPlayer</title>
9-
<script type="module" crossorigin src="/apps/drplayer/assets/index-OtG8Py8T.js"></script>
10-
<link rel="stylesheet" crossorigin href="/apps/drplayer/assets/index-CNRYp7Q4.css">
9+
<script type="module" crossorigin src="/apps/drplayer/assets/index-BBpMofy9.js"></script>
10+
<link rel="stylesheet" crossorigin href="/apps/drplayer/assets/index-BlBJvWTA.css">
1111
</head>
1212
<body>
1313
<div id="app"></div>

controllers/file-proxy.js

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
makeRemoteRequest,
1414
PROXY_CONSTANTS,
1515
setCorsHeaders,
16-
verifyAuth
16+
verifyAuth,
17+
CacheManagerFactory
1718
} from '../utils/proxy-util.js';
1819

1920
/**
@@ -23,8 +24,8 @@ import {
2324
* @param {Function} done - 完成回调
2425
*/
2526
export default (fastify, options, done) => {
26-
// 请求缓存
27-
const requestCache = new Map();
27+
// 请求缓存 - 使用智能缓存管理器防止内存泄漏
28+
const requestCache = CacheManagerFactory.createRequestCache('FileProxy-RequestCache');
2829

2930
/**
3031
* 远程文件代理健康检查接口
@@ -35,13 +36,18 @@ export default (fastify, options, done) => {
3536

3637
setCorsHeaders(reply);
3738

38-
const healthData = createHealthResponse('Remote File Proxy', {
39-
cache: {
40-
requests: requestCache.size
41-
}
42-
});
39+
const healthData = createHealthResponse(requestCache);
4340

44-
return reply.send(healthData);
41+
return reply.send({
42+
...healthData,
43+
service: 'Remote File Proxy',
44+
features: [
45+
'Remote file streaming',
46+
'Range request support',
47+
'Custom headers forwarding',
48+
'Smart cache management with auto-cleanup'
49+
]
50+
});
4551
});
4652

4753
/**
@@ -228,13 +234,26 @@ export default (fastify, options, done) => {
228234
fastify.get('/file-proxy/status', async (request, reply) => {
229235
setCorsHeaders(reply);
230236

231-
const statusData = createStatusResponse('file-proxy', '1.0.0', {
232-
cache: {
233-
size: requestCache.size,
234-
timeout: PROXY_CONSTANTS.CACHE_TIMEOUT
235-
}
236-
});
237-
237+
const statusData = createStatusResponse(
238+
'Remote File Proxy Controller',
239+
'1.0.0',
240+
[
241+
'Remote file streaming',
242+
'Range request support',
243+
'Custom headers forwarding',
244+
'Authentication protection',
245+
'Smart cache management with auto-cleanup'
246+
],
247+
[
248+
'GET /file-proxy/health - Health check (no auth required)',
249+
'GET /file-proxy/proxy?url=<target_url>&auth=<auth_code>&headers=<custom_headers> - Proxy remote file',
250+
'HEAD /file-proxy/proxy?url=<target_url>&auth=<auth_code>&headers=<custom_headers> - Get file headers',
251+
'GET /file-proxy/status - Get service status (no auth required)'
252+
],
253+
requestCache,
254+
null
255+
);
256+
238257
reply.send(statusData);
239258
});
240259

controllers/ftp-proxy.js

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import {ENV} from '../utils/env.js';
88
import {FTPClient} from '../utils/ftp.js';
9+
import {CacheManagerFactory, createHealthResponse, createStatusResponse} from '../utils/proxy-util.js';
910
import {readFileSync} from 'fs';
1011
import path from 'path';
1112

@@ -16,10 +17,10 @@ import path from 'path';
1617
* @param {Function} done - 完成回调
1718
*/
1819
export default (fastify, options, done) => {
19-
// FTP 客户端缓存
20-
const ftpClients = new Map();
21-
// 文件信息缓存
22-
const fileCache = new Map();
20+
// FTP 客户端缓存 - 使用智能缓存管理器
21+
const ftpClients = CacheManagerFactory.createClientCache('FTPProxy-ClientCache');
22+
// 文件信息缓存 - 使用智能缓存管理器
23+
const fileCache = CacheManagerFactory.createFileCache('FTPProxy-FileCache');
2324
// 缓存超时时间(5分钟)
2425
const cacheTimeout = 5 * 60 * 1000;
2526

@@ -78,15 +79,17 @@ export default (fastify, options, done) => {
7879
fastify.get('/ftp/health', async (request, reply) => {
7980
console.log(`[ftpController] Health check request`);
8081

81-
return reply.send({
82-
status: 'ok',
83-
service: 'FTP Proxy',
84-
timestamp: new Date().toISOString(),
85-
cache: {
86-
clients: ftpClients.size,
87-
files: fileCache.size
88-
}
82+
const healthData = createHealthResponse(ftpClients, fileCache, {
83+
features: [
84+
'FTP file direct link access',
85+
'Smart cache management with auto-cleanup',
86+
'Multiple FTP server support',
87+
'File metadata caching',
88+
'Range request support for large files'
89+
]
8990
});
91+
92+
return reply.send(healthData);
9093
});
9194

9295
/**
@@ -367,32 +370,39 @@ export default (fastify, options, done) => {
367370
const config = loadDefaultConfig();
368371
const processedConfig = processConfig(config);
369372

370-
return reply.send({
371-
service: 'FTP Proxy Controller',
372-
version: '1.0.0',
373-
status: 'running',
374-
cache: {
375-
clients: ftpClients.size,
376-
files: fileCache.size,
377-
timeout: cacheTimeout
378-
},
379-
config: processedConfig ? {
380-
host: processedConfig.host,
381-
port: processedConfig.port || 21,
382-
username: processedConfig.username,
383-
hasPassword: !!processedConfig.password,
384-
secure: processedConfig.secure || false
385-
} : null,
386-
endpoints: [
373+
const statusData = createStatusResponse(
374+
'FTP Proxy Controller',
375+
'1.0.0',
376+
[
377+
'FTP file direct link access',
378+
'Smart cache management with auto-cleanup',
379+
'Multiple FTP server support',
380+
'File metadata caching',
381+
'Range request support for large files'
382+
],
383+
[
387384
'GET /ftp/health - Health check',
388385
'GET /ftp/file?path=<file_path> - Get file direct link',
389386
'GET /ftp/info?path=<file_path> - Get file information',
390387
'GET /ftp/list?path=<dir_path> - List directory contents',
391388
'POST /ftp/config - Test FTP configuration',
392389
'DELETE /ftp/cache - Clear cache',
393390
'GET /ftp/status - Get service status'
394-
]
395-
});
391+
],
392+
ftpClients,
393+
fileCache,
394+
{
395+
config: processedConfig ? {
396+
host: processedConfig.host,
397+
port: processedConfig.port || 21,
398+
username: processedConfig.username,
399+
hasPassword: !!processedConfig.password,
400+
secure: processedConfig.secure || false
401+
} : null
402+
}
403+
);
404+
405+
return reply.send(statusData);
396406
} catch (error) {
397407
console.error('[ftpController] Status request error:', error);
398408
return reply.status(500).send({error: error.message});

0 commit comments

Comments
 (0)