ftp

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: BSD-1-Clause Imports: 8 Imported by: 0

Documentation

Overview

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

A textproto.Error is returned for errors at the protocol level. This is a stripped down version of github.com/jlaffaye/ftp@v0.0.0-20191218041957-e1b8fdd0dcc3

Index

Constants

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
	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
	StatusFileUnavailable         = 550
	StatusPageTypeUnknown         = 551
	StatusExceededStorage         = 552
	StatusBadFileName             = 553
)

FTP status codes, defined in RFC 959

Variables

This section is empty.

Functions

func StatusText

func StatusText(code int) string

StatusText returns a text for the FTP status code. It returns the empty string if the code is unknown.

Types

type DialOption

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

DialOption represents an option to start a new connection with Dial

func DialWithDisabledEPSV

func DialWithDisabledEPSV(disabled bool) DialOption

DialWithDisabledEPSV returns a DialOption that configures the ServerConn with EPSV disabled Note that EPSV is only used when advertised in the server features.

func DialWithTimeout

func DialWithTimeout(timeout time.Duration) DialOption

DialWithTimeout returns a DialOption that configures the ServerConn with specified timeout

type EntryType

type EntryType int

EntryType describes the different types of an Entry.

const (
	EntryTypeFile EntryType = iota
	EntryTypeFolder
	EntryTypeLink
)

The differents types of an Entry

type Response

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

Response represents a data-connection

func (*Response) Close

func (r *Response) Close() error

Close implements the io.Closer interface on a FTP data connection. After the first call, Close will do nothing and return nil.

func (*Response) Read

func (r *Response) Read(buf []byte) (int, error)

Read implements the io.Reader interface on a FTP data connection.

func (*Response) SetDeadline

func (r *Response) SetDeadline(t time.Time) error

SetDeadline sets the deadlines associated with the connection.

type ServerConn

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

ServerConn represents the connection to a remote FTP server. A single connection only supports one in-flight data connection. It is not safe to be called concurrently.

func Dial

func Dial(addr string, options ...DialOption) (*ServerConn, error)

Dial connects to the specified address with optional options

func DialTimeout

func DialTimeout(addr string, timeout time.Duration) (*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) 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) Quit

func (c *ServerConn) Quit() error

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

func (*ServerConn) Retr

func (c *ServerConn) Retr(path string) (*Response, 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) (*Response, 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.

Jump to

Keyboard shortcuts

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