Versions in this module Expand all Collapse all v2 v2.0.2 Dec 15, 2023 Changes in this version + var ErrServerClosed = errors.New("ftp: Server closed") + func DefaultCommands() map[string]Command + type Auth interface + CheckPasswd func(*Context, string, string) (bool, error) + type Command interface + Execute func(*Session, string) + IsExtend func() bool + RequireAuth func() bool + RequireParam func() bool + type Context struct + Cmd string + Data map[string]interface{} + Param string + Sess *Session + type DataSocket interface + Close func() error + Host func() string + Port func() int + Read func(p []byte) (n int, err error) + ReadFrom func(r io.Reader) (int64, error) + Write func(p []byte) (n int, err error) + type DiscardLogger struct + func (logger *DiscardLogger) Print(sessionID string, message interface{}) + func (logger *DiscardLogger) PrintCommand(sessionID string, command string, params string) + func (logger *DiscardLogger) PrintResponse(sessionID string, code int, message string) + func (logger *DiscardLogger) Printf(sessionID string, format string, v ...interface{}) + type Driver interface + DeleteDir func(*Context, string) error + DeleteFile func(*Context, string) error + GetFile func(*Context, string, int64) (int64, io.ReadCloser, error) + ListDir func(*Context, string, func(os.FileInfo) error) error + MakeDir func(*Context, string) error + PutFile func(*Context, string, io.Reader, int64) (int64, error) + Rename func(*Context, string, string) error + Stat func(*Context, string) (os.FileInfo, error) + func NewMultiDriver(drivers map[string]Driver) Driver + type FileInfo interface + Group func() string + Owner func() string + type Logger interface + Print func(sessionID string, message interface{}) + PrintCommand func(sessionID string, command string, params string) + PrintResponse func(sessionID string, code int, message string) + Printf func(sessionID string, format string, v ...interface{}) + type MultiDriver struct + func (driver *MultiDriver) DeleteDir(ctx *Context, path string) error + func (driver *MultiDriver) DeleteFile(ctx *Context, path string) error + func (driver *MultiDriver) GetFile(ctx *Context, path string, offset int64) (int64, io.ReadCloser, error) + func (driver *MultiDriver) ListDir(ctx *Context, path string, callback func(os.FileInfo) error) error + func (driver *MultiDriver) MakeDir(ctx *Context, path string) error + func (driver *MultiDriver) PutFile(ctx *Context, destPath string, data io.Reader, offset int64) (int64, error) + func (driver *MultiDriver) Rename(ctx *Context, fromPath string, toPath string) error + func (driver *MultiDriver) Stat(ctx *Context, path string) (os.FileInfo, error) + type Notifier interface + AfterCurDirChanged func(ctx *Context, oldCurDir, newCurDir string, err error) + AfterDirCreated func(ctx *Context, dstPath string, err error) + AfterDirDeleted func(ctx *Context, dstPath string, err error) + AfterFileDeleted func(ctx *Context, dstPath string, err error) + AfterFileDownloaded func(ctx *Context, dstPath string, size int64, err error) + AfterFilePut func(ctx *Context, dstPath string, size int64, err error) + AfterUserLogin func(ctx *Context, userName, password string, passMatched bool, err error) + BeforeChangeCurDir func(ctx *Context, oldCurDir, newCurDir string) + BeforeCreateDir func(ctx *Context, dstPath string) + BeforeDeleteDir func(ctx *Context, dstPath string) + BeforeDeleteFile func(ctx *Context, dstPath string) + BeforeDownloadFile func(ctx *Context, dstPath string) + BeforeLoginUser func(ctx *Context, userName string) + BeforePutFile func(ctx *Context, dstPath string) + type NullNotifier struct + func (NullNotifier) AfterCurDirChanged(ctx *Context, oldCurDir, newCurDir string, err error) + func (NullNotifier) AfterDirCreated(ctx *Context, dstPath string, err error) + func (NullNotifier) AfterDirDeleted(ctx *Context, dstPath string, err error) + func (NullNotifier) AfterFileDeleted(ctx *Context, dstPath string, err error) + func (NullNotifier) AfterFileDownloaded(ctx *Context, dstPath string, size int64, err error) + func (NullNotifier) AfterFilePut(ctx *Context, dstPath string, size int64, err error) + func (NullNotifier) AfterUserLogin(ctx *Context, userName, password string, passMatched bool, err error) + func (NullNotifier) BeforeChangeCurDir(ctx *Context, oldCurDir, newCurDir string) + func (NullNotifier) BeforeCreateDir(ctx *Context, dstPath string) + func (NullNotifier) BeforeDeleteDir(ctx *Context, dstPath string) + func (NullNotifier) BeforeDeleteFile(ctx *Context, dstPath string) + func (NullNotifier) BeforeDownloadFile(ctx *Context, dstPath string) + func (NullNotifier) BeforeLoginUser(ctx *Context, userName string) + func (NullNotifier) BeforePutFile(ctx *Context, dstPath string) + type Options struct + Auth Auth + CertFile string + Commands map[string]Command + Driver Driver + ExplicitFTPS bool + ForceTLS bool + Hostname string + KeyFile string + Logger Logger + Name string + PassivePorts string + Perm Perm + Port int + PublicIP string + RateLimit int64 + TLS bool + WelcomeMessage string + type Perm interface + ChGroup func(string, string) error + ChMode func(string, os.FileMode) error + ChOwner func(string, string) error + GetGroup func(string) (string, error) + GetMode func(string) (os.FileMode, error) + GetOwner func(string) (string, error) + type Server struct + func NewServer(opts *Options) (*Server, error) + func (server *Server) ListenAndServe() error + func (server *Server) RegisterNotifer(notifier Notifier) + func (server *Server) Serve(l net.Listener) error + func (server *Server) Shutdown() error + type Session struct + Data map[string]interface{} + func (sess *Session) BuildPath(filename string) string + func (sess *Session) Close() + func (sess *Session) DataConn() DataSocket + func (sess *Session) IsLogin() bool + func (sess *Session) LoginUser() string + func (sess *Session) Options() *Options + func (sess *Session) PassivePort() int + func (sess *Session) PublicIP() string + func (sess *Session) RemoteAddr() net.Addr + func (sess *Session) Serve() + func (sess *Session) Server() *Server + func (sess *Session) WriteMessage(code int, message string) + type SimpleAuth struct + Name string + Password string + func (a *SimpleAuth) CheckPasswd(ctx *Context, name, pass string) (bool, error) + type SimplePerm struct + func NewSimplePerm(owner, group string) *SimplePerm + func (s *SimplePerm) ChGroup(string, string) error + func (s *SimplePerm) ChMode(string, os.FileMode) error + func (s *SimplePerm) ChOwner(string, string) error + func (s *SimplePerm) GetGroup(string) (string, error) + func (s *SimplePerm) GetMode(string) (os.FileMode, error) + func (s *SimplePerm) GetOwner(string) (string, error) + type StdLogger struct + func (logger *StdLogger) Print(sessionID string, message interface{}) + func (logger *StdLogger) PrintCommand(sessionID string, command string, params string) + func (logger *StdLogger) PrintResponse(sessionID string, code int, message string) + func (logger *StdLogger) Printf(sessionID string, format string, v ...interface{})