Documentation
¶
Index ¶
- type Client
- type FTPClient
- func (c *FTPClient) Connect(host, user, pass string, port int) error
- func (c *FTPClient) Delete(target string, isDir bool) error
- func (c *FTPClient) Disconnect() error
- func (c *FTPClient) Download(remotePath, localPath string, progress func(int64)) error
- func (c *FTPClient) List(path string) ([]model.FileInfo, error)
- func (c *FTPClient) Mkdir(path string) error
- func (c *FTPClient) Rename(oldPath, newPath string) error
- func (c *FTPClient) Upload(localPath, remotePath string, progress func(int64)) error
- type HostKeyPrompt
- type Protocol
- type SFTPClient
- func (c *SFTPClient) AuthMethod() string
- func (c *SFTPClient) Connect(host, user, pass string, port int) error
- func (c *SFTPClient) Delete(path string, isDir bool) error
- func (c *SFTPClient) Disconnect() error
- func (c *SFTPClient) Download(remotePath, localPath string, progress func(int64)) error
- func (c *SFTPClient) List(path string) ([]model.FileInfo, error)
- func (c *SFTPClient) Mkdir(path string) error
- func (c *SFTPClient) Rename(oldPath, newPath string) error
- func (c *SFTPClient) SetHostKeyPrompt(p HostKeyPrompt)
- func (c *SFTPClient) SetIdentityFile(path string)
- func (c *SFTPClient) SetSessionNotifier(f func(error))
- func (c *SFTPClient) Upload(localPath, remotePath string, progress func(int64)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Connect(host, user, pass string, port int) error
Disconnect() error
List(path string) ([]model.FileInfo, error)
Upload(localPath, remotePath string, progress func(int64)) error
Download(remotePath, localPath string, progress func(int64)) error
Mkdir(path string) error
Rename(oldPath, newPath string) error
Delete(path string, isDir bool) error
}
type FTPClient ¶
type FTPClient struct {
// contains filtered or unexported fields
}
func NewFTPSClient ¶ added in v0.1.2
Explicit TLS only; implicit FTPS is not offered.
func (*FTPClient) Disconnect ¶
type HostKeyPrompt ¶ added in v0.4.0
HostKeyPrompt asks whether to trust a host seen for the first time. It blocks until the user answers.
type Protocol ¶ added in v0.1.2
type Protocol int
func ParseProtocol ¶ added in v0.4.0
ParseProtocol is String's inverse; an unknown name is FTP, like an out-of-range Protocol.
func (Protocol) DefaultPort ¶ added in v0.1.2
DefaultPort applies when the port field is left blank.
type SFTPClient ¶
type SFTPClient struct {
// contains filtered or unexported fields
}
SFTPClient holds one ssh connection and one sftp session, unlike FTP's pool that replaces broken connections by itself. When the session dies it opens a new one from the same host, user and credentials, so a drop costs a retry and not a retyped password. Remote paths are absolute, so the caller's current directory survives the swap untouched.
func NewSFTPClient ¶
func NewSFTPClient(logger io.Writer) *SFTPClient
A nil logger disables logging.
func (*SFTPClient) AuthMethod ¶ added in v0.4.0
func (c *SFTPClient) AuthMethod() string
AuthMethod names how the last successful Connect authenticated.
func (*SFTPClient) Delete ¶ added in v0.3.0
func (c *SFTPClient) Delete(path string, isDir bool) error
func (*SFTPClient) Disconnect ¶
func (c *SFTPClient) Disconnect() error
func (*SFTPClient) Download ¶
func (c *SFTPClient) Download(remotePath, localPath string, progress func(int64)) error
func (*SFTPClient) Mkdir ¶ added in v0.1.1
func (c *SFTPClient) Mkdir(path string) error
func (*SFTPClient) Rename ¶ added in v0.3.0
func (c *SFTPClient) Rename(oldPath, newPath string) error
func (*SFTPClient) SetHostKeyPrompt ¶ added in v0.4.0
func (c *SFTPClient) SetHostKeyPrompt(p HostKeyPrompt)
func (*SFTPClient) SetIdentityFile ¶ added in v0.4.0
func (c *SFTPClient) SetIdentityFile(path string)
SetIdentityFile names a private key to try before the agent and the defaults.
func (*SFTPClient) SetSessionNotifier ¶ added in v0.4.0
func (c *SFTPClient) SetSessionNotifier(f func(error))
SetSessionNotifier is told, from another goroutine, every time a lost session was reopened (nil) or could not be (the error).