{{if
Role:
- {{if eq .ID $.Leader}}Leader{{else if .IsLearner}}Learner{{else}}Member{{end}}
+ {{if eq .ID $.Leader}}Leader{{else if .IsLearner}}Learner{{else if .IsWitness}}Witness{{else}}Member{{end}}
diff --git a/ui/ui_webserver.go b/ui/ui_webserver.go
index fda88cdb..f86aff61 100644
--- a/ui/ui_webserver.go
+++ b/ui/ui_webserver.go
@@ -4,6 +4,7 @@ import (
"crypto/rand"
"crypto/tls"
"encoding/hex"
+ "errors"
"fmt"
"html"
"html/template"
@@ -84,7 +85,7 @@ func render(w http.ResponseWriter, r *http.Request, model interface{}, content .
parsed, err = template.New(name).Funcs(funcsMap).ParseFS(templatesContent, content...)
} else {
- realFiles := []string{}
+ var realFiles []string
for _, c := range content {
realFiles = append(realFiles, filepath.Join("ui/", c))
}
@@ -226,7 +227,7 @@ func StartWebServer(errs chan<- error) error {
if data.HasLeader() {
clusterState = "healthy"
}
- serverID = data.GetServerID()
+ serverID = data.GetServerID().String()
_, err = data.RegisterClusterHealthListener(watchClusterHealth)
if err != nil {
@@ -237,9 +238,6 @@ func StartWebServer(errs chan<- error) error {
//https://blog.cloudflare.com/exposing-go-on-the-internet/
tlsConfig := &tls.Config{
- // Causes servers to use Go's default ciphersuite preferences,
- // which are tuned to avoid attacks. Does nothing on clients.
- PreferServerCipherSuites: true,
// Only use curves which have assembly implementations
CurvePreferences: []tls.CurveID{
tls.CurveP256,
@@ -369,7 +367,7 @@ func StartWebServer(errs chan<- error) error {
Handler: setSecurityHeaders(allRoutes),
}
- if err := HTTPSServer.ListenAndServeTLS(config.Values.ManagementUI.CertPath, config.Values.ManagementUI.KeyPath); err != nil && err != http.ErrServerClosed {
+ if err := HTTPSServer.ListenAndServeTLS(config.Values.ManagementUI.CertPath, config.Values.ManagementUI.KeyPath); err != nil && !errors.Is(err, http.ErrServerClosed) {
errs <- fmt.Errorf("TLS management listener failed: %v", err)
}
@@ -383,7 +381,7 @@ func StartWebServer(errs chan<- error) error {
IdleTimeout: 120 * time.Second,
Handler: setSecurityHeaders(allRoutes),
}
- if err := HTTPServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
+ if err := HTTPServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
errs <- fmt.Errorf("webserver management listener failed: %v", HTTPServer.ListenAndServe())
}
diff --git a/ui/users.go b/ui/users.go
index b6889e8d..a2954082 100644
--- a/ui/users.go
+++ b/ui/users.go
@@ -61,7 +61,7 @@ func manageUsers(w http.ResponseWriter, r *http.Request) {
return
}
- usersData := []UsersData{}
+ var usersData []UsersData
for _, u := range users {
devices, _ := ctrl.ListDevice(u.Username)
@@ -90,6 +90,7 @@ func manageUsers(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write(b)
+ return
case "PUT":
var action struct {
Action string `json:"action"`
@@ -133,6 +134,7 @@ func manageUsers(w http.ResponseWriter, r *http.Request) {
}
w.Write([]byte("OK"))
+ return
case "DELETE":
var usernames []string
@@ -160,6 +162,7 @@ func manageUsers(w http.ResponseWriter, r *http.Request) {
}
w.Write([]byte("OK"))
+ return
default:
http.NotFound(w, r)