From 1b89db4dff4ad3a72591ac661e94801792b5e338 Mon Sep 17 00:00:00 2001
From: Josh Bleecher Snyder
Date: Mon, 14 Feb 2022 17:28:52 -0800
Subject: [PATCH] tsweb: add DebugHandler.FlagSet
For runtime-modifiable values.
Signed-off-by: Josh Bleecher Snyder
---
cmd/tailscaled/depaware.txt | 3 +
tsweb/debug.go | 167 ++++++++++++++++++++++++++++++++++++
2 files changed, 170 insertions(+)
diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt
index 5ecec59dd..2e18d1f9b 100644
--- a/cmd/tailscaled/depaware.txt
+++ b/cmd/tailscaled/depaware.txt
@@ -353,6 +353,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
hash/fnv from gvisor.dev/gvisor/pkg/tcpip/network/ipv6+
hash/maphash from go4.org/mem
html from net/http/pprof+
+ html/template from tailscale.com/tsweb
io from bufio+
io/fs from crypto/rand+
io/ioutil from github.com/aws/aws-sdk-go-v2/aws/protocol/query+
@@ -391,6 +392,8 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
sync/atomic from context+
syscall from crypto/rand+
text/tabwriter from runtime/pprof
+ text/template from html/template
+ text/template/parse from html/template+
time from compress/gzip+
unicode from bytes+
unicode/utf16 from crypto/x509+
diff --git a/tsweb/debug.go b/tsweb/debug.go
index 54fd188cb..39a3bb25c 100644
--- a/tsweb/debug.go
+++ b/tsweb/debug.go
@@ -6,14 +6,20 @@ package tsweb
import (
"expvar"
+ "flag"
"fmt"
"html"
+ "html/template"
"io"
+ "log"
"net/http"
"net/http/pprof"
"net/url"
"os"
"runtime"
+ "sort"
+ "strings"
+ "sync"
"tailscale.com/version"
)
@@ -33,6 +39,9 @@ type DebugHandler struct {
kvs []func(io.Writer) // output one ... each, see KV()
urls []string // one ... block with link each
sections []func(io.Writer, *http.Request) // invoked in registration order prior to outputting
+
+{{if .Error}}
+Error: {{.Error}}
+{{end}}
+
+{{if .Modified}}
+Modified: {{.Modified}}
+{{end}}
+
+Modifiable runtime flags
+
+Warning! Modifying these values will take effect immediately and impact the running service
+
+
+
+