tailcfg: move LogHeapPprof from Debug to c2n [capver 69]

And delete Debug.GoroutineDumpURL, which was already in c2n.

Updates #8923

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-16 20:03:57 -07:00
committed by Brad Fitzpatrick
parent 24509f8b22
commit 239ad57446
10 changed files with 32 additions and 119 deletions

View File

@@ -25,6 +25,8 @@ import (
"tailscale.com/version/distro"
)
var c2nLogHeap func(http.ResponseWriter, *http.Request) // non-nil on most platforms (c2n_pprof.go)
func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
writeJSON := func(v any) {
w.Header().Set("Content-Type", "application/json")
@@ -70,6 +72,13 @@ func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
res.Error = err.Error()
}
writeJSON(res)
case "/debug/logheap":
if c2nLogHeap != nil {
c2nLogHeap(w, r)
} else {
http.Error(w, "not implemented", http.StatusNotImplemented)
return
}
case "/ssh/usernames":
var req tailcfg.C2NSSHUsernamesRequest
if r.Method == "POST" {

17
ipn/ipnlocal/c2n_pprof.go Normal file
View File

@@ -0,0 +1,17 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:build !js && !wasm
package ipnlocal
import (
"net/http"
"runtime/pprof"
)
func init() {
c2nLogHeap = func(w http.ResponseWriter, r *http.Request) {
pprof.WriteHeapProfile(w)
}
}