func overrideGUIConfig(cfg config.GUIConfiguration, address, authentication, apikey string) config.GUIConfiguration { if address != "" { cfg.Enabled = true if !strings.Contains(address, "//") { // Assume just an IP was given. Don't touch he TLS setting. cfg.Address = address } else { parsed, err := url.Parse(address) if err != nil { l.Fatalln(err) } cfg.Address = parsed.Host switch parsed.Scheme { case "http": cfg.UseTLS = false case "https": cfg.UseTLS = true default: l.Fatalln("Unknown scheme:", parsed.Scheme) } } } if authentication != "" { authenticationParts := strings.SplitN(authentication, ":", 2) hash, err := bcrypt.GenerateFromPassword([]byte(authenticationParts[1]), 0) if err != nil { l.Fatalln("Invalid GUI password:"******"" { cfg.APIKey = apikey } return cfg }