client

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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
}

func New added in v0.1.2

func New(p Protocol, logger io.Writer) Client

SFTP has no control dialogue to capture, so its logger gets one line per request instead. A nil logger disables logging.

type FTPClient

type FTPClient struct {
	// contains filtered or unexported fields
}

func NewFTPClient

func NewFTPClient(logger io.Writer) *FTPClient

A nil logger disables logging.

func NewFTPSClient added in v0.1.2

func NewFTPSClient(logger io.Writer) *FTPClient

Explicit TLS only; implicit FTPS is not offered.

func (*FTPClient) Connect

func (c *FTPClient) Connect(host, user, pass string, port int) error

func (*FTPClient) Delete added in v0.3.0

func (c *FTPClient) Delete(target string, isDir bool) error

func (*FTPClient) Disconnect

func (c *FTPClient) Disconnect() error

func (*FTPClient) Download

func (c *FTPClient) Download(remotePath, localPath string, progress func(int64)) error

func (*FTPClient) List

func (c *FTPClient) List(path string) ([]model.FileInfo, error)

func (*FTPClient) Mkdir added in v0.1.1

func (c *FTPClient) Mkdir(path string) error

func (*FTPClient) Rename added in v0.3.0

func (c *FTPClient) Rename(oldPath, newPath string) error

func (*FTPClient) Upload

func (c *FTPClient) Upload(localPath, remotePath string, progress func(int64)) error

type HostKeyPrompt added in v0.4.0

type HostKeyPrompt func(host, keyType, fingerprint string) bool

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
const (
	FTP Protocol = iota
	FTPS
	SFTP
)

func ParseProtocol added in v0.4.0

func ParseProtocol(name string) Protocol

ParseProtocol is String's inverse; an unknown name is FTP, like an out-of-range Protocol.

func (Protocol) DefaultPort added in v0.1.2

func (p Protocol) DefaultPort() int

DefaultPort applies when the port field is left blank.

func (Protocol) Next added in v0.1.2

func (p Protocol) Next() Protocol

func (Protocol) Prev added in v0.1.2

func (p Protocol) Prev() Protocol

func (Protocol) String added in v0.1.2

func (p Protocol) String() string

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) Connect

func (c *SFTPClient) Connect(host, user, pass string, port int) error

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) List

func (c *SFTPClient) List(path string) ([]model.FileInfo, 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).

func (*SFTPClient) Upload

func (c *SFTPClient) Upload(localPath, remotePath string, progress func(int64)) error

Jump to

Keyboard shortcuts

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