diff --git a/cmd/derper/derper.go b/cmd/derper/derper.go index c726389c0..2ea77cbc3 100644 --- a/cmd/derper/derper.go +++ b/cmd/derper/derper.go @@ -12,8 +12,6 @@ "errors" "expvar" "flag" - "fmt" - "html" "io" "io/ioutil" "log" @@ -35,7 +33,6 @@ "tailscale.com/tsweb" "tailscale.com/types/key" "tailscale.com/types/wgkey" - "tailscale.com/version" ) var ( @@ -143,8 +140,7 @@ func main() { } expvar.Publish("derp", s.ExpVar()) - // Create our own mux so we don't expose /debug/ stuff to the world. - mux := tsweb.NewMux(debugHandler(s)) + mux := http.NewServeMux() mux.Handle("/derp", derphttp.Handler(s)) go refreshBootstrapDNSLoop() mux.HandleFunc("/bootstrap-dns", handleBootstrapDNS) @@ -164,6 +160,17 @@ func main() { io.WriteString(w, "

Debug info at /debug/.

\n") } })) + debug := tsweb.Debugger(mux) + debug.KV("TLS hostname", *hostname) + debug.KV("Mesh key", s.HasMeshKey()) + debug.Handle("check", "Consistency check", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + err := s.ConsistencyCheck() + if err != nil { + http.Error(w, err.Error(), 500) + } else { + io.WriteString(w, "derp.Server ConsistencyCheck okay") + } + })) if *runSTUN { go serveSTUN() @@ -217,39 +224,6 @@ func main() { } } -func debugHandler(s *derp.Server) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.RequestURI == "/debug/check" { - err := s.ConsistencyCheck() - if err != nil { - http.Error(w, err.Error(), 500) - } else { - io.WriteString(w, "derp.Server ConsistencyCheck okay") - } - return - } - f := func(format string, args ...interface{}) { fmt.Fprintf(w, format, args...) } - f(` -

DERP debug

-