feat(proxy): HTTP/SOCKS5 代理支持,按会话独立配置 | 15 files +483/-23 | 96/96 tests passing
功能: - 代理类型定义 (ProxyType, ProxyConfig) - 代理工具函数 (验证、解析、构建URL) + 24 测试 - SSH 连接通过 HTTP CONNECT / SOCKS5 隧道 - 数据库 proxy 列持久化 (JSON) - SessionDialog 代理配置 UI (可折叠面板) - 连接池传递 proxy 到 IPC - sessionStore 类型添加 proxy 支持
This commit is contained in:
1 parent
3f636b1b0e
commit
07c4a5b14f
15 files changed
+757
-23
No files matched your search
@@ -126,6 +126,13 @@ export class DatabaseService {
|
||||
// 列可能已存在,忽略错误
|
||||
}
|
||||
|
||||
// 迁移:添加 proxy 列 (JSON 格式存储代理配置)
|
||||
try {
|
||||
this.db.run(`ALTER TABLE sessions ADD COLUMN proxy TEXT`)
|
||||
} catch (e) {
|
||||
// 列可能已存在,忽略错误
|
||||
}
|
||||
|
||||
this.db.run(`
|
||||
CREATE TABLE IF NOT EXISTS connection_history (
|
||||
id TEXT PRIMARY KEY,
|
||||
@@ -218,8 +225,8 @@ export class DatabaseService {
|
||||
logger.info('Creating session:', session.name, session.host)
|
||||
|
||||
const stmt = this.prepare(`
|
||||
INSERT INTO sessions (id, name, host, port, username, auth_type, password, private_key_path, passphrase_encrypted, group_name, tags)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO sessions (id, name, host, port, username, auth_type, password, private_key_path, passphrase_encrypted, group_name, tags, proxy)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`)
|
||||
|
||||
const id = `session-${Date.now()}`
|
||||
@@ -236,7 +243,8 @@ export class DatabaseService {
|
||||
session.privateKey || null,
|
||||
this.encryptField(session.passphrase),
|
||||
session.group || 'default',
|
||||
session.tags ? JSON.stringify(session.tags) : null
|
||||
session.tags ? JSON.stringify(session.tags) : null,
|
||||
session.proxy ? JSON.stringify(session.proxy) : null
|
||||
)
|
||||
|
||||
this.save()
|
||||
@@ -259,6 +267,7 @@ export class DatabaseService {
|
||||
password: this.decryptField(s.password as string | null) || undefined,
|
||||
privateKey: s.private_key_path as string | undefined,
|
||||
passphrase: this.decryptField(s.passphrase_encrypted as string | null) || undefined,
|
||||
proxy: s.proxy ? JSON.parse(s.proxy as string) as Session['proxy'] : undefined,
|
||||
group: s.group_name as string | undefined,
|
||||
tags: s.tags ? JSON.parse(s.tags as string) as string[] : [],
|
||||
}))
|
||||
@@ -281,6 +290,7 @@ export class DatabaseService {
|
||||
password: this.decryptField(session.password as string | null) || undefined,
|
||||
privateKey: session.private_key_path as string | undefined,
|
||||
passphrase: this.decryptField(session.passphrase_encrypted as string | null) || undefined,
|
||||
proxy: session.proxy ? JSON.parse(session.proxy as string) as Session['proxy'] : undefined,
|
||||
group: session.group_name as string | undefined,
|
||||
tags: session.tags ? JSON.parse(session.tags as string) as string[] : [],
|
||||
}
|
||||
@@ -334,6 +344,10 @@ export class DatabaseService {
|
||||
fields.push('tags = ?')
|
||||
values.push(JSON.stringify(updates.tags))
|
||||
}
|
||||
if (updates.proxy !== undefined) {
|
||||
fields.push('proxy = ?')
|
||||
values.push(updates.proxy ? JSON.stringify(updates.proxy) : null)
|
||||
}
|
||||
|
||||
fields.push('updated_at = CURRENT_TIMESTAMP')
|
||||
values.push(id)
|
||||
|
||||
Reference in new issue
Block a user