mirror of https://github.com/statping/statping
commit
91296029b9
|
@ -1,3 +1,6 @@
|
|||
# 0.90.60 (07-15-2020)
|
||||
- Added LETSENCRYPT_ENABLE (boolean) env to enable/disable letsencrypt SSL
|
||||
|
||||
# 0.90.59 (07-14-2020)
|
||||
- Added LetsEncrypt SSL Generator by using LETSENCRYPT_HOST and LETSENCRYPT_EMAIL envs.
|
||||
- Modified JWT token key to be sha256 of API Secret
|
||||
|
|
|
@ -56,7 +56,7 @@ func RunHTTPServer() error {
|
|||
resetCookies()
|
||||
httpError = make(chan error)
|
||||
|
||||
if utils.Params.GetString("LETSENCRYPT_HOST") != "" {
|
||||
if utils.Params.GetBool("LETSENCRYPT_ENABLE") {
|
||||
go startLetsEncryptServer(ip)
|
||||
} else if usingSSL {
|
||||
go startSSLServer(ip)
|
||||
|
|
|
@ -64,8 +64,6 @@ func letsEncryptCert() (*tls.Config, error) {
|
|||
}
|
||||
|
||||
func startLetsEncryptServer(ip string) {
|
||||
log.Infoln("Starting SSL with LetsEncrypt")
|
||||
|
||||
log.Infoln("Starting LetEncrypt redirect server on port 80")
|
||||
go http.ListenAndServe(":80", http.HandlerFunc(simplecert.Redirect))
|
||||
|
||||
|
|
|
@ -57,29 +57,43 @@ func LoadConfigs(cfgFile string) (*DbConfig, error) {
|
|||
p.Set("API_SECRET", db.ApiSecret)
|
||||
}
|
||||
if db.Language != "" {
|
||||
p.Set("LANGUAGE", "en")
|
||||
p.Set("LANGUAGE", db.Language)
|
||||
}
|
||||
if db.SendReports {
|
||||
p.Set("ALLOW_REPORTS", true)
|
||||
}
|
||||
if db.LetsEncryptEmail != "" {
|
||||
p.Set("LETSENCRYPT_EMAIL", db.LetsEncryptEmail)
|
||||
}
|
||||
if db.LetsEncryptHost != "" {
|
||||
p.Set("LETSENCRYPT_HOST", db.LetsEncryptHost)
|
||||
}
|
||||
if db.LetsEncryptEnable {
|
||||
p.Set("LETSENCRYPT_ENABLE", db.LetsEncryptEnable)
|
||||
}
|
||||
|
||||
configs := &DbConfig{
|
||||
DbConn: p.GetString("DB_CONN"),
|
||||
DbHost: p.GetString("DB_HOST"),
|
||||
DbUser: p.GetString("DB_USER"),
|
||||
DbPass: p.GetString("DB_PASS"),
|
||||
DbData: p.GetString("DB_DATABASE"),
|
||||
DbPort: p.GetInt("DB_PORT"),
|
||||
Project: p.GetString("NAME"),
|
||||
Description: p.GetString("DESCRIPTION"),
|
||||
Domain: p.GetString("DOMAIN"),
|
||||
Email: p.GetString("EMAIL"),
|
||||
Username: p.GetString("ADMIN_USER"),
|
||||
Password: p.GetString("ADMIN_PASSWORD"),
|
||||
Location: utils.Directory,
|
||||
SqlFile: p.GetString("SQL_FILE"),
|
||||
Language: p.GetString("LANGUAGE"),
|
||||
SendReports: p.GetBool("ALLOW_REPORTS"),
|
||||
DbConn: p.GetString("DB_CONN"),
|
||||
DbHost: p.GetString("DB_HOST"),
|
||||
DbUser: p.GetString("DB_USER"),
|
||||
DbPass: p.GetString("DB_PASS"),
|
||||
DbData: p.GetString("DB_DATABASE"),
|
||||
DbPort: p.GetInt("DB_PORT"),
|
||||
Project: p.GetString("NAME"),
|
||||
Description: p.GetString("DESCRIPTION"),
|
||||
Domain: p.GetString("DOMAIN"),
|
||||
Email: p.GetString("EMAIL"),
|
||||
Username: p.GetString("ADMIN_USER"),
|
||||
Password: p.GetString("ADMIN_PASSWORD"),
|
||||
Location: utils.Directory,
|
||||
SqlFile: p.GetString("SQL_FILE"),
|
||||
Language: p.GetString("LANGUAGE"),
|
||||
SendReports: p.GetBool("ALLOW_REPORTS"),
|
||||
LetsEncryptEnable: p.GetBool("LETSENCRYPT_ENABLE"),
|
||||
}
|
||||
if configs.LetsEncryptEnable {
|
||||
configs.LetsEncryptHost = p.GetString("LETSENCRYPT_HOST")
|
||||
configs.LetsEncryptEmail = p.GetString("LETSENCRYPT_EMAIL")
|
||||
}
|
||||
log.WithFields(utils.ToFields(configs)).Debugln("read config file: " + cfgFile)
|
||||
|
||||
|
|
|
@ -6,26 +6,29 @@ const SqliteFilename = "statping.db"
|
|||
|
||||
// DbConfig struct is used for the Db connection and creates the 'config.yml' file
|
||||
type DbConfig struct {
|
||||
DbConn string `yaml:"connection" json:"connection"`
|
||||
DbHost string `yaml:"host" json:"-"`
|
||||
DbUser string `yaml:"user" json:"-"`
|
||||
DbPass string `yaml:"password" json:"-"`
|
||||
DbData string `yaml:"database" json:"-"`
|
||||
DbPort int `yaml:"port" json:"-"`
|
||||
ApiSecret string `yaml:"api_secret" json:"-"`
|
||||
Language string `yaml:"language" json:"language"`
|
||||
SendReports bool `yaml:"send_reports" json:"send_reports"`
|
||||
Project string `yaml:"-" json:"-"`
|
||||
Description string `yaml:"-" json:"-"`
|
||||
Domain string `yaml:"-" json:"-"`
|
||||
Username string `yaml:"-" json:"-"`
|
||||
Password string `yaml:"-" json:"-"`
|
||||
Email string `yaml:"-" json:"-"`
|
||||
Error error `yaml:"-" json:"-"`
|
||||
Location string `yaml:"location" json:"-"`
|
||||
SqlFile string `yaml:"sqlfile,omitempty" json:"-"`
|
||||
LocalIP string `yaml:"-" json:"-"`
|
||||
filename string `yaml:"-" json:"-"`
|
||||
DbConn string `yaml:"connection" json:"connection"`
|
||||
DbHost string `yaml:"host" json:"-"`
|
||||
DbUser string `yaml:"user" json:"-"`
|
||||
DbPass string `yaml:"password" json:"-"`
|
||||
DbData string `yaml:"database" json:"-"`
|
||||
DbPort int `yaml:"port" json:"-"`
|
||||
ApiSecret string `yaml:"api_secret" json:"-"`
|
||||
Language string `yaml:"language" json:"language"`
|
||||
SendReports bool `yaml:"send_reports" json:"send_reports"`
|
||||
Project string `yaml:"-" json:"-"`
|
||||
Description string `yaml:"-" json:"-"`
|
||||
Domain string `yaml:"-" json:"-"`
|
||||
Username string `yaml:"-" json:"-"`
|
||||
Password string `yaml:"-" json:"-"`
|
||||
Email string `yaml:"-" json:"-"`
|
||||
Error error `yaml:"-" json:"-"`
|
||||
Location string `yaml:"location" json:"-"`
|
||||
SqlFile string `yaml:"sqlfile,omitempty" json:"-"`
|
||||
LetsEncryptHost string `yaml:"letsencrypt_host,omitempty" json:"letsencrypt_host"`
|
||||
LetsEncryptEmail string `yaml:"letsencrypt_email,omitempty" json:"letsencrypt_email"`
|
||||
LetsEncryptEnable bool `yaml:"letsencrypt_enable" json:"letsencrypt_enable"`
|
||||
LocalIP string `yaml:"-" json:"-"`
|
||||
filename string `yaml:"-" json:"-"`
|
||||
|
||||
Db database.Database `yaml:"-" json:"-"`
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ func InitEnvs() {
|
|||
Params.SetDefault("LETSENCRYPT_HOST", "")
|
||||
Params.SetDefault("LETSENCRYPT_EMAIL", "")
|
||||
Params.SetDefault("LETSENCRYPT_LOCAL", false)
|
||||
Params.SetDefault("LETSENCRYPT_ENABLE", false)
|
||||
Params.SetDefault("LOGS_MAX_COUNT", 5)
|
||||
Params.SetDefault("LOGS_MAX_AGE", 28)
|
||||
Params.SetDefault("LOGS_MAX_SIZE", 16)
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.90.59
|
||||
0.90.60
|
||||
|
|
Loading…
Reference in New Issue