cmd/tailscaled, ipn/localapi, util/eventbus: don't link in regexp when debug is omitted

Saves 442 KB. Lock it with a new min test.

Updates #12614

Change-Id: Ia7bf6f797b6cbf08ea65419ade2f359d390f8e91
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-09-30 11:54:16 -07:00
committed by Brad Fitzpatrick
parent 840c7668e2
commit 9386a101d8
11 changed files with 100 additions and 78 deletions
+19 -2
View File
@@ -1,7 +1,7 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:build go1.19
//go:build !ts_omit_debug
package main
@@ -16,6 +16,7 @@ import (
"log"
"net/http"
"net/http/httptrace"
"net/http/pprof"
"net/url"
"os"
"time"
@@ -39,7 +40,23 @@ var debugArgs struct {
portmap bool
}
var debugModeFunc = debugMode // so it can be addressable
func init() {
debugModeFunc := debugMode // to be addressable
subCommands["debug"] = &debugModeFunc
hookNewDebugMux.Set(newDebugMux)
}
func newDebugMux() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/debug/metrics", servePrometheusMetrics)
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
return mux
}
func debugMode(args []string) error {
fs := flag.NewFlagSet("debug", flag.ExitOnError)