[BUGFIX] ftp join and
This commit is contained in:
parent
80fab46918
commit
e7b365df5e
|
@ -9,6 +9,7 @@ import (
|
||||||
// Config of warehost webserver
|
// Config of warehost webserver
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Database string `yaml:"database"`
|
Database string `yaml:"database"`
|
||||||
|
WelcomeMessage string `yaml:"welcome_message"`
|
||||||
Log struct {
|
Log struct {
|
||||||
Path string `yaml:"path"`
|
Path string `yaml:"path"`
|
||||||
} `yaml:"log"`
|
} `yaml:"log"`
|
||||||
|
@ -17,6 +18,10 @@ type Config struct {
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host"`
|
||||||
Web string `yaml:"web"`
|
Web string `yaml:"web"`
|
||||||
Port int `yaml:"port"`
|
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
|
// 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 {
|
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)
|
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 {
|
} 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 {
|
if web.ID > 0 {
|
||||||
root = fmt.Sprintf(driver.config.Host, domain)
|
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 {
|
if driver.login.Superadmin {
|
||||||
driver.db.Preload("Domain").Find(&list)
|
driver.db.Preload("Domain").Find(&list)
|
||||||
} else {
|
} 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 {
|
for _, i := range list {
|
||||||
|
|
|
@ -50,6 +50,14 @@ func main() {
|
||||||
Port: config.Port,
|
Port: config.Port,
|
||||||
Auth: WarehostAuth{db: dbconnection},
|
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
|
// start ftp server
|
||||||
ftpServer := ftpd.NewServer(opt)
|
ftpServer := ftpd.NewServer(opt)
|
||||||
|
|
Reference in New Issue