Update dependencies and fix some linter warnings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
//go:build !embed
|
||||
// +build !embed
|
||||
|
||||
package web
|
||||
@@ -21,7 +22,7 @@ func (s *Server) IndexHandler(frontendDir string) http.HandlerFunc {
|
||||
fname := filepath.Join(frontendDir, r.URL.Path)
|
||||
_, err := os.Stat(fname)
|
||||
if os.IsNotExist(err) {
|
||||
serveIndex(frontendDir).ServeHTTP(w, r)
|
||||
s.serveIndex(frontendDir).ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
fs.ServeHTTP(w, r)
|
||||
@@ -29,7 +30,7 @@ func (s *Server) IndexHandler(frontendDir string) http.HandlerFunc {
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func serveIndex(frontendDir string) http.HandlerFunc {
|
||||
func (s *Server) serveIndex(frontendDir string) http.HandlerFunc {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
fname := filepath.Join(frontendDir, "index.html")
|
||||
f, err := os.Open(fname)
|
||||
@@ -38,7 +39,9 @@ func serveIndex(frontendDir string) http.HandlerFunc {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
io.Copy(w, f)
|
||||
if _, err := io.Copy(w, f); err != nil {
|
||||
s.ServerLogger.Warnw("Error writing frontend to client.", "err", err)
|
||||
}
|
||||
}
|
||||
return fn
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ func NewServer(cfg config.FrontendConfig, hs *ssh.HoneypotServer, store store.Lo
|
||||
s.RegisterOnShutdown(func() {
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
s.httpRedirectServer.Shutdown(timeoutCtx)
|
||||
s.httpRedirectServer.Shutdown(timeoutCtx) // nolint: errcheck
|
||||
})
|
||||
s.Addr = ":443"
|
||||
|
||||
@@ -151,6 +151,7 @@ func (s *Server) closeAttemptListener(id string) {
|
||||
close(ch)
|
||||
delete(s.attemptListeners, id)
|
||||
}
|
||||
|
||||
func (s *Server) HandlerAttemptStream(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
@@ -216,6 +217,7 @@ func (s *Server) HandlerStats(w http.ResponseWriter, r *http.Request) {
|
||||
s.ServerLogger.Debugf("Error encoding or writing response", "remote_ip", r.RemoteAddr, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
queryType := r.URL.Query().Get("type")
|
||||
@@ -280,7 +282,7 @@ func (s *Server) HandlerHealth(w http.ResponseWriter, r *http.Request) {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, fmt.Sprintf("Health error: %s", err))
|
||||
return
|
||||
}
|
||||
w.Write([]byte(`{}`))
|
||||
w.Write([]byte(`{}`)) // nolint: errcheck
|
||||
}
|
||||
|
||||
type APIErrorResponse struct {
|
||||
|
Reference in New Issue
Block a user