ftp

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 OptionsInfo = fs.Options{{
	Name:    "addr",
	Default: "localhost:2121",
	Help:    "IPaddress:Port or :Port to bind server to",
}, {
	Name:    "public_ip",
	Default: "",
	Help:    "Public IP address to advertise for passive connections",
}, {
	Name:    "passive_port",
	Default: "30000-32000",
	Help:    "Passive port range to use",
}, {
	Name:    "user",
	Default: "anonymous",
	Help:    "User name for authentication",
}, {
	Name:    "pass",
	Default: "",
	Help:    "Password for authentication (empty value allow every password)",
}, {
	Name:    "cert",
	Default: "",
	Help:    "TLS PEM key (concatenation of certificate and CA certificate)",
}, {
	Name:    "key",
	Default: "",
	Help:    "TLS PEM Private key",
}}

OptionsInfo descripts the Options in use

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 `config:"addr"`         // Port to listen on
	PublicIP     string `config:"public_ip"`    // Passive ports range
	PassivePorts string `config:"passive_port"` // Passive ports range
	BasicUser    string `config:"user"`         // single username for basic auth if not using Htpasswd
	BasicPass    string `config:"pass"`         // password for BasicUser
	TLSCert      string `config:"cert"`         // TLS PEM key (concatenation of certificate and CA certificate)
	TLSKey       string `config:"key"`          // TLS PEM Private key
}

Options contains options for the http Server

var Opt Options

Opt is options set by command line flags

Jump to

Keyboard shortcuts

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