ftp

package
v1.52.3-0...-16af9ab Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "ftp remote:path",
	Short: `Serve remote:path over FTP.`,
	Long: `
rclone serve ftp implements a basic ftp server to serve the
remote over FTP protocol. This can be viewed with a ftp client
or you can make a remote of type ftp to read and write it.

### Server options

Use --addr to specify which IP address and port the server should
listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all
IPs.  By default it only listens on localhost.  You can use port
:0 to let the OS choose an available port.

If you set --addr to listen on a public or LAN accessible IP address
then using Authentication is advised - see the next section for info.

#### Authentication

By default this will serve files without needing a login.

You can set a single username and password with the --user and --pass flags.
` + vfs.Help + proxy.Help,
	Run: func(command *cobra.Command, args []string) {
		var f fs.Fs
		if proxyflags.Opt.AuthProxy == "" {
			cmd.CheckArgs(1, 1, command, args)
			f = cmd.NewFsSrc(args)
		} else {
			cmd.CheckArgs(0, 0, command, args)
		}
		cmd.Run(false, false, command, func() error {
			s, err := newServer(f, &Opt)
			if err != nil {
				return err
			}
			return s.serve()
		})
	},
}

Command definition for cobra

View Source
var DefaultOpt = Options{
	ListenAddr:   "localhost:2121",
	PublicIP:     "",
	PassivePorts: "30000-32000",
	BasicUser:    "anonymous",
	BasicPass:    "",
}

DefaultOpt is the default values used for Options

Opt is options set by command line flags

Functions

func AddFlags

func AddFlags(flagSet *pflag.FlagSet)

AddFlags adds flags for ftp

Types

type Driver

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

Driver implementation of ftp server

func (*Driver) ChangeDir

func (d *Driver) ChangeDir(path string) (err error)

ChangeDir move current folder

func (*Driver) DeleteDir

func (d *Driver) DeleteDir(path string) (err error)

DeleteDir delete a folder and his content

func (*Driver) DeleteFile

func (d *Driver) DeleteFile(path string) (err error)

DeleteFile delete a file

func (*Driver) GetFile

func (d *Driver) GetFile(path string, offset int64) (size int64, fr io.ReadCloser, err error)

GetFile download a file

func (*Driver) Init

func (d *Driver) Init(c *ftp.Conn)

Init a connection

func (*Driver) ListDir

func (d *Driver) ListDir(path string, callback func(ftp.FileInfo) error) (err error)

ListDir list content of a folder

func (*Driver) MakeDir

func (d *Driver) MakeDir(path string) (err error)

MakeDir create a folder

func (*Driver) PutFile

func (d *Driver) PutFile(path string, data io.Reader, appendData bool) (n int64, err error)

PutFile upload a file

func (*Driver) Rename

func (d *Driver) Rename(oldName, newName string) (err error)

Rename rename a file or folder

func (*Driver) Stat

func (d *Driver) Stat(path string) (fi ftp.FileInfo, err error)

Stat get information on file or folder

type FileInfo

type FileInfo struct {
	os.FileInfo
	// contains filtered or unexported fields
}

FileInfo struct to hold file info for ftp server

func (*FileInfo) Group

func (f *FileInfo) Group() string

Group return group of file. Try to find the group name if possible

func (*FileInfo) Mode

func (f *FileInfo) Mode() os.FileMode

Mode return mode of file.

func (*FileInfo) Owner

func (f *FileInfo) Owner() string

Owner return owner of file. Try to find the username if possible

type Logger

type Logger struct{}

Logger ftp logger output formatted message

func (*Logger) Print

func (l *Logger) Print(sessionID string, message interface{})

Print log simple text message

func (*Logger) PrintCommand

func (l *Logger) PrintCommand(sessionID string, command string, params string)

PrintCommand log formatted command execution

func (*Logger) PrintResponse

func (l *Logger) PrintResponse(sessionID string, code int, message string)

PrintResponse log responses

func (*Logger) Printf

func (l *Logger) Printf(sessionID string, format string, v ...interface{})

Printf log formatted text message

type Options

type Options struct {
	//TODO add more options
	ListenAddr   string // Port to listen on
	PublicIP     string // Passive ports range
	PassivePorts string // Passive ports range
	BasicUser    string // single username for basic auth if not using Htpasswd
	BasicPass    string // password for BasicUser
}

Options contains options for the http Server

Jump to

Keyboard shortcuts

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