improve FTP support

- allow to disable active mode
- allow to disable SITE commands
- add optional support for calculating hash value of files
- add optional support for the non standard COMB command
This commit is contained in:
Nicola Murino
2020-12-24 18:48:06 +01:00
parent 5b1d8666b3
commit 1dce1eff48
15 changed files with 375 additions and 31 deletions

View File

@@ -51,10 +51,22 @@ func (cc mockFTPClientContext) GetClientVersion() string {
return "mock version"
}
func (cc mockFTPClientContext) Close(code int, message string) error {
func (cc mockFTPClientContext) Close() error {
return nil
}
func (cc mockFTPClientContext) HasTLSForControl() bool {
return false
}
func (cc mockFTPClientContext) HasTLSForTransfers() bool {
return false
}
func (cc mockFTPClientContext) GetLastCommand() string {
return ""
}
// MockOsFs mockable OsFs
type MockOsFs struct {
vfs.Fs
@@ -209,7 +221,7 @@ func TestUserInvalidParams(t *testing.T) {
End: 11000,
},
}
server := NewServer(c, configDir, binding, 0)
server := NewServer(c, configDir, binding, 3)
_, err := server.validateUser(u, mockFTPClientContext{})
assert.Error(t, err)
@@ -241,7 +253,7 @@ func TestUserInvalidParams(t *testing.T) {
func TestClientVersion(t *testing.T) {
mockCC := mockFTPClientContext{}
connID := fmt.Sprintf("%v", mockCC.ID())
connID := fmt.Sprintf("2_%v", mockCC.ID())
user := dataprovider.User{}
connection := &Connection{
BaseConnection: common.NewBaseConnection(connID, common.ProtocolFTP, user, nil),
@@ -258,7 +270,7 @@ func TestClientVersion(t *testing.T) {
func TestDriverMethodsNotImplemented(t *testing.T) {
mockCC := mockFTPClientContext{}
connID := fmt.Sprintf("%v", mockCC.ID())
connID := fmt.Sprintf("2_%v", mockCC.ID())
user := dataprovider.User{}
connection := &Connection{
BaseConnection: common.NewBaseConnection(connID, common.ProtocolFTP, user, nil),