sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

[BUGFIX] ftp join and

This commit is contained in:
Martin Geno 2017-05-05 23:03:42 +02:00
parent 80fab46918
commit e7b365df5e
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
3 changed files with 17 additions and 4 deletions

View File

@ -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

View 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 {

View File

@ -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)