diff --git a/hscontrol/handlers.go b/hscontrol/handlers.go index b4bcd022..d52b4d50 100644 --- a/hscontrol/handlers.go +++ b/hscontrol/handlers.go @@ -101,6 +101,7 @@ func (h *Headscale) handleVerifyRequest( // Check if any node has the requested NodeKey var nodeKeyFound bool + for _, node := range nodes.All() { if node.NodeKey() == derpAdmitClientRequest.NodePublic { nodeKeyFound = true @@ -131,6 +132,7 @@ func (h *Headscale) VerifyHandler( httpError(writer, err) return } + writer.Header().Set("Content-Type", "application/json") } @@ -152,6 +154,7 @@ func (h *Headscale) KeyHandler( resp := tailcfg.OverTLSPublicKeyResponse{ PublicKey: h.noisePrivateKey.Public(), } + writer.Header().Set("Content-Type", "application/json") json.NewEncoder(writer).Encode(resp) @@ -174,13 +177,14 @@ func (h *Headscale) HealthHandler( if err != nil { writer.WriteHeader(http.StatusInternalServerError) + res.Status = "fail" } json.NewEncoder(writer).Encode(res) } - - if err := h.state.PingDB(req.Context()); err != nil { + err := h.state.PingDB(req.Context()) + if err != nil { respond(err) return @@ -195,6 +199,7 @@ func (h *Headscale) RobotsHandler( ) { writer.Header().Set("Content-Type", "text/plain") writer.WriteHeader(http.StatusOK) + _, err := writer.Write([]byte("User-agent: *\nDisallow: /")) if err != nil { log.Error(). @@ -214,7 +219,8 @@ func (h *Headscale) VersionHandler( writer.WriteHeader(http.StatusOK) versionInfo := types.GetVersionInfo() - if err := json.NewEncoder(writer).Encode(versionInfo); err != nil { + err := json.NewEncoder(writer).Encode(versionInfo) + if err != nil { log.Error(). Caller(). Err(err). @@ -273,12 +279,14 @@ func (a *AuthProviderWeb) RegisterHandler( } //go:embed assets/favicon.png -var favicon[] byte +var favicon []byte + func FaviconHandler(writer http.ResponseWriter, req *http.Request) { writer.Header().Set("Content-Type", "image/png") http.ServeContent(writer, req, "favicon.ico", time.Unix(0, 0), bytes.NewReader(favicon)) } -// Returns a blank page with favicon linked + +// Returns a blank page with favicon linked. func BlankHandler(writer http.ResponseWriter, res *http.Request) { writer.Header().Set("Content-Type", "text/html; charset=utf-8") io.WriteString(writer, ` @@ -286,4 +294,4 @@ func BlankHandler(writer http.ResponseWriter, res *http.Request) { `) -} \ No newline at end of file +}