ftps

package
v0.0.0-...-fd1f34f Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: ISC Imports: 13 Imported by: 0

Documentation

Overview

Package ftp implements a FTP client as described in RFC 959.

Index

Constants

View Source
const (
	Retrieve = TransferDirction(1)
	Store    = TransferDirction(2)
)
View Source
const (
	StatusInitiating    = 100
	StatusRestartMarker = 110
	StatusReadyMinute   = 120
	StatusAlreadyOpen   = 125
	StatusAboutToSend   = 150

	StatusCommandOK             = 200
	StatusCommandNotImplemented = 202
	StatusSystem                = 211
	StatusDirectory             = 212
	StatusFile                  = 213
	StatusHelp                  = 214
	StatusName                  = 215
	StatusReady                 = 220
	StatusClosing               = 221
	StatusDataConnectionOpen    = 225
	StatusClosingDataConnection = 226
	StatusPassiveMode           = 227
	StatusLongPassiveMode       = 228
	StatusExtendedPassiveMode   = 229
	StatusLoggedIn              = 230
	StatusLoggedOut             = 231
	StatusLogoutAck             = 232
	StatusAuthTLS               = 234
	StatusRequestedFileActionOK = 250
	StatusPathCreated           = 257

	StatusUserOK             = 331
	StatusLoginNeedAccount   = 332
	StatusRequestFilePending = 350

	StatusNotAvailable             = 421
	StatusCanNotOpenDataConnection = 425
	StatusTransfertAborted         = 426
	StatusInvalidCredentials       = 430
	StatusHostUnavailable          = 434
	StatusFileActionIgnored        = 450
	StatusActionAborted            = 451
	Status452                      = 452

	StatusBadCommand              = 500
	StatusBadArguments            = 501
	StatusNotImplemented          = 502
	StatusBadSequence             = 503
	StatusNotImplementedParameter = 504
	StatusNotLoggedIn             = 530
	StatusStorNeedAccount         = 532
	StatusNeedTLS                 = 534
	StatusFileUnavailable         = 550
	StatusPageTypeUnknown         = 551
	StatusExceededStorage         = 552
	StatusBadFileName             = 553
)

FTP status codes, defined in RFC 959

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerConn

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

ServerConn represents the connection to a remote FTP server.

func Connect

func Connect(addr string, certfile string) (*ServerConn, error)

Connect is an alias to Dial, for backward compatibility

func Dial

func Dial(addr string, certfile string) (*ServerConn, error)

Dial is like DialTimeout with no timeout

func DialTimeout

func DialTimeout(addr string, timeout time.Duration, certfile string) (*ServerConn, error)

DialTimeout initializes the connection to the specified ftp server address.

It is generally followed by a call to Login() as most FTP commands require an authenticated user.

func (*ServerConn) AuthTLS

func (c *ServerConn) AuthTLS() error

Negotiates TLS for the connection

func (*ServerConn) ChangeDir

func (c *ServerConn) ChangeDir(path string) error

ChangeDir issues a CWD FTP command, which changes the current directory to the specified path.

func (*ServerConn) ChangeDirToParent

func (c *ServerConn) ChangeDirToParent() error

ChangeDirToParent issues a CDUP FTP command, which changes the current directory to the parent directory. This is similar to a call to ChangeDir with a path set to "..".

func (*ServerConn) CurrentDir

func (c *ServerConn) CurrentDir() (string, error)

CurrentDir issues a PWD FTP command, which Returns the path of the current directory.

func (*ServerConn) Delete

func (c *ServerConn) Delete(path string) error

Delete issues a DELE FTP command to delete the specified file from the remote FTP server.

func (*ServerConn) Exec

func (c *ServerConn) Exec(expected int, format string, args ...interface{}) (int, string, error)

Exec runs a command and check for expected code

func (*ServerConn) Feat

func (c *ServerConn) Feat() error

feat issues a FEAT FTP command to list the additional commands supported by the remote FTP server. FEAT is described in RFC 2389

func (*ServerConn) Features

func (c *ServerConn) Features() map[string]string

Features return allowed features from feat command response

func (*ServerConn) List

func (c *ServerConn) List(path string) (entries []*ftps_qftp_client.Entry, err error)

List issues a LIST FTP command.

func (*ServerConn) Login

func (c *ServerConn) Login(user, password string) error

Login authenticates the client with specified user and password.

"anonymous"/"anonymous" is a common user/password scheme for FTP servers that allows anonymous read-only accounts.

func (*ServerConn) Logout

func (c *ServerConn) Logout() error

Logout issues a REIN FTP command to logout the current user.

func (*ServerConn) MakeDir

func (c *ServerConn) MakeDir(path string) error

MakeDir issues a MKD FTP command to create the specified directory on the remote FTP server.

func (*ServerConn) MultipleTransfer

func (c *ServerConn) MultipleTransfer(tasks []TransferTask, nrParallel int) error

MultipleTransfer issues STOR FTP commands in parallel connections to store multiple files to the remote FTP server. Stor creates the specified files as specified in tasks. The number of parallel connections can be limited. nrParallel < 0 means no limit

Hint: io.Pipe() can be used if an io.Writer is required.

func (*ServerConn) NameList

func (c *ServerConn) NameList(path string) (entries []string, err error)

NameList issues an NLST FTP command.

func (*ServerConn) NoOp

func (c *ServerConn) NoOp() error

NoOp issues a NOOP FTP command. NOOP has no effects and is usually used to prevent the remote FTP server to close the otherwise idle connection.

func (*ServerConn) Quit

func (c *ServerConn) Quit() error

Quit issues a QUIT FTP command to properly close the connection from the remote FTP server.

func (*ServerConn) RemoveDir

func (c *ServerConn) RemoveDir(path string) error

RemoveDir issues a RMD FTP command to remove the specified directory from the remote FTP server.

func (*ServerConn) Rename

func (c *ServerConn) Rename(from, to string) error

Rename renames a file on the remote FTP server.

func (*ServerConn) Retr

func (c *ServerConn) Retr(path string) (io.ReadCloser, error)

Retr issues a RETR FTP command to fetch the specified file from the remote FTP server.

The returned ReadCloser must be closed to cleanup the FTP data connection.

func (*ServerConn) RetrFrom

func (c *ServerConn) RetrFrom(path string, offset uint64) (io.ReadCloser, error)

RetrFrom issues a RETR FTP command to fetch the specified file from the remote FTP server, the server will not send the offset first bytes of the file.

The returned ReadCloser must be closed to cleanup the FTP data connection.

func (*ServerConn) Stor

func (c *ServerConn) Stor(path string, r io.Reader) error

Stor issues a STOR FTP command to store a file to the remote FTP server. Stor creates the specified file with the content of the io.Reader.

Hint: io.Pipe() can be used if an io.Writer is required.

func (*ServerConn) StorFrom

func (c *ServerConn) StorFrom(path string, r io.Reader, offset uint64) error

StorFrom issues a STOR FTP command to store a file to the remote FTP server. Stor creates the specified file with the content of the io.Reader, writing on the server will start at the given file offset.

Hint: io.Pipe() can be used if an io.Writer is required.

type TransferDirction

type TransferDirction int8

type TransferTask

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

Task to inform a go routine which transfer should be performed

func NewTransferTask

func NewTransferTask(direction TransferDirction, localpath string, remotepath string) TransferTask

Creates a new TransferTask

Directories

Path Synopsis