Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agent): expose HTTP debug server over tailnet API #12582

Merged
merged 3 commits into from
Mar 14, 2024

Conversation

johnstcn
Copy link
Member

Related to #12161
Exposes the agent magicsock handler over tailnet so you can just dial it over an agent conn.

@johnstcn johnstcn self-assigned this Mar 13, 2024
@@ -36,6 +36,8 @@ func (a *agent) apiHandler() http.Handler {
cacheDuration: cacheDuration,
}
r.Get("/api/v0/listening-ports", lp.handler)
r.Get("/debug/magicsock", a.HandleHTTPDebugMagicsock)
r.Get("/debug/magicsock/debug-logging/{state}", a.HandleHTTPMagicsockDebugLoggingState)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: /debug/magicsock/debug... sounds weird. Maybe POST /debug/magicsock/enable-logger instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep this the same for consistency purposes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

agent/agent.go Outdated
func (a *agent) HandleHTTPDebugMagicsock(w http.ResponseWriter, r *http.Request) {
network, ok := a.requireNetwork()
if !ok {
w.WriteHeader(http.StatusNotFound)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that be a different HTTP status? 503?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make the arguemnt yeah, but I didn't see a huge need to change it in this PR. Since it's a debug endpoint though, it's probably fine to change.

@mtojek mtojek self-requested a review March 14, 2024 09:17
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@johnstcn johnstcn merged commit 3b40687 into main Mar 14, 2024
23 checks passed
@johnstcn johnstcn deleted the cj/agent-debug-magicsock branch March 14, 2024 10:02
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants