Documentation ¶
Index ¶
- Constants
- type Authenticator
- type CloudwatchSender
- type DriverFactory
- type FTPLogger
- func (logger *FTPLogger) Print(sessionID string, message interface{})
- func (logger *FTPLogger) PrintCommand(sessionID string, command string, params string)
- func (logger *FTPLogger) PrintResponse(sessionID string, code int, message string)
- func (logger *FTPLogger) Printf(sessionID string, format string, v ...interface{})
- type FactoryConfig
- type MetricsSender
- type NopSender
- type S3Driver
- func (d S3Driver) ChangeDir(path string) error
- func (d S3Driver) DeleteDir(key string) error
- func (d S3Driver) DeleteFile(key string) error
- func (d S3Driver) GetFile(key string, offset int64) (int64, io.ReadCloser, error)
- func (d S3Driver) Init(conn *ftp.Conn)
- func (d S3Driver) ListDir(key string, cb func(ftp.FileInfo) error) error
- func (d S3Driver) MakeDir(key string) error
- func (d S3Driver) PutFile(key string, data io.Reader, appendMode bool) (int64, error)
- func (d S3Driver) Rename(oldKey string, newKey string) error
- func (d S3Driver) Stat(key string) (ftp.FileInfo, error)
- type S3ObjectInfo
- func (s S3ObjectInfo) Group() string
- func (s S3ObjectInfo) IsDir() bool
- func (s S3ObjectInfo) ModTime() time.Time
- func (s S3ObjectInfo) Mode() os.FileMode
- func (s S3ObjectInfo) Name() string
- func (s S3ObjectInfo) Owner() string
- func (s S3ObjectInfo) Size() int64
- func (s S3ObjectInfo) Sys() interface{}
Constants ¶
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.
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.
type FTPLogger ¶
type FTPLogger struct{}
FTPLogger is a logger implementation for use in `go-ftp`.
func (*FTPLogger) PrintCommand ¶
PrintCommand logs the given command and its parameters as well as the session id.
func (*FTPLogger) PrintResponse ¶
PrintResponse logs the response code and message as well as the 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.
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 ¶
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 ¶
DeleteDir will always return an error because there is no such operation for a cloud object storage.
func (S3Driver) DeleteFile ¶
DeleteFile will delete the object with key `key`.
func (S3Driver) ListDir ¶
ListDir call the callback function with object metadata for each object located under prefix `key`.
func (S3Driver) MakeDir ¶
MakeDir will always return an error because there is no such operation for a cloud object storage.
func (S3Driver) PutFile ¶
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.
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.