1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00

Some linting fixes

This commit is contained in:
Juan Font Alonso 2022-08-14 12:40:22 +02:00
parent ade1b73779
commit 3bea20850a
2 changed files with 9 additions and 7 deletions

View File

@ -113,6 +113,7 @@ func (h *Headscale) getNoiseConnection(
if err != nil { if err != nil {
log.Error().Caller().Err(err).Msgf("Hijack failed") log.Error().Caller().Err(err).Msgf("Hijack failed")
http.Error(writer, "HTTP does not support general TCP support", http.StatusInternalServerError) http.Error(writer, "HTTP does not support general TCP support", http.StatusInternalServerError)
return nil, errCannotHijack return nil, errCannotHijack
} }
if err := conn.Flush(); err != nil { if err := conn.Flush(); err != nil {
@ -123,12 +124,12 @@ func (h *Headscale) getNoiseConnection(
netConn = netutil.NewDrainBufConn(netConn, conn.Reader) netConn = netutil.NewDrainBufConn(netConn, conn.Reader)
nc, err := controlbase.Server(req.Context(), netConn, *h.noisePrivateKey, init) noiseConn, err := controlbase.Server(req.Context(), netConn, *h.noisePrivateKey, init)
if err != nil { if err != nil {
netConn.Close() netConn.Close()
return nil, errNoiseHandshakeFailed return nil, errNoiseHandshakeFailed
} }
return nc, nil return noiseConn, nil
} }

View File

@ -22,6 +22,7 @@ func (h *Headscale) NoiseRegistrationHandler(
log.Trace().Caller().Msgf("Noise registration handler for client %s", req.RemoteAddr) log.Trace().Caller().Msgf("Noise registration handler for client %s", req.RemoteAddr)
if req.Method != http.MethodPost { if req.Method != http.MethodPost {
http.Error(writer, "Wrong method", http.StatusMethodNotAllowed) http.Error(writer, "Wrong method", http.StatusMethodNotAllowed)
return return
} }
body, _ := io.ReadAll(req.Body) body, _ := io.ReadAll(req.Body)
@ -296,8 +297,8 @@ func (h *Headscale) handleNoiseAuthKey(
} }
func (h *Headscale) handleNoiseNodeValidRegistration( func (h *Headscale) handleNoiseNodeValidRegistration(
w http.ResponseWriter, writer http.ResponseWriter,
r *http.Request, req *http.Request,
machine Machine, machine Machine,
) { ) {
resp := tailcfg.RegisterResponse{} resp := tailcfg.RegisterResponse{}
@ -314,9 +315,9 @@ func (h *Headscale) handleNoiseNodeValidRegistration(
machineRegistrations.WithLabelValues("update", "web", "success", machine.Namespace.Name). machineRegistrations.WithLabelValues("update", "web", "success", machine.Namespace.Name).
Inc() Inc()
w.Header().Set("Content-Type", "application/json") writer.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK) writer.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(resp) json.NewEncoder(writer).Encode(resp)
} }
func (h *Headscale) handleNoiseMachineRegistrationNew( func (h *Headscale) handleNoiseMachineRegistrationNew(