server

package
v0.5.1-0...-b85d87f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFeatureSet is the driver default (set of) features
	DefaultFeatureSet = "ls"
	// DefaultRegion is the default bucket region
	DefaultRegion = "custom"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator contains credentials. Implements https://godoc.org/github.com/goftp/server#Auth

func AuthenticatorFromFile

func AuthenticatorFromFile(path string) (Authenticator, error)

AuthenticatorFromFile returns an Authenticator with credentials parsed from the given file path. The file must contain one credential pair per line where username and password is separated by a `:`.

func AuthenticatorFromString

func AuthenticatorFromString(contents string) (Authenticator, error)

AuthenticatorFromString returns an Authenticator whose credentials where parsed from the given string. The contents must contain one credential pair per line where username and password is separated by a `:`.

func (Authenticator) CheckPasswd

func (c Authenticator) CheckPasswd(username, password string) (bool, error)

CheckPasswd returns `true` if username and password was found in the credentials store.

type CloudwatchSender

type CloudwatchSender struct {
	// contains filtered or unexported fields
}

CloudwatchSender implements MetricsSender for amazon's cloudwatch service.

func (*CloudwatchSender) SendGet

func (c *CloudwatchSender) SendGet(size int64, timestamp time.Time) error

SendGet stores the metric data for a GET operation in cloudwatch.

func (*CloudwatchSender) SendPut

func (c *CloudwatchSender) SendPut(size int64, timestamp time.Time) error

SendPut stores the metric data for a PUT operation in cloudwatch.

type DriverFactory

type DriverFactory struct {
	DisableCloudWatch bool
	// contains filtered or unexported fields
}

DriverFactory builds FTP drivers. Implements https://godoc.org/github.com/goftp/server#DriverFactory

func NewDriverFactory

func NewDriverFactory(config *FactoryConfig) (DriverFactory, error)

NewDriverFactory returns a DriverFactory.

func (DriverFactory) NewDriver

func (d DriverFactory) NewDriver() (ftp.Driver, error)

NewDriver returns a new FTP driver.

type FTPLogger

type FTPLogger struct{}

FTPLogger is a logger implementation for use in `go-ftp`.

func (*FTPLogger) Print

func (logger *FTPLogger) Print(sessionID string, message interface{})

Print logs the given message and session id.

func (*FTPLogger) PrintCommand

func (logger *FTPLogger) PrintCommand(sessionID string, command string, params string)

PrintCommand logs the given command and its parameters as well as the session id.

func (*FTPLogger) PrintResponse

func (logger *FTPLogger) PrintResponse(sessionID string, code int, message string)

PrintResponse logs the response code and message as well as the session id.

func (*FTPLogger) Printf

func (logger *FTPLogger) Printf(sessionID string, format string, v ...interface{})

Printf logs an evaluated format string with arguments and the given session id.

type FactoryConfig

type FactoryConfig struct {
	FtpFeatures       string
	FtpNoOverwrite    bool
	S3Credentials     string
	S3BucketURL       string
	S3Region          string
	S3UsePathStyle    bool
	DisableCloudWatch bool
}

FactoryConfig wraps config values required to setup an FTP driver and for the s3 backend.

type MetricsSender

type MetricsSender interface {
	// SendPut sends the size of a stored (PUT) object and the operation's timestamp.
	SendPut(size int64, timestamp time.Time) error
	// SendGet sends the size of a served (GET) object and the operation's timestamp.
	SendGet(size int64, timestamp time.Time) error
}

MetricsSender defines methods for sending data to a metrics provider.

func NewCloudwatchSender

func NewCloudwatchSender(awsSession *session.Session) (MetricsSender, error)

NewCloudwatchSender returns a new CloudwatchSender for the given session.

type NopSender

type NopSender struct{}

NopSender returns immediately.

func (NopSender) SendGet

func (n NopSender) SendGet(size int64, timestamp time.Time) error

SendGet returns nil.

func (NopSender) SendPut

func (n NopSender) SendPut(size int64, timestamp time.Time) error

SendPut returns nil.

type S3Driver

type S3Driver struct {
	// contains filtered or unexported fields
}

S3Driver is a filesystem FTP driver. Implements https://godoc.org/github.com/goftp/server#Driver

func (S3Driver) ChangeDir

func (d S3Driver) ChangeDir(path string) error

ChangeDir will always return an error because there is no such operation for a cloud object storage.

To allow uploading into "subdirectories" of a bucket a path change is simulated by keeping track of `CD` calls. In FTP only a single directory level will be changed at a time, i.e. `CD /foo/bar` will result in two calls, `CD /foo` and `CD /foo/bar`. There is no server side logic to be implement because relative paths are handled by the client, at least is how lftp and Filezilla operated.

func (S3Driver) DeleteDir

func (d S3Driver) DeleteDir(key string) error

DeleteDir will always return an error because there is no such operation for a cloud object storage.

func (S3Driver) DeleteFile

func (d S3Driver) DeleteFile(key string) error

DeleteFile will delete the object with key `key`.

func (S3Driver) GetFile

func (d S3Driver) GetFile(key string, offset int64) (int64, io.ReadCloser, error)

GetFile returns the object with key `key`.

func (S3Driver) Init

func (d S3Driver) Init(conn *ftp.Conn)

Init initializes the FTP connection.

func (S3Driver) ListDir

func (d S3Driver) ListDir(key string, cb func(ftp.FileInfo) error) error

ListDir call the callback function with object metadata for each object located under prefix `key`.

func (S3Driver) MakeDir

func (d S3Driver) MakeDir(key string) error

MakeDir will always return an error because there is no such operation for a cloud object storage.

func (S3Driver) PutFile

func (d S3Driver) PutFile(key string, data io.Reader, appendMode bool) (int64, error)

PutFile stores the object with key `key`. The method returns an error with no-overwrite was set and the object already exists or appendMode was specified.

func (S3Driver) Rename

func (d S3Driver) Rename(oldKey string, newKey string) error

Rename will always return an error because there is no such operation for a cloud object storage.

func (S3Driver) Stat

func (d S3Driver) Stat(key string) (ftp.FileInfo, error)

Stat returns information about the object with key `key`.

type S3ObjectInfo

type S3ObjectInfo struct {
	// contains filtered or unexported fields
}

S3ObjectInfo metadata about an s3 object.

func (S3ObjectInfo) Group

func (s S3ObjectInfo) Group() string

Group returns always "Unknown" because there is no corresponding attribute for an s3 object.

func (S3ObjectInfo) IsDir

func (s S3ObjectInfo) IsDir() bool

IsDir is solely used for compatibility with FTP, don't rely on its return value.

func (S3ObjectInfo) ModTime

func (s S3ObjectInfo) ModTime() time.Time

ModTime returns the object's date of last modification.

func (S3ObjectInfo) Mode

func (s S3ObjectInfo) Mode() os.FileMode

Mode returns `o644` for all objects because there is no file mode equivalent for s3 objects.

func (S3ObjectInfo) Name

func (s S3ObjectInfo) Name() string

Name returns an s3 objects fully qualified identifier, e.g. `https://my-bucket.s3.amazonaws.com/some/prefix/objectKey`.

func (S3ObjectInfo) Owner

func (s S3ObjectInfo) Owner() string

Owner returns the objects owner name if known, otherwise "Unknown" is returned.

func (S3ObjectInfo) Size

func (s S3ObjectInfo) Size() int64

Size returns the objects size in bytes.

func (S3ObjectInfo) Sys

func (s S3ObjectInfo) Sys() interface{}

Sys always returns `nil`.

Jump to

Keyboard shortcuts

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