*(global): refactoring - moved runtime properties to Context

This commit is contained in:
Andrey Meshkov
2020-02-12 15:53:36 +03:00
parent d8d48c5386
commit ae2990582d
16 changed files with 141 additions and 131 deletions

View File

@@ -302,7 +302,7 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
var curConfig configuration
copyInstallSettings(&curConfig, &config)
config.firstRun = false
Context.firstRun = false
config.BindHost = newSettings.Web.IP
config.BindPort = newSettings.Web.Port
config.DNS.BindHost = newSettings.DNS.IP
@@ -317,7 +317,7 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
}
}
if err != nil || err2 != nil {
config.firstRun = true
Context.firstRun = true
copyInstallSettings(&config, &curConfig)
if err != nil {
httpError(w, http.StatusInternalServerError, "Couldn't initialize DNS server: %s", err)
@@ -329,11 +329,11 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
u := User{}
u.Name = newSettings.Username
config.auth.UserAdd(&u, newSettings.Password)
Context.auth.UserAdd(&u, newSettings.Password)
err = config.write()
if err != nil {
config.firstRun = true
Context.firstRun = true
copyInstallSettings(&config, &curConfig)
httpError(w, http.StatusInternalServerError, "Couldn't write config: %s", err)
return