mirror of
https://github.com/rclone/rclone.git
synced 2025-01-08 23:40:29 +01:00
vendor: update goftp.io/server to v0.3.5-master to fix auth proxy #4394
See upstream issue: https://gitea.com/goftp/server/issues/117
This commit is contained in:
parent
0afd5a2204
commit
c7eae60944
4
go.mod
4
go.mod
@ -5,6 +5,7 @@ go 1.14
|
||||
require (
|
||||
bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512
|
||||
cloud.google.com/go v0.59.0 // indirect
|
||||
code.gitea.io/log v0.0.0-20191208183219-f31613838113 // indirect
|
||||
github.com/Azure/azure-pipeline-go v0.2.2
|
||||
github.com/Azure/azure-storage-blob-go v0.10.0
|
||||
github.com/Unknwon/goconfig v0.0.0-20191126170842-860a72fb44fd
|
||||
@ -60,7 +61,7 @@ require (
|
||||
go.etcd.io/bbolt v1.3.5
|
||||
go.opencensus.io v0.22.4 // indirect
|
||||
go.uber.org/zap v1.15.0 // indirect
|
||||
goftp.io/server v0.3.3
|
||||
goftp.io/server v0.3.5-0.20200630051340-d7b447417587
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
@ -73,6 +74,7 @@ require (
|
||||
google.golang.org/grpc v1.30.0 // indirect
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
gopkg.in/ini.v1 v1.57.0 // indirect
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
|
||||
storj.io/common v0.0.0-20200624215549-bf610d22d466 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -502,6 +502,8 @@ goftp.io/server v0.3.3 h1:ufplF8S62baWmzmFBkvaVfVGTD6cq8ona8BzNvwRiqc=
|
||||
goftp.io/server v0.3.3/go.mod h1:Ewqfa40Xnkh/AEA+Sf9KX2lp8aKnEum77YDHhHwABK4=
|
||||
goftp.io/server v0.3.4 h1:Sq0leWKoZFRWtbxNrHRqKpBygVg2kcRPqgbXnLIFRVU=
|
||||
goftp.io/server v0.3.4/go.mod h1:hFZeR656ErRt3ojMKt7H10vQ5nuWV1e0YeUTeorlR6k=
|
||||
goftp.io/server v0.3.5-0.20200630051340-d7b447417587 h1:wbWVo+1uNd5kviLopJ2mZbVQgRG91Y/tGEUu67WrLbA=
|
||||
goftp.io/server v0.3.5-0.20200630051340-d7b447417587/go.mod h1:hFZeR656ErRt3ojMKt7H10vQ5nuWV1e0YeUTeorlR6k=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
5
vendor/goftp.io/server/.drone.yml
generated
vendored
5
vendor/goftp.io/server/.drone.yml
generated
vendored
@ -19,7 +19,7 @@ steps:
|
||||
commands:
|
||||
- export PATH=$PATH:/go:/srv/app/bin
|
||||
- go vet ./...
|
||||
- go test -race ./...
|
||||
- go test -v -race ./...
|
||||
environment:
|
||||
GOPATH: /srv/app
|
||||
MINIO_SERVER_ENDPOINT: minio:9000
|
||||
@ -28,6 +28,7 @@ steps:
|
||||
MINIO_SERVER_SECRET_KEY:
|
||||
from_secret: aws_secret_access_key
|
||||
MINIO_SERVER_BUCKET: test
|
||||
GOPROXY: https://goproxy.cn,direct
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
@ -36,7 +37,7 @@ steps:
|
||||
|
||||
services:
|
||||
- name: minio
|
||||
image: minio/minio:RELEASE.2019-10-12T01-39-57Z
|
||||
image: minio/minio:RELEASE.2020-03-14T02-21-58Z
|
||||
commands:
|
||||
- minio server ./data
|
||||
environment:
|
||||
|
3
vendor/goftp.io/server/.gitignore
generated
vendored
3
vendor/goftp.io/server/.gitignore
generated
vendored
@ -1,3 +1,4 @@
|
||||
testdata
|
||||
coverage.txt
|
||||
exampleftpd/exampleftpd
|
||||
exampleftpd/exampleftpd
|
||||
.vscode
|
8
vendor/goftp.io/server/cmd.go
generated
vendored
8
vendor/goftp.io/server/cmd.go
generated
vendored
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Command represents a Command interface to a ftp command
|
||||
type Command interface {
|
||||
IsExtend() bool
|
||||
RequireParam() bool
|
||||
@ -630,7 +631,12 @@ func (cmd commandPass) RequireAuth() bool {
|
||||
}
|
||||
|
||||
func (cmd commandPass) Execute(conn *Conn, param string) {
|
||||
ok, err := conn.server.Auth.CheckPasswd(conn.reqUser, param)
|
||||
auth := conn.server.Auth
|
||||
// If Driver implements Auth then call that instead of the Server version
|
||||
if driverAuth, found := conn.driver.(Auth); found {
|
||||
auth = driverAuth
|
||||
}
|
||||
ok, err := auth.CheckPasswd(conn.reqUser, param)
|
||||
conn.server.notifiers.AfterUserLogin(conn, conn.reqUser, param, ok, err)
|
||||
if err != nil {
|
||||
conn.writeMessage(550, "Checking password error")
|
||||
|
23
vendor/goftp.io/server/conn.go
generated
vendored
23
vendor/goftp.io/server/conn.go
generated
vendored
@ -26,6 +26,7 @@ const (
|
||||
defaultWelcomeMessage = "Welcome to the Go FTP Server"
|
||||
)
|
||||
|
||||
// Conn represents a connection between ftp client and the server
|
||||
type Conn struct {
|
||||
conn net.Conn
|
||||
controlReader *bufio.Reader
|
||||
@ -47,22 +48,35 @@ type Conn struct {
|
||||
tls bool
|
||||
}
|
||||
|
||||
// RemoteAddr returns the remote ftp client's address
|
||||
func (conn *Conn) RemoteAddr() net.Addr {
|
||||
return conn.conn.RemoteAddr()
|
||||
}
|
||||
|
||||
// LoginUser returns the login user name if login
|
||||
func (conn *Conn) LoginUser() string {
|
||||
return conn.user
|
||||
}
|
||||
|
||||
// IsLogin returns if user has login
|
||||
func (conn *Conn) IsLogin() bool {
|
||||
return len(conn.user) > 0
|
||||
}
|
||||
|
||||
func (conn *Conn) PublicIp() string {
|
||||
return conn.server.PublicIp
|
||||
// PublicIP returns the public ip of the server
|
||||
func (conn *Conn) PublicIP() string {
|
||||
return conn.server.PublicIP
|
||||
}
|
||||
|
||||
// ServerOpts returns the server options
|
||||
func (conn *Conn) ServerOpts() *ServerOpts {
|
||||
return conn.server.ServerOpts
|
||||
}
|
||||
|
||||
func (conn *Conn) passiveListenIP() string {
|
||||
var listenIP string
|
||||
if len(conn.PublicIp()) > 0 {
|
||||
listenIP = conn.PublicIp()
|
||||
if len(conn.PublicIP()) > 0 {
|
||||
listenIP = conn.PublicIP()
|
||||
} else {
|
||||
listenIP = conn.conn.LocalAddr().(*net.TCPAddr).IP.String()
|
||||
}
|
||||
@ -78,6 +92,7 @@ func (conn *Conn) passiveListenIP() string {
|
||||
return listenIP[:lastIdx]
|
||||
}
|
||||
|
||||
// PassivePort returns the port which could be used by passive mode.
|
||||
func (conn *Conn) PassivePort() int {
|
||||
if len(conn.server.PassivePorts) > 0 {
|
||||
portRange := strings.Split(conn.server.PassivePorts, "-")
|
||||
|
18
vendor/goftp.io/server/driver.go
generated
vendored
18
vendor/goftp.io/server/driver.go
generated
vendored
@ -16,9 +16,13 @@ type DriverFactory interface {
|
||||
NewDriver() (Driver, error)
|
||||
}
|
||||
|
||||
// Driver is an interface that you will create an implementation that speaks to your
|
||||
// chosen persistence layer. graval will create a new instance of your
|
||||
// Driver is an interface that you will implement to create a driver for your
|
||||
// chosen persistence layer. The server will create a new instance of your
|
||||
// driver for each client that connects and delegate to it as required.
|
||||
//
|
||||
// Note that if the driver also implements the Auth interface then
|
||||
// this will be called instead of calling ServerOpts.Auth. This allows
|
||||
// the Auth mechanism to change the driver configuration.
|
||||
type Driver interface {
|
||||
// params - a file path
|
||||
// returns - a time indicating when the requested path was last modified
|
||||
@ -63,6 +67,7 @@ type MultipleDriver struct {
|
||||
drivers map[string]Driver
|
||||
}
|
||||
|
||||
// Stat implements Driver
|
||||
func (driver *MultipleDriver) Stat(path string) (FileInfo, error) {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -72,6 +77,7 @@ func (driver *MultipleDriver) Stat(path string) (FileInfo, error) {
|
||||
return nil, errors.New("Not a file")
|
||||
}
|
||||
|
||||
// ListDir implements Driver
|
||||
func (driver *MultipleDriver) ListDir(path string, callback func(FileInfo) error) error {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -81,6 +87,7 @@ func (driver *MultipleDriver) ListDir(path string, callback func(FileInfo) error
|
||||
return errors.New("Not a directory")
|
||||
}
|
||||
|
||||
// DeleteDir implements Driver
|
||||
func (driver *MultipleDriver) DeleteDir(path string) error {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -90,6 +97,7 @@ func (driver *MultipleDriver) DeleteDir(path string) error {
|
||||
return errors.New("Not a directory")
|
||||
}
|
||||
|
||||
// DeleteFile implements Driver
|
||||
func (driver *MultipleDriver) DeleteFile(path string) error {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -100,6 +108,7 @@ func (driver *MultipleDriver) DeleteFile(path string) error {
|
||||
return errors.New("Not a file")
|
||||
}
|
||||
|
||||
// Rename implements Driver
|
||||
func (driver *MultipleDriver) Rename(fromPath string, toPath string) error {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(fromPath, prefix) {
|
||||
@ -110,6 +119,7 @@ func (driver *MultipleDriver) Rename(fromPath string, toPath string) error {
|
||||
return errors.New("Not a file")
|
||||
}
|
||||
|
||||
// MakeDir implements Driver
|
||||
func (driver *MultipleDriver) MakeDir(path string) error {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -119,6 +129,7 @@ func (driver *MultipleDriver) MakeDir(path string) error {
|
||||
return errors.New("Not a directory")
|
||||
}
|
||||
|
||||
// GetFile implements Driver
|
||||
func (driver *MultipleDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
@ -129,6 +140,7 @@ func (driver *MultipleDriver) GetFile(path string, offset int64) (int64, io.Read
|
||||
return 0, nil, errors.New("Not a file")
|
||||
}
|
||||
|
||||
// PutFile implements Driver
|
||||
func (driver *MultipleDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
|
||||
for prefix, driver := range driver.drivers {
|
||||
if strings.HasPrefix(destPath, prefix) {
|
||||
@ -139,10 +151,12 @@ func (driver *MultipleDriver) PutFile(destPath string, data io.Reader, appendDat
|
||||
return 0, errors.New("Not a file")
|
||||
}
|
||||
|
||||
// MultipleDriverFactory implements a DriverFactory
|
||||
type MultipleDriverFactory struct {
|
||||
drivers map[string]Driver
|
||||
}
|
||||
|
||||
// NewDriver implements DriverFactory
|
||||
func (factory *MultipleDriverFactory) NewDriver() (Driver, error) {
|
||||
return &MultipleDriver{factory.drivers}, nil
|
||||
}
|
||||
|
16
vendor/goftp.io/server/driver_file.go
generated
vendored
16
vendor/goftp.io/server/driver_file.go
generated
vendored
@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FileDriver implements Driver directly read local file system
|
||||
type FileDriver struct {
|
||||
RootPath string
|
||||
Perm
|
||||
@ -23,6 +24,7 @@ func (driver *FileDriver) realPath(path string) string {
|
||||
return filepath.Join(append([]string{driver.RootPath}, paths...)...)
|
||||
}
|
||||
|
||||
// Stat implements Driver
|
||||
func (driver *FileDriver) Stat(path string) (FileInfo, error) {
|
||||
basepath := driver.realPath(path)
|
||||
rPath, err := filepath.Abs(basepath)
|
||||
@ -51,6 +53,7 @@ func (driver *FileDriver) Stat(path string) (FileInfo, error) {
|
||||
return &fileInfo{f, mode, owner, group}, nil
|
||||
}
|
||||
|
||||
// ListDir implements Driver
|
||||
func (driver *FileDriver) ListDir(path string, callback func(FileInfo) error) error {
|
||||
basepath := driver.realPath(path)
|
||||
return filepath.Walk(basepath, func(f string, info os.FileInfo, err error) error {
|
||||
@ -86,6 +89,7 @@ func (driver *FileDriver) ListDir(path string, callback func(FileInfo) error) er
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteDir implements Driver
|
||||
func (driver *FileDriver) DeleteDir(path string) error {
|
||||
rPath := driver.realPath(path)
|
||||
f, err := os.Lstat(rPath)
|
||||
@ -98,6 +102,7 @@ func (driver *FileDriver) DeleteDir(path string) error {
|
||||
return errors.New("Not a directory")
|
||||
}
|
||||
|
||||
// DeleteFile implements Driver
|
||||
func (driver *FileDriver) DeleteFile(path string) error {
|
||||
rPath := driver.realPath(path)
|
||||
f, err := os.Lstat(rPath)
|
||||
@ -110,17 +115,20 @@ func (driver *FileDriver) DeleteFile(path string) error {
|
||||
return errors.New("Not a file")
|
||||
}
|
||||
|
||||
// Rename implements Driver
|
||||
func (driver *FileDriver) Rename(fromPath string, toPath string) error {
|
||||
oldPath := driver.realPath(fromPath)
|
||||
newPath := driver.realPath(toPath)
|
||||
return os.Rename(oldPath, newPath)
|
||||
}
|
||||
|
||||
// MakeDir implements Driver
|
||||
func (driver *FileDriver) MakeDir(path string) error {
|
||||
rPath := driver.realPath(path)
|
||||
return os.MkdirAll(rPath, os.ModePerm)
|
||||
}
|
||||
|
||||
// GetFile implements Driver
|
||||
func (driver *FileDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
|
||||
rPath := driver.realPath(path)
|
||||
f, err := os.Open(rPath)
|
||||
@ -138,6 +146,7 @@ func (driver *FileDriver) GetFile(path string, offset int64) (int64, io.ReadClos
|
||||
return info.Size() - offset, f, nil
|
||||
}
|
||||
|
||||
// PutFile implements Driver
|
||||
func (driver *FileDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
|
||||
rPath := driver.realPath(destPath)
|
||||
var isExist bool
|
||||
@ -197,11 +206,18 @@ func (driver *FileDriver) PutFile(destPath string, data io.Reader, appendData bo
|
||||
return bytes, nil
|
||||
}
|
||||
|
||||
// FileDriverFactory implements DriverFactory
|
||||
type FileDriverFactory struct {
|
||||
RootPath string
|
||||
Perm
|
||||
}
|
||||
|
||||
// NewDriver implements DriverFactory
|
||||
func (factory *FileDriverFactory) NewDriver() (Driver, error) {
|
||||
var err error
|
||||
factory.RootPath, err = filepath.Abs(factory.RootPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &FileDriver{factory.RootPath, factory.Perm}, nil
|
||||
}
|
||||
|
88
vendor/goftp.io/server/driver_minio.go
generated
vendored
88
vendor/goftp.io/server/driver_minio.go
generated
vendored
@ -19,6 +19,7 @@ var (
|
||||
_ Driver = &MinioDriver{}
|
||||
)
|
||||
|
||||
// MinioDriver implements Driver to store files in minio
|
||||
type MinioDriver struct {
|
||||
client *minio.Client
|
||||
perm Perm
|
||||
@ -37,13 +38,28 @@ func buildMinioDir(p string) string {
|
||||
return v
|
||||
}
|
||||
|
||||
type minioFileInfo struct {
|
||||
p string
|
||||
info minio.ObjectInfo
|
||||
perm Perm
|
||||
type myPerm struct {
|
||||
Perm
|
||||
isDir bool
|
||||
}
|
||||
|
||||
func (m *myPerm) GetMode(user string) (os.FileMode, error) {
|
||||
mode, err := m.Perm.GetMode(user)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if m.isDir {
|
||||
return mode | os.ModeDir, nil
|
||||
}
|
||||
return mode, nil
|
||||
}
|
||||
|
||||
type minioFileInfo struct {
|
||||
p string
|
||||
info minio.ObjectInfo
|
||||
perm Perm
|
||||
}
|
||||
|
||||
func (m *minioFileInfo) Name() string {
|
||||
return m.p
|
||||
}
|
||||
@ -62,7 +78,7 @@ func (m *minioFileInfo) ModTime() time.Time {
|
||||
}
|
||||
|
||||
func (m *minioFileInfo) IsDir() bool {
|
||||
return m.isDir
|
||||
return m.Mode().IsDir()
|
||||
}
|
||||
|
||||
func (m *minioFileInfo) Sys() interface{} {
|
||||
@ -80,26 +96,32 @@ func (m *minioFileInfo) Group() string {
|
||||
}
|
||||
|
||||
func (driver *MinioDriver) isDir(path string) (bool, error) {
|
||||
doneCh := make(chan struct{})
|
||||
defer close(doneCh)
|
||||
p := buildMinioDir(path)
|
||||
|
||||
info, err := driver.client.StatObject(driver.bucket, p, minio.StatObjectOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
doneCh := make(chan struct{})
|
||||
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
|
||||
for object := range objectCh {
|
||||
if strings.HasPrefix(object.Key, p) {
|
||||
close(doneCh)
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
close(doneCh)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if info.Err != nil {
|
||||
return false, info.Err
|
||||
}
|
||||
return true, nil
|
||||
return strings.HasSuffix(info.Key, "/"), nil
|
||||
}
|
||||
|
||||
// Stat implements Driver
|
||||
func (driver *MinioDriver) Stat(path string) (FileInfo, error) {
|
||||
if path == "/" {
|
||||
return &minioFileInfo{
|
||||
p: "/",
|
||||
perm: driver.perm,
|
||||
isDir: true,
|
||||
p: "/",
|
||||
perm: &myPerm{driver.perm, true},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -110,25 +132,29 @@ func (driver *MinioDriver) Stat(path string) (FileInfo, error) {
|
||||
return nil, err
|
||||
} else if isDir {
|
||||
return &minioFileInfo{
|
||||
p: path,
|
||||
perm: driver.perm,
|
||||
isDir: true,
|
||||
p: path,
|
||||
perm: &myPerm{driver.perm, true},
|
||||
}, nil
|
||||
}
|
||||
return nil, errors.New("Not a directory")
|
||||
}
|
||||
isDir := strings.HasSuffix(objInfo.Key, "/")
|
||||
return &minioFileInfo{
|
||||
p: p,
|
||||
info: objInfo,
|
||||
perm: driver.perm,
|
||||
perm: &myPerm{driver.perm, isDir},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListDir implements Driver
|
||||
func (driver *MinioDriver) ListDir(path string, callback func(FileInfo) error) error {
|
||||
doneCh := make(chan struct{})
|
||||
defer close(doneCh)
|
||||
|
||||
p := buildMinioPath(path)
|
||||
p := buildMinioDir(path)
|
||||
if p == "/" {
|
||||
p = ""
|
||||
}
|
||||
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
|
||||
for object := range objectCh {
|
||||
if object.Err != nil {
|
||||
@ -140,11 +166,14 @@ func (driver *MinioDriver) ListDir(path string, callback func(FileInfo) error) e
|
||||
continue
|
||||
}
|
||||
|
||||
if err := callback(&minioFileInfo{
|
||||
p: object.Key,
|
||||
isDir := strings.HasSuffix(object.Key, "/")
|
||||
info := minioFileInfo{
|
||||
p: strings.TrimPrefix(object.Key, p),
|
||||
info: object,
|
||||
perm: driver.perm,
|
||||
}); err != nil {
|
||||
perm: &myPerm{driver.perm, isDir},
|
||||
}
|
||||
|
||||
if err := callback(&info); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -152,6 +181,7 @@ func (driver *MinioDriver) ListDir(path string, callback func(FileInfo) error) e
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteDir implements Driver
|
||||
func (driver *MinioDriver) DeleteDir(path string) error {
|
||||
doneCh := make(chan struct{})
|
||||
defer close(doneCh)
|
||||
@ -170,10 +200,12 @@ func (driver *MinioDriver) DeleteDir(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteFile implements Driver
|
||||
func (driver *MinioDriver) DeleteFile(path string) error {
|
||||
return driver.client.RemoveObject(driver.bucket, buildMinioPath(path))
|
||||
}
|
||||
|
||||
// Rename implements Driver
|
||||
func (driver *MinioDriver) Rename(fromPath string, toPath string) error {
|
||||
src := minio.NewSourceInfo(driver.bucket, buildMinioPath(fromPath), nil)
|
||||
dst, err := minio.NewDestinationInfo(driver.bucket, buildMinioPath(toPath), nil, nil)
|
||||
@ -188,12 +220,14 @@ func (driver *MinioDriver) Rename(fromPath string, toPath string) error {
|
||||
return driver.client.RemoveObject(driver.bucket, buildMinioPath(fromPath))
|
||||
}
|
||||
|
||||
// MakeDir implements Driver
|
||||
func (driver *MinioDriver) MakeDir(path string) error {
|
||||
dirPath := buildMinioDir(path)
|
||||
_, err := driver.client.PutObject(driver.bucket, dirPath, nil, 0, minio.PutObjectOptions{ContentType: "application/octet-stream"})
|
||||
_, err := driver.client.PutObject(driver.bucket, dirPath, nil, 0, minio.PutObjectOptions{})
|
||||
return err
|
||||
}
|
||||
|
||||
// GetFile implements Driver
|
||||
func (driver *MinioDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
|
||||
var opts = minio.GetObjectOptions{}
|
||||
object, err := driver.client.GetObject(driver.bucket, buildMinioPath(path), opts)
|
||||
@ -210,6 +244,7 @@ func (driver *MinioDriver) GetFile(path string, offset int64) (int64, io.ReadClo
|
||||
return info.Size - offset, object, nil
|
||||
}
|
||||
|
||||
// PutFile implements Driver
|
||||
func (driver *MinioDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
|
||||
p := buildMinioPath(destPath)
|
||||
if !appendData {
|
||||
@ -244,6 +279,7 @@ func (driver *MinioDriver) PutFile(destPath string, data io.Reader, appendData b
|
||||
return size, driver.client.ComposeObject(dst, srcs)
|
||||
}
|
||||
|
||||
// MinioDriverFactory implements DriverFactory
|
||||
type MinioDriverFactory struct {
|
||||
endpoint string
|
||||
accessKeyID string
|
||||
@ -254,6 +290,7 @@ type MinioDriverFactory struct {
|
||||
perm Perm
|
||||
}
|
||||
|
||||
// NewMinioDriverFactory creates a DriverFactory implementation
|
||||
func NewMinioDriverFactory(endpoint, accessKeyID, secretAccessKey, location, bucket string, useSSL bool, perm Perm) *MinioDriverFactory {
|
||||
return &MinioDriverFactory{
|
||||
endpoint: endpoint,
|
||||
@ -266,6 +303,7 @@ func NewMinioDriverFactory(endpoint, accessKeyID, secretAccessKey, location, buc
|
||||
}
|
||||
}
|
||||
|
||||
// NewDriver implements DriverFactory
|
||||
func (factory *MinioDriverFactory) NewDriver() (Driver, error) {
|
||||
// Initialize minio client object.
|
||||
minioClient, err := minio.New(factory.endpoint, factory.accessKeyID, factory.secretAccessKey, factory.useSSL)
|
||||
|
1
vendor/goftp.io/server/file_info.go
generated
vendored
1
vendor/goftp.io/server/file_info.go
generated
vendored
@ -6,6 +6,7 @@ package server
|
||||
|
||||
import "os"
|
||||
|
||||
// FileInfo represents an file interface
|
||||
type FileInfo interface {
|
||||
os.FileInfo
|
||||
|
||||
|
6
vendor/goftp.io/server/go.mod
generated
vendored
6
vendor/goftp.io/server/go.mod
generated
vendored
@ -3,9 +3,11 @@ module goftp.io/server
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
code.gitea.io/log v0.0.0-20191208183219-f31613838113
|
||||
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf
|
||||
github.com/minio/minio-go/v6 v6.0.46
|
||||
github.com/stretchr/testify v1.3.0
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
)
|
||||
|
47
vendor/goftp.io/server/go.sum
generated
vendored
47
vendor/goftp.io/server/go.sum
generated
vendored
@ -1,59 +1,33 @@
|
||||
code.gitea.io/log v0.0.0-20191208183219-f31613838113 h1:r3gilyTmowpqsnvXRX7Ww1sYWmfR8pbZ1meymLXYCDA=
|
||||
code.gitea.io/log v0.0.0-20191208183219-f31613838113/go.mod h1:YOBHMQw/14CwuwNStgQyvnzoDJEO6ARjcSdD48QRzhM=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf h1:2IYBd5TD/maMqTU2YUzp2tJL4cNaOYQ9EBullN9t9pk=
|
||||
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o=
|
||||
github.com/minio/minio-go/v6 v6.0.46 h1:waExJtO53xrnsNX//7cSc1h3478wqTryDx4RVD7o26I=
|
||||
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
|
||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
|
||||
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo=
|
||||
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -63,17 +37,12 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
@ -82,13 +51,5 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
|
||||
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
|
||||
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
|
50
vendor/goftp.io/server/logger.go
generated
vendored
50
vendor/goftp.io/server/logger.go
generated
vendored
@ -9,40 +9,52 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
// Logger represents an interface to record all ftp information and command
|
||||
type Logger interface {
|
||||
Print(sessionId string, message interface{})
|
||||
Printf(sessionId string, format string, v ...interface{})
|
||||
PrintCommand(sessionId string, command string, params string)
|
||||
PrintResponse(sessionId string, code int, message string)
|
||||
Print(sessionID string, message interface{})
|
||||
Printf(sessionID string, format string, v ...interface{})
|
||||
PrintCommand(sessionID string, command string, params string)
|
||||
PrintResponse(sessionID string, code int, message string)
|
||||
}
|
||||
|
||||
// Use an instance of this to log in a standard format
|
||||
// StdLogger use an instance of this to log in a standard format
|
||||
type StdLogger struct{}
|
||||
|
||||
func (logger *StdLogger) Print(sessionId string, message interface{}) {
|
||||
log.Printf("%s %s", sessionId, message)
|
||||
// Print impelment Logger
|
||||
func (logger *StdLogger) Print(sessionID string, message interface{}) {
|
||||
log.Printf("%s %s", sessionID, message)
|
||||
}
|
||||
|
||||
func (logger *StdLogger) Printf(sessionId string, format string, v ...interface{}) {
|
||||
logger.Print(sessionId, fmt.Sprintf(format, v...))
|
||||
// Printf impelment Logger
|
||||
func (logger *StdLogger) Printf(sessionID string, format string, v ...interface{}) {
|
||||
logger.Print(sessionID, fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
func (logger *StdLogger) PrintCommand(sessionId string, command string, params string) {
|
||||
// PrintCommand impelment Logger
|
||||
func (logger *StdLogger) PrintCommand(sessionID string, command string, params string) {
|
||||
if command == "PASS" {
|
||||
log.Printf("%s > PASS ****", sessionId)
|
||||
log.Printf("%s > PASS ****", sessionID)
|
||||
} else {
|
||||
log.Printf("%s > %s %s", sessionId, command, params)
|
||||
log.Printf("%s > %s %s", sessionID, command, params)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *StdLogger) PrintResponse(sessionId string, code int, message string) {
|
||||
log.Printf("%s < %d %s", sessionId, code, message)
|
||||
// PrintResponse impelment Logger
|
||||
func (logger *StdLogger) PrintResponse(sessionID string, code int, message string) {
|
||||
log.Printf("%s < %d %s", sessionID, code, message)
|
||||
}
|
||||
|
||||
// Silent logger, produces no output
|
||||
// DiscardLogger represents a silent logger, produces no output
|
||||
type DiscardLogger struct{}
|
||||
|
||||
func (logger *DiscardLogger) Print(sessionId string, message interface{}) {}
|
||||
func (logger *DiscardLogger) Printf(sessionId string, format string, v ...interface{}) {}
|
||||
func (logger *DiscardLogger) PrintCommand(sessionId string, command string, params string) {}
|
||||
func (logger *DiscardLogger) PrintResponse(sessionId string, code int, message string) {}
|
||||
// Print impelment Logger
|
||||
func (logger *DiscardLogger) Print(sessionID string, message interface{}) {}
|
||||
|
||||
// Printf impelment Logger
|
||||
func (logger *DiscardLogger) Printf(sessionID string, format string, v ...interface{}) {}
|
||||
|
||||
// PrintCommand impelment Logger
|
||||
func (logger *DiscardLogger) PrintCommand(sessionID string, command string, params string) {}
|
||||
|
||||
// PrintResponse impelment Logger
|
||||
func (logger *DiscardLogger) PrintResponse(sessionID string, code int, message string) {}
|
||||
|
63
vendor/goftp.io/server/notifier.go
generated
vendored
63
vendor/goftp.io/server/notifier.go
generated
vendored
@ -111,3 +111,66 @@ func (notifiers notifierList) AfterDirDeleted(conn *Conn, dstPath string, err er
|
||||
notifier.AfterDirDeleted(conn, dstPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
// NullNotifier implements Notifier
|
||||
type NullNotifier struct{}
|
||||
|
||||
var (
|
||||
_ Notifier = &NullNotifier{}
|
||||
)
|
||||
|
||||
// BeforeLoginUser implements Notifier
|
||||
func (NullNotifier) BeforeLoginUser(conn *Conn, userName string) {
|
||||
}
|
||||
|
||||
// BeforePutFile implements Notifier
|
||||
func (NullNotifier) BeforePutFile(conn *Conn, dstPath string) {
|
||||
}
|
||||
|
||||
// BeforeDeleteFile implements Notifier
|
||||
func (NullNotifier) BeforeDeleteFile(conn *Conn, dstPath string) {
|
||||
}
|
||||
|
||||
// BeforeChangeCurDir implements Notifier
|
||||
func (NullNotifier) BeforeChangeCurDir(conn *Conn, oldCurDir, newCurDir string) {
|
||||
}
|
||||
|
||||
// BeforeCreateDir implements Notifier
|
||||
func (NullNotifier) BeforeCreateDir(conn *Conn, dstPath string) {
|
||||
}
|
||||
|
||||
// BeforeDeleteDir implements Notifier
|
||||
func (NullNotifier) BeforeDeleteDir(conn *Conn, dstPath string) {
|
||||
}
|
||||
|
||||
// BeforeDownloadFile implements Notifier
|
||||
func (NullNotifier) BeforeDownloadFile(conn *Conn, dstPath string) {
|
||||
}
|
||||
|
||||
// AfterUserLogin implements Notifier
|
||||
func (NullNotifier) AfterUserLogin(conn *Conn, userName, password string, passMatched bool, err error) {
|
||||
}
|
||||
|
||||
// AfterFilePut implements Notifier
|
||||
func (NullNotifier) AfterFilePut(conn *Conn, dstPath string, size int64, err error) {
|
||||
}
|
||||
|
||||
// AfterFileDeleted implements Notifier
|
||||
func (NullNotifier) AfterFileDeleted(conn *Conn, dstPath string, err error) {
|
||||
}
|
||||
|
||||
// AfterFileDownloaded implements Notifier
|
||||
func (NullNotifier) AfterFileDownloaded(conn *Conn, dstPath string, size int64, err error) {
|
||||
}
|
||||
|
||||
// AfterCurDirChanged implements Notifier
|
||||
func (NullNotifier) AfterCurDirChanged(conn *Conn, oldCurDir, newCurDir string, err error) {
|
||||
}
|
||||
|
||||
// AfterDirCreated implements Notifier
|
||||
func (NullNotifier) AfterDirCreated(conn *Conn, dstPath string, err error) {
|
||||
}
|
||||
|
||||
// AfterDirDeleted implements Notifier
|
||||
func (NullNotifier) AfterDirDeleted(conn *Conn, dstPath string, err error) {
|
||||
}
|
||||
|
9
vendor/goftp.io/server/perm.go
generated
vendored
9
vendor/goftp.io/server/perm.go
generated
vendored
@ -6,6 +6,7 @@ package server
|
||||
|
||||
import "os"
|
||||
|
||||
// Perm represents a perm interface
|
||||
type Perm interface {
|
||||
GetOwner(string) (string, error)
|
||||
GetGroup(string) (string, error)
|
||||
@ -16,10 +17,12 @@ type Perm interface {
|
||||
ChMode(string, os.FileMode) error
|
||||
}
|
||||
|
||||
// SimplePerm implements Perm interface that all files are owned by special owner and group
|
||||
type SimplePerm struct {
|
||||
owner, group string
|
||||
}
|
||||
|
||||
// NewSimplePerm creates a SimplePerm
|
||||
func NewSimplePerm(owner, group string) *SimplePerm {
|
||||
return &SimplePerm{
|
||||
owner: owner,
|
||||
@ -27,26 +30,32 @@ func NewSimplePerm(owner, group string) *SimplePerm {
|
||||
}
|
||||
}
|
||||
|
||||
// GetOwner returns the file's owner
|
||||
func (s *SimplePerm) GetOwner(string) (string, error) {
|
||||
return s.owner, nil
|
||||
}
|
||||
|
||||
// GetGroup returns the group of the file
|
||||
func (s *SimplePerm) GetGroup(string) (string, error) {
|
||||
return s.group, nil
|
||||
}
|
||||
|
||||
// GetMode returns the file's mode
|
||||
func (s *SimplePerm) GetMode(string) (os.FileMode, error) {
|
||||
return os.ModePerm, nil
|
||||
}
|
||||
|
||||
// ChOwner changed the file's owner
|
||||
func (s *SimplePerm) ChOwner(string, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChGroup changed the file's group
|
||||
func (s *SimplePerm) ChGroup(string, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChMode changed the file's mode
|
||||
func (s *SimplePerm) ChMode(string, os.FileMode) error {
|
||||
return nil
|
||||
}
|
||||
|
17
vendor/goftp.io/server/server.go
generated
vendored
17
vendor/goftp.io/server/server.go
generated
vendored
@ -35,7 +35,7 @@ type ServerOpts struct {
|
||||
Hostname string
|
||||
|
||||
// Public IP of the server
|
||||
PublicIp string
|
||||
PublicIP string
|
||||
|
||||
// Passive ports
|
||||
PassivePorts string
|
||||
@ -116,9 +116,10 @@ func serverOptsWithDefaults(opts *ServerOpts) *ServerOpts {
|
||||
newOpts.Auth = opts.Auth
|
||||
}
|
||||
|
||||
newOpts.Logger = &StdLogger{}
|
||||
if opts.Logger != nil {
|
||||
newOpts.Logger = opts.Logger
|
||||
} else {
|
||||
newOpts.Logger = &StdLogger{}
|
||||
}
|
||||
|
||||
newOpts.TLS = opts.TLS
|
||||
@ -126,7 +127,7 @@ func serverOptsWithDefaults(opts *ServerOpts) *ServerOpts {
|
||||
newOpts.CertFile = opts.CertFile
|
||||
newOpts.ExplicitFTPS = opts.ExplicitFTPS
|
||||
|
||||
newOpts.PublicIp = opts.PublicIp
|
||||
newOpts.PublicIP = opts.PublicIP
|
||||
newOpts.PassivePorts = opts.PassivePorts
|
||||
|
||||
return &newOpts
|
||||
@ -155,6 +156,12 @@ func NewServer(opts *ServerOpts) *Server {
|
||||
s.ServerOpts = opts
|
||||
s.listenTo = net.JoinHostPort(opts.Hostname, strconv.Itoa(opts.Port))
|
||||
s.logger = opts.Logger
|
||||
var curFeats = featCmds
|
||||
if opts.TLS {
|
||||
curFeats += " AUTH TLS\n PBSZ\n PROT\n"
|
||||
}
|
||||
s.feats = fmt.Sprintf(feats, curFeats)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
@ -208,7 +215,6 @@ func simpleTLSConfig(certFile, keyFile string) (*tls.Config, error) {
|
||||
func (server *Server) ListenAndServe() error {
|
||||
var listener net.Listener
|
||||
var err error
|
||||
var curFeats = featCmds
|
||||
|
||||
if server.ServerOpts.TLS {
|
||||
server.tlsConfig, err = simpleTLSConfig(server.CertFile, server.KeyFile)
|
||||
@ -216,8 +222,6 @@ func (server *Server) ListenAndServe() error {
|
||||
return err
|
||||
}
|
||||
|
||||
curFeats += " AUTH TLS\n PBSZ\n PROT\n"
|
||||
|
||||
if server.ServerOpts.ExplicitFTPS {
|
||||
listener, err = net.Listen("tcp", server.listenTo)
|
||||
} else {
|
||||
@ -229,7 +233,6 @@ func (server *Server) ListenAndServe() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
server.feats = fmt.Sprintf(feats, curFeats)
|
||||
|
||||
sessionID := ""
|
||||
server.logger.Printf(sessionID, "%s listening on %d", server.Name, server.Port)
|
||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@ -6,6 +6,8 @@ bazil.org/fuse/fuseutil
|
||||
# cloud.google.com/go v0.59.0
|
||||
## explicit
|
||||
cloud.google.com/go/compute/metadata
|
||||
# code.gitea.io/log v0.0.0-20191208183219-f31613838113
|
||||
## explicit
|
||||
# github.com/Azure/azure-pipeline-go v0.2.2
|
||||
## explicit
|
||||
github.com/Azure/azure-pipeline-go/pipeline
|
||||
@ -344,7 +346,7 @@ go.uber.org/zap/internal/bufferpool
|
||||
go.uber.org/zap/internal/color
|
||||
go.uber.org/zap/internal/exit
|
||||
go.uber.org/zap/zapcore
|
||||
# goftp.io/server v0.3.3
|
||||
# goftp.io/server v0.3.5-0.20200630051340-d7b447417587
|
||||
## explicit
|
||||
goftp.io/server
|
||||
# golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||
@ -520,6 +522,8 @@ google.golang.org/protobuf/types/known/timestamppb
|
||||
# gopkg.in/ini.v1 v1.57.0
|
||||
## explicit
|
||||
gopkg.in/ini.v1
|
||||
# gopkg.in/src-d/go-git.v4 v4.13.1
|
||||
## explicit
|
||||
# gopkg.in/yaml.v2 v2.3.0
|
||||
## explicit
|
||||
gopkg.in/yaml.v2
|
||||
|
Loading…
Reference in New Issue
Block a user