功能: - 代理类型定义 (ProxyType, ProxyConfig) - 代理工具函数 (验证、解析、构建URL) + 24 测试 - SSH 连接通过 HTTP CONNECT / SOCKS5 隧道 - 数据库 proxy 列持久化 (JSON) - SessionDialog 代理配置 UI (可折叠面板) - 连接池传递 proxy 到 IPC - sessionStore 类型添加 proxy 支持
68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
/**
|
|
* Session Types - 统一的会话类型定义
|
|
* 在主进程和渲染进程间共享
|
|
*/
|
|
|
|
// 认证方式
|
|
export type AuthType = 'password' | 'key' | 'agent'
|
|
|
|
// 代理类型
|
|
export type ProxyType = 'none' | 'http' | 'socks5'
|
|
|
|
// 代理配置
|
|
export interface ProxyConfig {
|
|
type: ProxyType
|
|
host: string
|
|
port: number
|
|
username?: string
|
|
password?: string
|
|
}
|
|
|
|
// 会话配置 (用于快速连接)
|
|
export interface SSHConnectionConfig {
|
|
host: string
|
|
port: number
|
|
username: string
|
|
password?: string
|
|
privateKey?: string
|
|
passphrase?: string
|
|
authType?: AuthType
|
|
proxy?: ProxyConfig
|
|
}
|
|
|
|
// 持久化会话
|
|
export interface Session {
|
|
id: string
|
|
name: string
|
|
host: string
|
|
port: number
|
|
username: string
|
|
authType: AuthType
|
|
password?: string // 加密存储
|
|
privateKey?: string // 私钥路径或内容
|
|
passphrase?: string // 私钥密码
|
|
proxy?: ProxyConfig // 代理配置
|
|
group?: string
|
|
tags?: string[]
|
|
createdAt?: number
|
|
updatedAt?: number
|
|
}
|
|
|
|
// 会话创建请求
|
|
export interface SessionCreateRequest {
|
|
name: string
|
|
host: string
|
|
port: number
|
|
username: string
|
|
authType: AuthType
|
|
password?: string
|
|
privateKey?: string
|
|
passphrase?: string
|
|
proxy?: ProxyConfig
|
|
group?: string
|
|
tags?: string[]
|
|
}
|
|
|
|
// 会话更新请求
|
|
export type SessionUpdateRequest = Partial<Omit<Session, 'id' | 'createdAt' | 'updatedAt'>>
|