noise: reject non-HEAD on PingResponseHandler

chi routes only HEAD to the handler, but assert explicitly so a
future router config change cannot silently accept GET/POST and leak
latency bytes or side-effects.

Updates #3157
This commit is contained in:
Kristoffer Dalby 2026-04-17 05:48:43 +00:00
parent f3eb9a7bba
commit 5a7cafdf85
2 changed files with 37 additions and 0 deletions

View file

@ -302,6 +302,11 @@ func (h *Headscale) PingResponseHandler(
writer http.ResponseWriter,
req *http.Request,
) {
if req.Method != http.MethodHead {
http.Error(writer, "method not allowed", http.StatusMethodNotAllowed)
return
}
pingID := req.URL.Query().Get("id")
if pingID == "" {
http.Error(writer, "missing ping ID", http.StatusBadRequest)