1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-08-19 13:48:20 +02:00

Add comment, improve error message

This commit is contained in:
Mustafa Enes Batur 2025-06-05 14:41:30 +02:00
parent 7610e8c398
commit fe97600c88

View File

@ -210,18 +210,19 @@ func (ns *noiseServer) NoisePollNetMapHandler(
} }
node, err := ns.headscale.db.GetNodeByMachineKey(ns.machineKey) node, err := ns.headscale.db.GetNodeByMachineKey(ns.machineKey)
if err != nil { if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
httpError(writer, NewHTTPError(http.StatusNotFound, "node not found", nil)) httpError(writer, NewHTTPError(http.StatusNotFound, "node not found", nil))
return return
} }
httpError(writer, err) httpError(writer, err)
return return
} }
// Ensure the NodeKey in the request matches the one associated with the machine key from the Noise session
if node.NodeKey != mapRequest.NodeKey { if node.NodeKey != mapRequest.NodeKey {
httpError(writer, NewHTTPError(http.StatusNotFound, "node does not belong to machine key", nil)) httpError(writer, NewHTTPError(http.StatusNotFound, "node key in request does not match the one associated with this machine key", nil))
return return
} }
@ -274,6 +275,7 @@ func (ns *noiseServer) NoiseRegistrationHandler(
return &regReq, resp return &regReq, resp
} else { } else {
} }
return &regReq, regErr(err) return &regReq, regErr(err)
} }