Files
opsxshell/shared/types/session.types.ts
T

110 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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
}
/** Jump host / bastion credentials (ProxyJump-style) */
export interface JumpHostConfig {
host: string
port?: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
/** Optional proxy used only when reaching the jump host */
proxy?: ProxyConfig
}
// 会话配置 (用于快速连接)
export interface SSHConnectionConfig {
host: string
port: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
proxy?: ProxyConfig
/** 连接成功后自动发送到 shell 的命令(可含片段变量) */
startupCommand?: string
/** 单跳板(兼容);多跳请用 jumpHosts */
jumpHost?: JumpHostConfig
/** 有序跳板链:第一跳 → … → 最后一跳 → 目标 */
jumpHosts?: JumpHostConfig[]
/** TCP connect and SSH handshake timeout in seconds. */
timeoutSeconds?: number
/** Enable SSH protocol keepalive for this connection. */
keepAlive?: boolean
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链(优先于 jumpSessionId) */
jumpSessionIds?: string[]
}
// 持久化会话
export interface Session {
id: string
name: string
host: string
port: number
username: string
authType: AuthType
password?: string // 加密存储
privateKey?: string // 私钥路径或内容
passphrase?: string // 私钥密码
proxy?: ProxyConfig // 代理配置
/** 连接成功后自动执行的启动命令 */
startupCommand?: string
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链 JSON 持久化 */
jumpSessionIds?: string[]
/** 内联单跳板(兼容) */
jumpHost?: JumpHostConfig
/** 内联多跳板链 */
jumpHosts?: JumpHostConfig[]
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
startupCommand?: string
jumpSessionId?: string
jumpSessionIds?: string[]
jumpHost?: JumpHostConfig
jumpHosts?: JumpHostConfig[]
group?: string
tags?: string[]
}
// 会话更新请求
export type SessionUpdateRequest = Partial<Omit<Session, 'id' | 'createdAt' | 'updatedAt'>>