Documentation ¶
Overview ¶
Package ssh contains abstractions which manage SSH connections for the user, allowing for faster and easier remote execution
Index ¶
- type Client
- func (sshClient *Client) Close()
- func (sshClient *Client) DockerCp(node Node, source string, dest string) error
- func (sshClient *Client) DockerExec(node Node, command string) (string, error)
- func (sshClient *Client) DockerExecd(node Node, command string) (string, error)
- func (sshClient *Client) DockerExecdLog(node Node, command string) error
- func (sshClient *Client) DockerExecdLogAppend(node Node, command string) error
- func (sshClient *Client) DockerExecdit(node Node, command string) (string, error)
- func (sshClient *Client) DockerMultiExec(node Node, commands []string) (string, error)
- func (sshClient *Client) DockerRead(node Node, file string, lines int) (string, error)
- func (sshClient *Client) FastMultiRun(commands ...string) (string, error)
- func (sshClient *Client) InternalScp(src string, dest string) error
- func (sshClient *Client) KTDockerMultiExec(node Node, commands []string) (string, error)
- func (sshClient *Client) KeepTryDockerExec(node Node, command string) (string, error)
- func (sshClient *Client) KeepTryDockerExecAll(node Node, commands ...string) ([]string, error)
- func (sshClient *Client) KeepTryRun(command string) (string, error)
- func (sshClient *Client) MultiRun(commands ...string) ([]string, error)
- func (sshClient *Client) Run(command string) (string, error)
- func (sshClient *Client) Scp(src string, dest string) error
- type Node
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client maintains a persistent connect with a server, allowing commands to be run on that server. This object is thread safe.
func NewClient ¶
NewClient creates an instance of Client, with a connection to the host server given.
func (*Client) Close ¶
func (sshClient *Client) Close()
Close cleans up the resources used by sshClient object
func (*Client) DockerCp ¶
DockerCp copies a file on a remote machine from source to the dest in the node
func (*Client) DockerExec ¶
DockerExec executes a command inside of a node
func (*Client) DockerExecd ¶
DockerExecd runs the given command, and then returns immediately. This function will not return the output of the command. This is useful if you are starting a persistent process inside a container
func (*Client) DockerExecdLog ¶
DockerExecdLog will cause the stdout and stderr of the command to be stored in the logs. Should only be used for the blockchain process.
func (*Client) DockerExecdLogAppend ¶
DockerExecdLogAppend will cause the stdout and stderr of the command to be stored in the logs. Should only be used for the blockchain process. Will append to existing logs.
func (*Client) DockerExecdit ¶
DockerExecdit runs the given command, and then returns immediately. This function will not return the output of the command. This is useful if you are starting a persistent process inside a container. Also flags the session as interactive and sets up a virtual tty.
func (*Client) DockerMultiExec ¶
DockerMultiExec will run all of the given commands strung together with && on the given node.
func (*Client) DockerRead ¶
DockerRead will read a file on a node, if lines > -1 then it will return the last `lines` lines of the file
func (*Client) FastMultiRun ¶
FastMultiRun speeds up remote execution by chaining commands together
func (*Client) InternalScp ¶
InternalScp is a wrapper for the scp command. Can be used to copy a file over to a remote machine. This is for internal use, and may cause unpredictable behavior. Use Scp instead
func (*Client) KTDockerMultiExec ¶
KTDockerMultiExec is like DockerMultiExec, except it keeps attempting the command after failure
func (*Client) KeepTryDockerExec ¶
KeepTryDockerExec is like KeepTryRun for nodes
func (*Client) KeepTryDockerExecAll ¶
KeepTryDockerExecAll is like KeepTryRun for nodes, but can handle more than one command. Executes the given commands in order.
func (*Client) KeepTryRun ¶
KeepTryRun attempts to run a command successfully multiple times. It will keep trying until it reaches the max amount of tries or it is successful once.
type Node ¶ added in v1.7.1
type Node interface { GetAbsoluteNumber() int GetIP() string GetRelativeNumber() int GetServerID() int GetTestNetID() string GetNodeName() string }
Node represents the interface which all nodes must follow.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a simple wrapper for golang's ssh.Session, which decrements a semaphore on destruction.
func NewSession ¶
NewSession creates a new session from a native library ssh session and a semaphore