Documentation ¶
Index ¶
- type Client
- func (a *Client) Close() error
- func (a *Client) Connect(addr string, clientConfig *ssh.ClientConfig) (err error)
- func (a *Client) Copy(r io.Reader, remotePath, permissions string, size int64) error
- func (a *Client) CopyFile(fileReader io.Reader, remotePath string, permissions string) error
- func (a *Client) CopyFromFile(file os.File, remotePath string, permissions string) error
- type ClientConf
- type Response
- type ResponseType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // the client config to use ClientConfig *ssh.ClientConfig // stores the SSH session while the connection is running Session *ssh.Session // stores the SSH connection itself in order to close it after transfer Conn ssh.Conn // the clients waits for the given timeout until given up the connection Timeout time.Duration // the absolute path to the remote SCP binary RemoteBinary string }
Client represents a client of scp session.
func (*Client) Connect ¶
func (a *Client) Connect(addr string, clientConfig *ssh.ClientConfig) (err error)
Connect connects to the remote SSH server, returns error if it couldn't establish a session to the SSH server
type ClientConf ¶
ClientConf is a struct containing all the configuration options used by an scp client.
func NewConf ¶
func NewConf() *ClientConf
NewConf creates a new client configurer. It takes the required parameters: the addr and the ssh.ClientConfig and returns a configurer populated with the default values for the optional parameters.
These optional parameters can be set by using the methods provided on the ClientConf struct.
func (*ClientConf) CreateClient ¶
func (c *ClientConf) CreateClient() *Client
CreateClient builds a client with the configuration stored within the ClientConf
type Response ¶
type Response struct { Type ResponseType Message string }
Response has tree types of responses that the remote can send back: ok, warning and error
The difference between warning and error is that the connection is not closed by the remote, however, a warning can indicate a file transfer failure (such as invalid destination directory) and such be handled as such.
All responses except for the `OK` type always have a message (although these can be empty)
The remote sends a confirmation after every SCP command, because a failure can occur after every command, the response should be read and checked after sending them.
func ParseResponse ¶
ParseResponse reads from the given reader (assuming it is the output of the remote) and parses it into a Response structure
func (*Response) GetMessage ¶
GetMessage returns the detailed message.
type ResponseType ¶
type ResponseType = uint8
ResponseType represents the type of the response.
const ( // OK represents everything is OK OK ResponseType = iota + 1 // Warning represents there is warning. Warning // Error means there is error. Error )