fix(remote-backup): 移除调试日志并改进协议类型验证

refactor(migrations): 添加设备字段options配置迁移
This commit is contained in:
zhang1106
2026-03-23 11:09:36 +08:00
parent 66807b1660
commit f51c39284b
3 changed files with 81 additions and 36 deletions
+4 -13
View File
@@ -802,7 +802,6 @@ router.delete('/remote/targets/:id', (req, res) => {
router.post('/remote/test', async (req, res) => {
try {
const config = req.body;
console.log(`[RemoteBackup] 收到连接测试请求:`, JSON.stringify(config));
if (!config.host || !config.port || !config.username) {
return res.status(400).json({
@@ -812,21 +811,13 @@ router.post('/remote/test', async (req, res) => {
}
if (!config.protocol) {
const port = parseInt(config.port);
if (port === 22 || port === 2222) {
config.protocol = 'sftp';
} else if (port === 445 || port === 139 || port === 443) {
config.protocol = 'smb';
} else if (port === 80 || port === 443 || config.url) {
config.protocol = 'webdav';
} else {
config.protocol = 'ftp';
}
console.log(`[RemoteBackup] 推断协议类型: ${config.protocol} (基于端口 ${config.port})`);
return res.status(400).json({
success: false,
message: '请提供协议类型(protocol',
});
}
const result = await testRemoteConnection(config);
console.log(`[RemoteBackup] 连接测试结果:`, JSON.stringify(result));
if (result.success) {
res.json({