summaryrefslogtreecommitdiffhomepage
path: root/ipn/localapi/localapi.go
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2022-10-18 17:29:54 -0400
committerAndrew Dunham <andrew@du.nham.ca>2022-10-21 11:08:39 -0400
commitd8b9698eaaaf40ea857ed888ffe5b7ac99575c8f (patch)
tree6831136356d8ef3006b6736a37ec48e8697fa576 /ipn/localapi/localapi.go
parent95f630ced019a6d90b28ad2e682740fe3cb1830c (diff)
downloadtailscale-andrew/debug-subnet-router.tar.xz
tailscale-andrew/debug-subnet-router.zip
Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Id806c5c62b5097d9a5a7600324349ce7692d4d55
Diffstat (limited to 'ipn/localapi/localapi.go')
-rw-r--r--ipn/localapi/localapi.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/ipn/localapi/localapi.go b/ipn/localapi/localapi.go
index bfdd6a15a..fe34fdc44 100644
--- a/ipn/localapi/localapi.go
+++ b/ipn/localapi/localapi.go
@@ -59,6 +59,7 @@ var handler = map[string]localAPIHandler{
"check-prefs": (*Handler).serveCheckPrefs,
"component-debug-logging": (*Handler).serveComponentDebugLogging,
"debug": (*Handler).serveDebug,
+ "debug-subnet-route": (*Handler).serveDebugSubnetRoute,
"derpmap": (*Handler).serveDERPMap,
"dial": (*Handler).serveDial,
"file-targets": (*Handler).serveFileTargets,
@@ -417,6 +418,26 @@ func (h *Handler) serveComponentDebugLogging(w http.ResponseWriter, r *http.Requ
json.NewEncoder(w).Encode(res)
}
+func (h *Handler) serveDebugSubnetRoute(w http.ResponseWriter, r *http.Request) {
+ if !h.PermitWrite {
+ http.Error(w, "debug access denied", http.StatusForbidden)
+ return
+ }
+ addr := r.FormValue("addr")
+ res, err := h.b.DebugSubnetRoute(r.Context(), addr)
+ w.Header().Set("Content-Type", "application/json")
+ if err != nil {
+ json.NewEncoder(w).Encode(struct {
+ Errors []string
+ }{
+ Errors: []string{err.Error()},
+ })
+ return
+ }
+
+ json.NewEncoder(w).Encode(res)
+}
+
// serveProfileFunc is the implementation of Handler.serveProfile, after auth,
// for platforms where we want to link it in.
var serveProfileFunc func(http.ResponseWriter, *http.Request)