ftp

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDirectory           = errors.New("Not a directory")
	ErrNotFile                = errors.New("Not a file")
	ErrDirectoryAlreadyExists = errors.New("A dir has the same name")
	ErrPutFile                = errors.New("Put File error")
)
View Source
var (
	DefaultConfig = &Config{
		PidFile:   `ftp.pid`,
		StoreType: `file`,

		Name:           `TinyFTP`,
		PassivePorts:   `6001-7000`,
		Port:           25,
		PublicIP:       `127.0.0.1`,
		WelcomeMessage: `Welcome to the TinyFTP`,
	}
	DefaultPidFile = `ftp.pid`
)

Functions

func SetDefaults

func SetDefaults(c *Config)

Types

type Auth

type Auth struct {
}

func NewAuth

func NewAuth() *Auth

func (*Auth) CheckPasswd

func (a *Auth) CheckPasswd(ftpCtx *ftpserver.Context, username string, password string) (bool, error)

type Config

type Config struct {
	PidFile   string `json:"-"`
	StoreType string `json:"storeType"`

	// Server Name, Default is Go Ftp Server
	Name string `json:"name"`

	// The hostname that the FTP server should listen on. Optional, defaults to
	// "::", which means all hostnames on ipv4 and ipv6.
	Hostname string `json:"hostName"`

	// Public IP of the server
	PublicIP string `json:"publicIP"`

	// Passive ports
	PassivePorts string `json:"passivePorts"`

	// The port that the FTP should listen on. Optional, defaults to 3000. In
	// a production environment you will probably want to change this to 21.
	Port int `json:"port"`

	// use tls, default is false
	TLS bool `json:"tls"`

	// if tls used, cert file is required
	CertFile string `json:"certFile"`

	// if tls used, key file is required
	KeyFile string `json:"keyFile"`

	// If ture TLS is used in RFC4217 mode
	ExplicitFTPS bool `json:"explicitFTPS"`

	// If true, client must upgrade to TLS before sending any other command
	ForceTLS bool `json:"forceTLS"`

	WelcomeMessage string `json:"welcomeMessage"`

	// Rate Limit per connection bytes per second, 0 means no limit
	RateLimit int64 `json:"rateLimit"`
	// contains filtered or unexported fields
}

func (*Config) Init

func (c *Config) Init() *Config

func (*Config) SetAuth

func (c *Config) SetAuth(auth ftpserver.Auth) *Config

func (*Config) SetDriver

func (c *Config) SetDriver(driver ftpserver.Driver) *Config

func (*Config) SetPerm

func (c *Config) SetPerm(perm ftpserver.Perm, owner string, group string) *Config

func (*Config) SetPort

func (c *Config) SetPort(port int) *Config

func (*Config) SetStoreByType

func (c *Config) SetStoreByType(storeType string) *Config

func (*Config) Start

func (c *Config) Start() error

Start start ftp server

func (*Config) Stop added in v1.3.1

func (c *Config) Stop() error

type FileDriver

type FileDriver struct {
	ftpserver.Perm
}

func (*FileDriver) ChangeDir

func (f *FileDriver) ChangeDir(ftpCtx *ftpserver.Context, path string) error

func (*FileDriver) DeleteDir

func (f *FileDriver) DeleteDir(ftpCtx *ftpserver.Context, path string) error

func (*FileDriver) DeleteFile

func (f *FileDriver) DeleteFile(ftpCtx *ftpserver.Context, path string) error

func (*FileDriver) GetFile

func (f *FileDriver) GetFile(ftpCtx *ftpserver.Context, path string, offset int64) (int64, io.ReadCloser, error)

func (*FileDriver) ListDir

func (f *FileDriver) ListDir(ftpCtx *ftpserver.Context, path string, callback func(os.FileInfo) error) error

func (*FileDriver) MakeDir

func (f *FileDriver) MakeDir(ftpCtx *ftpserver.Context, path string) error

func (*FileDriver) PutFile

func (f *FileDriver) PutFile(ftpCtx *ftpserver.Context, destPath string, data io.Reader, offset int64) (int64, error)

func (*FileDriver) Rename

func (f *FileDriver) Rename(ftpCtx *ftpserver.Context, fromPath string, toPath string) error

func (*FileDriver) Stat

func (f *FileDriver) Stat(ftpCtx *ftpserver.Context, path string) (os.FileInfo, error)

type Operate added in v1.3.1

type Operate int
const (
	OperateRead   Operate = 0 // 读
	OperateModify Operate = 1 // 修改
	OperateCreate Operate = 2 // 新建
)

操作类型

type PathType added in v1.3.1

type PathType int
const (
	PathTypeDir  PathType = 0 // 文件夹
	PathTypeFile PathType = 1 // 文件
	PathTypeBoth PathType = 2 // 不限
)

路径类型

type Perm

type Perm struct {
	*ftpserver.SimplePerm
}

func NewPerm

func NewPerm(owner, group string) *Perm

Jump to

Keyboard shortcuts

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