ftp

package
v0.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package ftp implements the "ftp" protocol.Protocol driver. It speaks plain FTP and FTPS. The control connection is one command at a time, so a call takes one session from a pool and gives it back. Every transfer also opens a data connection.

The client library sets no deadline after the TCP connect. Each call sets a deadline on the control connection and on each data connection, and a watchdog closes those connections when the budget ends.

Uploads and deletes change files on the server. They need allow_writes, and a fixed path or a delete also needs allow_admin. An account that can only touch a scratch directory is the real lock.

Index

Constants

This section is empty.

Variables

View Source
var Options = []string{
	"mode", "path", "size", "fill", "expect_size", "expect_sha256", "expect",
	"limit", "hidden", "username", "password_env", "tls", "tls_verify",
	"sessions", "connection", "data_host", "epsv", "allow_writes", "allow_admin",
}

Options are the -opt keys this driver accepts.

Functions

This section is empty.

Types

type Driver

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

Driver is an FTP protocol.Protocol.

func New

func New(target protocol.Target, timeout time.Duration) (*Driver, error)

New builds a driver. It does not connect.

func NewConn

func NewConn(target protocol.Target, timeout time.Duration, password *string) (*Driver, error)

NewConn is New for a script. password is already known, so password_env is not read. The job of each call is set with Call.

func (*Driver) Call

func (d *Driver) Call(opts map[string]string, body []byte, timeout time.Duration) (*Driver, error)

Call returns a driver for one script call. It shares the pool. Close on it does nothing.

func (*Driver) Close

func (d *Driver) Close() error

Close quits idle sessions. A Call driver does nothing.

func (*Driver) Do

func (d *Driver) Do(ctx context.Context) (protocol.Result, error)

Do runs one iteration.

func (*Driver) Name

func (d *Driver) Name() string

Name is the protocol name.

func (*Driver) Run

func (d *Driver) Run(parent context.Context) (protocol.Result, Reply)

Run runs one call and returns the reply a script reads.

type Entry

type Entry struct {
	Name string
	Type string
	Size int64
	Time time.Time
}

Entry is one name from a listing.

type Reply

type Reply struct {
	Entries []Entry
	Size    int64
	Total   int
	Timing  Timing
	Text    string
}

Reply is what a call returns besides the byte counts.

type Timing

type Timing struct {
	ConnectMs  int64
	LoginMs    int64
	TransferMs int64
	UploadMs   int64
	DownloadMs int64
	DeleteMs   int64
}

Timing is how long the parts of a call took, in milliseconds.

Directories

Path Synopsis
Package ftptest is a small FTP server for tests.
Package ftptest is a small FTP server for tests.

Jump to

Keyboard shortcuts

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