feat: add debug server for tailnet coordinators (#5861)

Implements a Tailscale-like debug server for our in-memory coordinator. This should provide some visibility into why connections could be failing.
Resolves: https://github.com/coder/coder/issues/5845

![image](https://user-images.githubusercontent.com/6332295/214680832-2724d633-2d54-44d6-a7ce-5841e5824ee5.png)
This commit is contained in:
Colin Adler
2023-01-25 21:27:36 +00:00
committed by GitHub
parent 8830ddfd56
commit 1cd5f38cb0
16 changed files with 261 additions and 34 deletions
+19
View File
@@ -613,6 +613,25 @@ func New(options *Options) *API {
r.Get("/", api.workspaceApplicationAuth)
})
})
r.Route("/debug", func(r chi.Router) {
r.Use(
apiKeyMiddleware,
// Ensure only owners can access debug endpoints.
func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if !api.Authorize(r, rbac.ActionRead, rbac.ResourceDebugInfo) {
httpapi.ResourceNotFound(rw)
return
}
next.ServeHTTP(rw, r)
})
},
)
r.Get("/coordinator", api.debugCoordinator)
})
})
if options.SwaggerEndpoint {