api: expose node endpoints on GET /api/v1/node#3181
Open
bigbozza wants to merge 1 commit into
Open
Conversation
Closed
2 tasks
|
This is an interesting pull request to provide more information at least that can be used in web interfaces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #2152 Related: #2272
Summary
The headscale database already persists each node's current endpoints ([]netip.AddrPort) via GORM JSON serialisation, populated from UpdateNodeFromMapRequest. However, this field was not surfaced in the REST API response, making it unavailable to operators building external tooling (network maps, dashboards, audit logs).
Change
Added repeated string endpoints = 27 to proto/headscale/v1/node.proto (new field number, fully wire-compatible; the old field 16 comment is preserved)
Added EndpointsAsString() []string helper on types.Node to convert []netip.AddrPort to strings
Populated Endpoints in the v1.Node proto conversion, so both GetNode and ListNodes return the field
Regenerated node.pb.go and headscale.swagger.json via buf generate
Added TestGetNode_IncludesEndpoints in grpcv1_test.go that persists endpoints via UpdateNodeFromMapRequest and asserts GetNode returns them; test passes
Use case
Operators running external tooling against the headscale API currently have no way to retrieve a node's active endpoints without querying the database directly. This change makes the information available through the existing REST surface with no breaking changes.
Maintenance
The field is derived entirely from the existing types.Node.Endpoints value; no new persistence, migration, or external dependency is introduced.