ftp

package
v0.0.0-...-1dc401f Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package ftp implements an FTP server for rclone

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "ftp remote:path",
	Short: `Serve remote:path over FTP.`,
	Long: `Run a basic FTP server to serve a 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, e.g. --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,
	Annotations: map[string]string{
		"versionIntroduced": "v1.44",
		"groups":            "Filter",
	},
	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(context.Background(), 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 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) ModTime

func (f *FileInfo) ModTime() time.Time

ModTime returns the time in UTC

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
	TLSCert      string // TLS PEM key (concatenation of certificate and CA certificate)
	TLSKey       string // TLS PEM Private key
}

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