Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalConfig ¶
type LocalConfig struct {
SSH string `yaml:"ssh" mapstructure:"ssh" json:"ssh"` // 对应 Ssh.Name 的值,用于指定使用的 SSH 连接
Local string `yaml:"local" mapstructure:"local" json:"local"` // 本地监听地址与端口(例如 "127.0.0.1:8080")
Remote string `yaml:"remote" mapstructure:"remote" json:"remote"` // 远程目标地址与端口(例如 "example.com:80")
RetryInterval int `yaml:"retry_interval" mapstructure:"retry_interval" json:"retry_interval"` // 连接失败后的重试间隔(秒)
}
type LocalTunnel ¶
type LocalTunnel struct {
SSHConfig sshx.Config // SSH 配置
LocalAddr string // 本地监听地址,如 "127.0.0.1:8080"
RemoteAddr string // 远程目标地址,如 "example.com:80"
// contains filtered or unexported fields
}
LocalTunnel 本地端口转发实现(ssh -L)
func NewLocalTunnel ¶
func NewLocalTunnel(cfg sshx.Config, config LocalConfig) *LocalTunnel
NewLocalTunnel 创建 LocalTunnel
type RemoteConfig ¶
type RemoteConfig struct {
SSH string `yaml:"ssh" mapstructure:"ssh" json:"ssh"` // 对应 Ssh.Name 的值,用于指定使用的 SSH 连接
Local string `yaml:"local" mapstructure:"local" json:"local"` // 本地目标地址(例如 "127.0.0.1:8080")
Remote string `yaml:"remote" mapstructure:"remote" json:"remote"` // 远程监听地址(例如 "0.0.0.0:9000")
RetryInterval int `yaml:"retry_interval" mapstructure:"retry_interval" json:"retry_interval"` // 连接失败后的重试间隔(秒)
}
type RemoteTunnel ¶
type RemoteTunnel struct {
SSHConfig sshx.Config
LocalAddr string // 本地目标地址,如 "127.0.0.1:3306"
RemoteAddr string // 远程监听地址,如 "0.0.0.0:9000"
// contains filtered or unexported fields
}
RemoteTunnel 远程端口转发实现(ssh -R)
func NewRemoteTunnel ¶
func NewRemoteTunnel(cfg sshx.Config, config RemoteConfig) *RemoteTunnel
NewRemoteTunnel 创建 RemoteTunnel
type TunnelManager ¶
type TunnelManager struct {
// contains filtered or unexported fields
}
TunnelManager 管理所有本地和远程隧道
func NewTunnelManager ¶
func NewTunnelManager(ssh []sshx.Config, local []LocalConfig, remote []RemoteConfig) (*TunnelManager, error)
NewTunnelManager 根据配置创建 TunnelManager
func (*TunnelManager) StartAll ¶
func (m *TunnelManager) StartAll(ctx context.Context)
StartAll 启动所有隧道
Click to show internal directories.
Click to hide internal directories.