drivers

package
v0.0.0-...-9df619b Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sample is a sample server driver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	User string // Username
	Pass string // Password
	Dir  string // Directory
}

Account defines a user/pass password

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

func (*VirtualFile) Read

func (f *VirtualFile) Read(buffer []byte) (int, error)

func (*VirtualFile) Seek

func (f *VirtualFile) Seek(n int64, w int) (int64, error)

func (*VirtualFile) Write

func (f *VirtualFile) Write(buffer []byte) (int, 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{}

Jump to

Keyboard shortcuts

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