ftps

package module
v0.0.0-...-8aff86a Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: ISC Imports: 13 Imported by: 0

README

FTPS Implementation for Go

Information

This implementation does not implement the full FTP/FTPS specification. Only a small subset.

I have not done a security review of the code, yet. Therefore no guarantee is given. It would be nice if somebody could do a security review and report back if the implementation is vulnerable.

Installation

go get github.com/shoobyban/ftps

Usage

	ftps := new(FTPS)

	ftps.TLSConfig.InsecureSkipVerify = true // often necessary in shared hosting environments
	ftps.Debug = true
	ftps.Timeout = time.Second * 1

	err := ftps.Connect("localhost", 21)
	if err != nil {
		panic(err)
	}

	err = ftps.Login("username", "password")
	if err != nil {
		panic(err)
	}

	directory, err := ftps.PrintWorkingDirectory()
	if err != nil {
		panic(err)
	}
	log.Printf("Current working directory: %s", directory)

	err = ftps.Quit()
	if err != nil {
		panic(err)
	}

Credits

This is a fork of (https://github.com/sacloud/ftps), that is originally fork of (https://github.com/marcobeierer/ftps), that was inspired by the work of jlaffaye (https://github.com/jlaffaye/ftp) and smallfish (https://github.com/smallfish/ftp).

Update

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	UserName string
	Password string
	Host     string
}

Client FTPS Client

func NewClient

func NewClient(user string, pass string, host string) *Client

NewClient return new FTPS Client

func (*Client) Download

func (c *Client) Download(filePath string) error

Download file from server

func (*Client) DownloadFile

func (c *Client) DownloadFile(file *os.File) error

DownloadFile file from server

func (*Client) Upload

func (c *Client) Upload(filePath string) error

Upload file to Server

func (*Client) UploadFile

func (c *Client) UploadFile(remoteFilepath string, file *os.File) error

UploadFile file to Server

type Entry

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

type EntryType

type EntryType int
const (
	EntryTypeFile EntryType = iota
	EntryTypeFolder
	EntryTypeLink
)

type FTPS

type FTPS struct {
	Debug     bool
	Timeout   time.Duration
	TLSConfig tls.Config
	// contains filtered or unexported fields
}

func (*FTPS) ChangeWorkingDirectory

func (ftps *FTPS) ChangeWorkingDirectory(path string) (err error)

func (*FTPS) Connect

func (ftps *FTPS) Connect(host string, port int) (err error)

func (*FTPS) DeleteFile

func (ftps *FTPS) DeleteFile(path string) (err error)

func (*FTPS) List

func (ftps *FTPS) List() (entries []Entry, err error)

func (*FTPS) Login

func (ftps *FTPS) Login(username, password string) (err error)

func (*FTPS) MakeDirectory

func (ftps *FTPS) MakeDirectory(path string) (err error)

func (*FTPS) PrintWorkingDirectory

func (ftps *FTPS) PrintWorkingDirectory() (directory string, err error)

func (*FTPS) Quit

func (ftps *FTPS) Quit() (err error)

func (*FTPS) RemoveDirectory

func (ftps *FTPS) RemoveDirectory(path string) (err error)

func (*FTPS) Rename

func (ftps *FTPS) Rename(from, to string) error

Rename renames a file on the remote FTPS server.

func (*FTPS) RetrieveFile

func (ftps *FTPS) RetrieveFile(remoteFilepath string, file *os.File) (err error)

func (*FTPS) StoreData

func (ftps *FTPS) StoreData(remoteFilepath string, data []byte) (err error)

func (*FTPS) StoreFile

func (ftps *FTPS) StoreFile(remoteFilepath string, f *os.File) (err error)

Jump to

Keyboard shortcuts

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