diff --git a/cmd/warehost-ftp/config.go b/cmd/warehost-ftp/config.go index 2e56104..28c6a8e 100644 --- a/cmd/warehost-ftp/config.go +++ b/cmd/warehost-ftp/config.go @@ -8,8 +8,9 @@ import ( // Config of warehost webserver type Config struct { - Database string `yaml:"database"` - Log struct { + Database string `yaml:"database"` + WelcomeMessage string `yaml:"welcome_message"` + Log struct { Path string `yaml:"path"` } `yaml:"log"` DatabaseDebug bool `yaml:"databasedebug"` @@ -17,6 +18,10 @@ type Config struct { Host string `yaml:"host"` Web string `yaml:"web"` Port int `yaml:"port"` + SSL struct { + Public string `yaml:"public"` + Private string `yaml:"private"` + } `yaml:"ssl"` } // ReadConfigFile reads a config models by path to a yml file diff --git a/cmd/warehost-ftp/driver.go b/cmd/warehost-ftp/driver.go index 95484a9..0ca4e1b 100644 --- a/cmd/warehost-ftp/driver.go +++ b/cmd/warehost-ftp/driver.go @@ -110,7 +110,7 @@ func (driver *FileDriver) realPath(path string) (string, bool) { if driver.login.Superadmin { driver.db.Joins("LEFT JOIN host_domain ON host_domain.id=host_web.domain").Where("CONCAT(host_web.subdomain,'.',host_domain.fqdn) = ?", domain).Or("host_web.subdomain='' AND host_domain.fqdn = ?", domain).First(&web) } else { - driver.db.Joins("LEFT JOIN host_domain ON host_domain.id=host_web.domain").Joins("LEFT JOIN host_web_ftpaccess ftp ON ftp.web=host_web.id AND ftp.login = ?", driver.login.ID).Where("CONCAT(host_web.subdomain,'.',host_domain.fqdn) = ?", domain).Or("host_web.subdomain='' AND host_domain.fqdn = ?", domain).First(&web) + driver.db.Joins("LEFT JOIN host_domain ON host_domain.id=host_web.domain").Joins("LEFT JOIN host_web_ftpaccess ftp ON ftp.web=host_web.id").Where("ftp.login = ?", driver.login.ID).Where("CONCAT(host_web.subdomain,'.',host_domain.fqdn) = ?", domain).Or("host_web.subdomain='' AND host_domain.fqdn = ?", domain).First(&web) } if web.ID > 0 { root = fmt.Sprintf(driver.config.Host, domain) @@ -232,7 +232,7 @@ func (driver *FileDriver) ListDir(path string, callback func(ftpd.FileInfo) erro if driver.login.Superadmin { driver.db.Preload("Domain").Find(&list) } else { - driver.db.Joins("LEFT JOIN host_web_ftpaccess ftp ON ftp.web=host_web.id AND ftp.login = ?", driver.login.ID).Preload("Domain").Find(&list) + driver.db.Joins("LEFT JOIN host_web_ftpaccess ftp ON ftp.web=host_web.id").Where("ftp.login = ?", driver.login.ID).Preload("Domain").Find(&list) } for _, i := range list { diff --git a/cmd/warehost-ftp/main.go b/cmd/warehost-ftp/main.go index eedf158..0ce5c8c 100644 --- a/cmd/warehost-ftp/main.go +++ b/cmd/warehost-ftp/main.go @@ -50,6 +50,14 @@ func main() { Port: config.Port, Auth: WarehostAuth{db: dbconnection}, } + if config.WelcomeMessage != "" { + opt.WelcomeMessage = config.WelcomeMessage + } + if config.SSL.Private != "" && config.SSL.Public != "" { + opt.TLS = true + opt.CertFile = config.SSL.Public + opt.KeyFile = config.SSL.Private + } // start ftp server ftpServer := ftpd.NewServer(opt)