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

@@ -93,6 +93,10 @@ func (s *Server) GetSettings() (*ftpserver.Settings, error) {
ConnectionTimeout: 20,
Banner: s.statusBanner,
TLSRequired: ftpserver.TLSRequirement(s.binding.TLSMode),
DisableSite: !s.config.EnableSite,
DisableActiveMode: s.config.DisableActiveMode,
EnableHASH: s.config.HASHSupport > 0,
EnableCOMB: s.config.CombineSupport > 0,
}, nil
}
@@ -156,7 +160,7 @@ func (s *Server) GetTLSConfig() (*tls.Config, error) {
}
func (s *Server) validateUser(user dataprovider.User, cc ftpserver.ClientContext) (*Connection, error) {
connectionID := fmt.Sprintf("%v_%v", common.ProtocolFTP, cc.ID())
connectionID := fmt.Sprintf("%v_%v_%v", common.ProtocolFTP, s.ID, cc.ID())
if !filepath.IsAbs(user.HomeDir) {
logger.Warn(logSender, connectionID, "user %#v has an invalid home dir: %#v. Home dir must be an absolute path, login not allowed",
user.Username, user.HomeDir)