Removed warnings from go staticcheck

This commit is contained in:
gezimbll
2023-11-03 12:20:48 -04:00
committed by Dan Christian Bogos
parent 529430bd4d
commit c2dacc42c1
97 changed files with 334 additions and 761 deletions

View File

@@ -55,28 +55,28 @@ func basicAuth(userList map[string]string) basicAuthMiddleware {
authHeader := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
if len(authHeader) != 2 {
utils.Logger.Warning("<BasicAuth> Missing authorization header value")
http.Error(w, "Not authorized", 401)
http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}
authHeaderDecoded, err := base64.StdEncoding.DecodeString(authHeader[1])
if err != nil {
utils.Logger.Warning("<BasicAuth> Unable to decode authorization header")
http.Error(w, err.Error(), 401)
http.Error(w, err.Error(), http.StatusUnauthorized)
return
}
userPass := strings.SplitN(string(authHeaderDecoded), ":", 2)
if len(userPass) != 2 {
utils.Logger.Warning("<BasicAuth> Unauthorized API access. Missing or extra credential components")
http.Error(w, "Not authorized", 401)
http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}
valid := verifyCredential(userPass[0], userPass[1], userList)
if !valid {
utils.Logger.Warning(fmt.Sprintf("<BasicAuth> Unauthorized API access by user '%s'", userPass[0]))
http.Error(w, "Not authorized", 401)
http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}

View File

@@ -68,7 +68,6 @@ func (cS *CoreService) Shutdown() {
utils.Logger.Info(fmt.Sprintf("<%s> shutdown initialized", utils.CoreS))
cS.StopChanMemProf()
utils.Logger.Info(fmt.Sprintf("<%s> shutdown complete", utils.CoreS))
return
}
// StopChanMemProf will stop the MemoryProfiling Channel in order to create

View File

@@ -244,7 +244,7 @@ func (s *Server) ServeHTTP(addr string, jsonRPCURL string, wsRPCURL string,
}
utils.Logger.Info(fmt.Sprintf("<HTTP> start listening at <%s>", addr))
if err := http.ListenAndServe(addr, s.httpMux); err != nil {
log.Println(fmt.Sprintf("<HTTP>Error: %s when listening ", err))
log.Printf("<HTTP>Error: %s when listening ", err)
shdChan.CloseOnce()
}
}
@@ -379,7 +379,7 @@ func loadTLSConfig(serverCrt, serverKey, caCert string, serverPolicy int,
}
if ok := rootCAs.AppendCertsFromPEM(ca); !ok {
utils.Logger.Crit(fmt.Sprintf("Cannot append certificate authority"))
utils.Logger.Crit("Cannot append certificate authority")
return config, errors.New("Cannot append certificate authority")
}
}
@@ -411,7 +411,7 @@ func (s *Server) serveCodecTLS(addr, codecName, serverCrt, serverKey, caCert str
}
listener, err := tls.Listen(utils.TCP, addr, config)
if err != nil {
log.Println(fmt.Sprintf("Error: %s when listening", err))
log.Printf("Error: %s when listening", err)
shdChan.CloseOnce()
return
}
@@ -483,7 +483,7 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
}
utils.Logger.Info(fmt.Sprintf("<HTTPS> start listening at <%s>", addr))
if err := httpSrv.ListenAndServeTLS(serverCrt, serverKey); err != nil {
log.Println(fmt.Sprintf("<HTTPS>Error: %s when listening ", err))
log.Printf("<HTTPS>Error: %s when listening ", err)
shdChan.CloseOnce()
}
}