ftpconnection

package
v0.0.0-...-2b5ea0c Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialContext

func DialContext(ctx context.Context, address string, options ...Option) (connection.Connection, error)

func DialContextExplicitTLS

func DialContextExplicitTLS(ctx context.Context, address string, tlsConfig *tls.Config, options ...Option) (connection.Connection, error)

func DialContextTLS

func DialContextTLS(ctx context.Context, address string, tlsConfig *tls.Config, options ...Option) (connection.Connection, error)

func NewConnection

func NewConnection(
	host string,
	dialer Dialer,
	conn net.Conn,
	textConn TextConnection,
	options ...Option,
) (connection.Connection, error)

Types

type Conn

type Conn interface {
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

type Dialer

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
	DialContextTLS(ctx context.Context, network, address string, tlsConfig *tls.Config) (net.Conn, error)
}

type Option

type Option func(conn *ServerConnection) error

func WithDisabledEPSV

func WithDisabledEPSV() Option

func WithDisabledUTF8

func WithDisabledUTF8() Option

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

func WithVerboseWriter

func WithVerboseWriter(writer io.Writer) Option

type ServerConnection

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

func (*ServerConnection) Cd

func (c *ServerConnection) Cd(path string) error

func (*ServerConnection) Download

func (c *ServerConnection) Download(ctx context.Context, path string) ([]byte, error)

func (*ServerConnection) EnableExplicitTLSMode

func (c *ServerConnection) EnableExplicitTLSMode() (err error)

EnableExplicitTLSMode function enables TLS modes on established TCP connection.

func (*ServerConnection) IsDir

func (c *ServerConnection) IsDir(ctx context.Context, path string) (bool, error)

func (*ServerConnection) List

func (c *ServerConnection) List(ctx context.Context, options *connection.ListOptions) (entries []*entities.Entry, err error)

func (*ServerConnection) Login

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

Login function authenticate user with provided account username and password. Upon successful authentication, server is then queried to list supported features to update connection settings at runtime.

func (*ServerConnection) Mkdir

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

func (*ServerConnection) Move

func (c *ServerConnection) Move(oldPath string, newPath string) error

func (*ServerConnection) Ready

func (c *ServerConnection) Ready() (err error)

Ready function validates that the FTP server is ready to proceed.

func (*ServerConnection) RemoveDir

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

func (*ServerConnection) RemoveFile

func (c *ServerConnection) RemoveFile(path string) error

func (*ServerConnection) Size

func (c *ServerConnection) Size(path string) (uint64, error)

func (*ServerConnection) Status

func (c *ServerConnection) Status() (*entities.Status, error)

func (*ServerConnection) Stop

func (c *ServerConnection) Stop() (err error)

Stop function sends a quit command to FTP server and closes the TCP connection.

func (*ServerConnection) Upload

func (c *ServerConnection) Upload(ctx context.Context, options *connection.UploadOptions) error

type TextConnection

type TextConnection interface {
	ReadResponse(expectedCode int) (int, string, error)
	Cmd(format string, args ...any) (uint, error)
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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