ftp

package module
v0.0.0-...-30d3aa8 Latest Latest
Warning

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

Go to latest
Published: May 19, 2013 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package ftp provides a minimal FTP client as defined in RFC 959.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Welcome Reply
	// contains filtered or unexported fields
}

A Client is an FTP client. A single FTP connection cannot handle simultaneous transfers.

func Dial

func Dial(network, addr string) (*Client, error)

Dial connects to an FTP server.

func NewClient

func NewClient(c net.Conn) (*Client, error)

NewClient creates an FTP client from an existing connection.

func (*Client) Binary

func (client *Client) Binary(command string) (io.ReadWriteCloser, error)

Binary sends a command and opens a new passive data connection in image mode.

func (*Client) Close

func (client *Client) Close() error

Close closes the connection.

func (*Client) Do

func (client *Client) Do(command string) (Reply, error)

Do sends a command over the control connection and waits for the response. It returns any protocol error encountered while performing the command.

func (*Client) Login

func (client *Client) Login(username, password string) error

Login sends credentials to the server.

func (*Client) Quit

func (client *Client) Quit() error

Quit sends the QUIT command and closes the connection.

func (*Client) Text

func (client *Client) Text(command string) (io.ReadWriteCloser, error)

Text sends a command and opens a new passive data connection in ASCII mode.

type Code

type Code int

Code is an FTP reply code.

const (
	CodeRestartMarker    Code = 110
	CodeServiceReadySoon Code = 120
	CodeStartingTransfer Code = 125
	CodeFileStatusOkay   Code = 150

	CodeOkay            Code = 200
	CodeSuperfluous     Code = 202
	CodeSystemStatus    Code = 211
	CodeDirectoryStatus Code = 212
	CodeFileStatus      Code = 213
	CodeHelpMessage     Code = 214
	CodeSystemType      Code = 215
	CodeServiceReady    Code = 220
	CodeServiceClosing  Code = 221
	CodeNoTransfer      Code = 225
	CodeClosingData     Code = 226
	CodePassive         Code = 227
	CodeExtendedPassive Code = 229
	CodeLoggedIn        Code = 230
	CodeActionOkay      Code = 250
	CodeCreated         Code = 257

	CodeNeedPassword       Code = 331
	CodeNeedAccount        Code = 332
	CodePendingInformation Code = 350

	CodeServiceNotAvailable Code = 421
	CodeCantOpenData        Code = 425
	CodeTransferAborted     Code = 426
	CodeActionNotTaken      Code = 450
	CodeLocalError          Code = 451
	CodeInsufficientStorage Code = 452

	CodeUnrecognizedCommand     Code = 500
	CodeParameterSyntaxError    Code = 501
	CodeNotImplemented          Code = 502
	CodeBadSequence             Code = 503
	CodeParameterNotImplemented Code = 504
	CodeNotLoggedIn             Code = 530
	CodeNoAccount               Code = 532
	CodeFileUnavailable         Code = 550
	CodePageTypeUnknown         Code = 551
	CodeExceededQuota           Code = 552
	CodeFileNameNotAllowed      Code = 553
)

FTP reply codes defined in RFC 959.

func (Code) Complete

func (code Code) Complete() bool

Complete returns whether this code indicates a complete reply. A complete reply code is not necessarily positive.

func (Code) Positive

func (code Code) Positive() bool

Positive returns whether the code is positive.

func (Code) PositiveComplete

func (code Code) PositiveComplete() bool

PositiveComplete returns whether this code is a positive completion.

func (Code) Preliminary

func (code Code) Preliminary() bool

Preliminary returns whether the code indicates a preliminary positive reply.

func (Code) String

func (code Code) String() string

func (Code) Temporary

func (code Code) Temporary() bool

Temporary returns whether this code indicates a temporary error.

type Reply

type Reply struct {
	Code
	Msg string
}

Reply is a response from a server. This may also be used as an error.

func (Reply) Error

func (r Reply) Error() string

func (Reply) String

func (r Reply) String() string

Jump to

Keyboard shortcuts

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