term

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterConnector added in v1.9.3

func RegisterConnector(c Connector)

RegisterConnector 注册一个终端连接插件。

Types

type ChainBuilder added in v1.9.3

type ChainBuilder interface {
	Build(chain GatewayChain) (Transport, error)
}

ChainBuilder 负责将一条 GatewayChain 构建为一个 Transport。 不同的实现可以支持不同的多跳策略(例如纯 SSH、多协议混合等)。

func NewSSHChainBuilder added in v1.9.3

func NewSSHChainBuilder() ChainBuilder

type ConnectOptions added in v1.9.3

type ConnectOptions map[string]any

ConnectOptions 为不同协议预留的扩展参数。

type Connector added in v1.9.3

type Connector interface {
	// Name 返回协议/插件名称,例如 "ssh"、"rdp"、"k8s_exec" 等。
	Name() string

	// Connect 根据多级网关链路建立到目标的连接,返回抽象的 Session
	Connect(ctx context.Context, chain GatewayChain, opts ConnectOptions) (Session, error)
}

Connector 抽象出终端连接能力,不关心具体协议实现(SSH/RDP/VNC/K8s exec 等)。

func GetConnector added in v1.9.3

func GetConnector(name string) (Connector, bool)

GetConnector 按名称获取插件实现。

type Endpoint added in v1.9.3

type Endpoint struct {
	Host       string
	Port       int
	Username   string
	Password   string
	PrivateKey string
	Passphrase string
	AuthType   string
	Sort       int
}

Endpoint 表示一个通用的远程访问端点(可以是网关,也可以是最终目标主机)。

type FileCapable added in v1.9.3

type FileCapable interface {
	NewSFTP() (*sftp.Client, error)
}

FileCapable 表示 Session 具备文件管理能力,例如 SFTP。

type GatewayChain added in v1.9.3

type GatewayChain []Endpoint

GatewayChain 代表从入口到目标主机的一条多级跳板链路。

type SSHChainBuilder added in v1.9.3

type SSHChainBuilder struct{}

SSHChainBuilder 是基于 SSH 多级网关的 ChainBuilder 实现。 目前将 GatewayChain 里的每个 Endpoint 直接映射为 sshx.GatewayConfig, 在第一次 Dial 时通过 sshx.MultiGatewayManager 打通整条链路。

func (*SSHChainBuilder) Build added in v1.9.3

func (b *SSHChainBuilder) Build(chain GatewayChain) (Transport, error)

type Session added in v1.9.3

type Session interface {
	Protocol() string
	Close() error
	Transport() Transport
}

Session 表示一次建立好的远程会话(可能是 SSH、RDP、K8s exec 等)。 具体能力通过能力接口进行扩展。

type SessionPool

type SessionPool struct {
	// contains filtered or unexported fields
}

func NewSessionPool

func NewSessionPool() *SessionPool

func (*SessionPool) GetSession

func (p *SessionPool) GetSession(id int64) (*Sessions, error)

func (*SessionPool) SetSession

func (p *SessionPool) SetSession(id int64, session *Sessions)

type Sessions

type Sessions struct {
	Session Session
}

func NewSessions

func NewSessions(sess Session) *Sessions

type ShellCapable added in v1.9.3

type ShellCapable interface {
	NewTerminal(ws *websocket.Conn, rows, cols int) (TerminalSession, error)
}

ShellCapable 表示 Session 具备创建交互式终端的能力。

type TerminalSession added in v1.9.3

type TerminalSession interface {
	Start()
	Stop()
	Resize(rows, cols int) error
	Write(data []byte) error
	Ping() error
}

TerminalSession 抽象了一个与终端交互的会话能力,用于绑定 websocket。

type Transport added in v1.9.3

type Transport interface {
	Dial(ctx context.Context, ep Endpoint) (net.Conn, error)
}

Transport 抽象了多跳链路上的传输能力,负责根据 Endpoint 建立底层连接。 后续可以有多种实现:直连、SSH 多跳、代理隧道等。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL