[BUGFIX] ftp join and
This commit is contained in:
parent
80fab46918
commit
e7b365df5e
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in New Issue