tunnel

package
v0.0.0-...-8ba9586 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ITunnel

type ITunnel interface {
	Start(ctx context.Context) error
	Stop() error
}

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

func (*LocalTunnel) Start

func (t *LocalTunnel) Start(ctx context.Context) error

Start 启动本地端口转发

func (*LocalTunnel) Stop

func (t *LocalTunnel) Stop() error

Stop 停止本地端口转发

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

func (*RemoteTunnel) Start

func (t *RemoteTunnel) Start(ctx context.Context) error

Start 启动远程端口转发

func (*RemoteTunnel) Stop

func (t *RemoteTunnel) Stop() error

Stop 停止远程端口转发

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 启动所有隧道

func (*TunnelManager) StopAll

func (m *TunnelManager) StopAll()

StopAll 停止所有隧道

Jump to

Keyboard shortcuts

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