Documentation ¶
Overview ¶
Package sample is a sample server driver
Index ¶
- type Account
- type ClientDriver
- func (driver *ClientDriver) AsyncListFiles(cc server.ClientContext, cfiles chan<- os.FileInfo)
- func (driver *ClientDriver) CanAllocate(cc server.ClientContext, size int) (bool, error)
- func (driver *ClientDriver) ChangeDirectory(cc server.ClientContext, directory string) error
- func (driver *ClientDriver) ChmodFile(cc server.ClientContext, path string, mode os.FileMode) error
- func (driver *ClientDriver) DeleteFile(cc server.ClientContext, path string) error
- func (driver *ClientDriver) GetFileInfo(cc server.ClientContext, path string) (os.FileInfo, error)
- func (driver *ClientDriver) ListFiles(cc server.ClientContext) ([]os.FileInfo, error)
- func (driver *ClientDriver) MakeDirectory(cc server.ClientContext, directory string) error
- func (driver *ClientDriver) OpenFile(cc server.ClientContext, path string, flag int) (server.FileStream, error)
- func (driver *ClientDriver) RenameFile(cc server.ClientContext, from, to string) error
- type FilesDriver
- func (driver *FilesDriver) AuthUser(cc server.ClientContext, user, pass string) (server.ClientHandlingDriver, error)
- func (driver *FilesDriver) GetSettings() (*server.Settings, error)
- func (driver *FilesDriver) GetTLSConfig() (*tls.Config, error)
- func (driver *FilesDriver) UserLeft(cc server.ClientContext)
- func (driver *FilesDriver) WelcomeUser(cc server.ClientContext) (string, error)
- type OurSettings
- type VirtualFile
- type VirtualFileInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientDriver ¶
type ClientDriver struct {
BaseDir string // Base directory from which to server file
}
ClientDriver defines a very basic client driver
func (*ClientDriver) AsyncListFiles ¶
func (driver *ClientDriver) AsyncListFiles(cc server.ClientContext, cfiles chan<- os.FileInfo)
func (*ClientDriver) CanAllocate ¶
func (driver *ClientDriver) CanAllocate(cc server.ClientContext, size int) (bool, error)
CanAllocate gives the approval to allocate some data
func (*ClientDriver) ChangeDirectory ¶
func (driver *ClientDriver) ChangeDirectory(cc server.ClientContext, directory string) error
ChangeDirectory changes the current working directory
func (*ClientDriver) ChmodFile ¶
func (driver *ClientDriver) ChmodFile(cc server.ClientContext, path string, mode os.FileMode) error
ChmodFile changes the attributes of the file
func (*ClientDriver) DeleteFile ¶
func (driver *ClientDriver) DeleteFile(cc server.ClientContext, path string) error
DeleteFile deletes a file or a directory
func (*ClientDriver) GetFileInfo ¶
func (driver *ClientDriver) GetFileInfo(cc server.ClientContext, path string) (os.FileInfo, error)
GetFileInfo gets some info around a file or a directory
func (*ClientDriver) ListFiles ¶
func (driver *ClientDriver) ListFiles(cc server.ClientContext) ([]os.FileInfo, error)
ListFiles lists the files of a directory
func (*ClientDriver) MakeDirectory ¶
func (driver *ClientDriver) MakeDirectory(cc server.ClientContext, directory string) error
MakeDirectory creates a directory
func (*ClientDriver) OpenFile ¶
func (driver *ClientDriver) OpenFile(cc server.ClientContext, path string, flag int) (server.FileStream, error)
OpenFile opens a file in 3 possible modes: read, write, appending write (use appropriate flags)
func (*ClientDriver) RenameFile ¶
func (driver *ClientDriver) RenameFile(cc server.ClientContext, from, to string) error
RenameFile renames a file or a directory
type FilesDriver ¶
type FilesDriver struct { server.MainDriver SettingsFile string // Settings file BaseDir string // Base directory from which to serve file // contains filtered or unexported fields }
FilesDriver defines a very basic ftpserver driver
func NewSampleDriver ¶
func NewSampleDriver(dir string, settingsFile string) (*FilesDriver, error)
NewSampleDriver creates a sample driver
func (*FilesDriver) AuthUser ¶
func (driver *FilesDriver) AuthUser(cc server.ClientContext, user, pass string) (server.ClientHandlingDriver, error)
AuthUser authenticates the user and selects an handling driver
func (*FilesDriver) GetSettings ¶
func (driver *FilesDriver) GetSettings() (*server.Settings, error)
GetSettings returns some general settings around the server setup
func (*FilesDriver) GetTLSConfig ¶
func (driver *FilesDriver) GetTLSConfig() (*tls.Config, error)
GetTLSConfig returns a TLS Certificate to use
func (*FilesDriver) UserLeft ¶
func (driver *FilesDriver) UserLeft(cc server.ClientContext)
UserLeft is called when the user disconnects, even if he never authenticated
func (*FilesDriver) WelcomeUser ¶
func (driver *FilesDriver) WelcomeUser(cc server.ClientContext) (string, error)
WelcomeUser is called to send the very first welcome message
type OurSettings ¶
type OurSettings struct { Server server.Settings // Server settings (shouldn't need to be filled) Users []Account // Credentials MaxConnections int32 // Maximum number of clients that are allowed to connect at the same time }
OurSettings defines our settings
type VirtualFile ¶
type VirtualFile struct {
// contains filtered or unexported fields
}
The virtual file is an example of how you can implement a purely virtual file
func (*VirtualFile) Close ¶
func (f *VirtualFile) Close() error
type VirtualFileInfo ¶
type VirtualFileInfo struct {
// contains filtered or unexported fields
}
func (*VirtualFileInfo) IsDir ¶
func (f *VirtualFileInfo) IsDir() bool
func (*VirtualFileInfo) ModTime ¶
func (f *VirtualFileInfo) ModTime() time.Time
func (*VirtualFileInfo) Mode ¶
func (f *VirtualFileInfo) Mode() os.FileMode
func (*VirtualFileInfo) Name ¶
func (f *VirtualFileInfo) Name() string
func (*VirtualFileInfo) Size ¶
func (f *VirtualFileInfo) Size() int64
func (*VirtualFileInfo) Sys ¶
func (f *VirtualFileInfo) Sys() interface{}