diff options
| author | Andrew Dunham <andrew@du.nham.ca> | 2022-10-18 17:29:54 -0400 |
|---|---|---|
| committer | Andrew Dunham <andrew@du.nham.ca> | 2022-10-21 11:08:39 -0400 |
| commit | d8b9698eaaaf40ea857ed888ffe5b7ac99575c8f (patch) | |
| tree | 6831136356d8ef3006b6736a37ec48e8697fa576 /ipn/localapi | |
| parent | 95f630ced019a6d90b28ad2e682740fe3cb1830c (diff) | |
| download | tailscale-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')
| -rw-r--r-- | ipn/localapi/localapi.go | 21 |
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) |
