summaryrefslogtreecommitdiffhomepage
path: root/ipn/localapi/localapi.go
diff options
context:
space:
mode:
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)