launcher

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package launcher provides SSH/SCP connection and file transfer capabilities.

Index

Constants

View Source
const (
	SSHProtocol   = "tcp"
	TerminalTerm  = "xterm"
	SSHKeyKeyword = "SSH-KEY"
)

SSHProtocol, TerminalTerm, and SSHKeyKeyword are constants used in SSH connection setup.

Variables

This section is empty.

Functions

func GetConfigFromSSHConnector added in v0.4.0

func GetConfigFromSSHConnector(tgt *SSHConnector) *config.ServerListConfig

GetConfigFromSSHConnector converts an SSHConnector back into a ServerListConfig.

Types

type Connector

type Connector interface {
	Launch() bool
	CreateConnection() (sshClient *ssh.Client, err error)
	CloseConnection(sshClient *ssh.Client)
	TryToConnect() (err error)
}

Connector defines the interface for launching SSH/SCP connections and testing connectivity.

type SSHConnector added in v0.4.0

type SSHConnector struct {
	IP         string
	Port       string
	User       string
	Password   string
	Key        string
	SSHTimeout time.Duration
	Dialer     SSHDialer
	KnownHosts string
}

SSHConnector holds the parameters and state needed to establish an SSH connection.

func GetSSHConnectorFromConfig added in v0.4.0

func GetSSHConnectorFromConfig(conf *config.ServerListConfig) *SSHConnector

GetSSHConnectorFromConfig creates an SSHConnector from a ServerListConfig entry.

func (*SSHConnector) BuildSSHConfig added in v0.4.0

func (sc *SSHConnector) BuildSSHConfig() (cfg *ssh.ClientConfig)

BuildSSHConfig creates an SSH client configuration with appropriate auth methods.

func (*SSHConnector) CloseConnection added in v0.4.0

func (sc *SSHConnector) CloseConnection(sshClient *ssh.Client)

CloseConnection closes the given SSH client connection.

func (*SSHConnector) CreateConnection added in v0.4.0

func (sc *SSHConnector) CreateConnection() (sshClient *ssh.Client, err error)

CreateConnection establishes an SSH connection using the configured parameters.

func (*SSHConnector) TryToConnect added in v0.4.0

func (sc *SSHConnector) TryToConnect() (err error)

TryToConnect attempts to establish and then immediately close an SSH connection.

type SSHDialer added in v0.4.0

type SSHDialer interface {
	Dial(network, address string, config *ssh.ClientConfig) (*ssh.Client, error)
}

SSHDialer abstracts the SSH dial operation for testability.

type SSHLauncher added in v0.4.0

type SSHLauncher struct {
	SSHConnector
}

SSHLauncher handles interactive SSH terminal sessions.

func NewSSHLaunchersByCombinations added in v0.4.0

func NewSSHLaunchersByCombinations(combinations chan []interface{},
	sshTimeout time.Duration) (launchers []*SSHLauncher)

NewSSHLaunchersByCombinations creates SSHLauncher instances from a channel of credential combinations.

func (*SSHLauncher) Launch added in v0.4.0

func (h *SSHLauncher) Launch() bool

Launch starts an interactive SSH session and returns true on success.

type ScpLauncher

type ScpLauncher struct {
	SSHConnector
	Src       string
	Dest      string
	Recursive bool
}

ScpLauncher handles SCP file transfer operations over SSH.

func NewScpLaunchersByCombinations

func NewScpLaunchersByCombinations(combinations chan []interface{}, src string, dest string,
	recursive bool, sshTimeout time.Duration) (launchers []*ScpLauncher)

NewScpLaunchersByCombinations creates ScpLauncher instances from a channel of credential combinations.

func (*ScpLauncher) Launch

func (c *ScpLauncher) Launch() bool

Launch performs the SCP file transfer and returns true on success.

Jump to

Keyboard shortcuts

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