mirror of
https://github.com/tailscale/tailscale.git
synced 2026-03-26 15:51:28 +01:00
ipn/localapi: expose local node service details over api
This commit is contained in:
parent
d5715bd606
commit
c95e317aeb
@ -85,6 +85,7 @@ var handler = map[string]LocalAPIHandler{
|
||||
"set-expiry-sooner": (*Handler).serveSetExpirySooner,
|
||||
"shutdown": (*Handler).serveShutdown,
|
||||
"start": (*Handler).serveStart,
|
||||
"service-details": (*Handler).serveServiceDetails,
|
||||
"status": (*Handler).serveStatus,
|
||||
"whois": (*Handler).serveWhoIs,
|
||||
}
|
||||
@ -1728,3 +1729,23 @@ func (h *Handler) serveGetAppcRouteInfo(w http.ResponseWriter, r *http.Request)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(res)
|
||||
}
|
||||
|
||||
// serveServiceDetails handles GET /localapi/v0/service-details and returns the
|
||||
// list of VIP services that the control plane has approved this node to serve,
|
||||
// including their names, assigned IP addresses, ports, and annotations (e.g.
|
||||
// proxy service configuration). Returns null if no service details are present.
|
||||
func (h *Handler) serveServiceDetails(w http.ResponseWriter, r *http.Request) {
|
||||
if !h.PermitRead {
|
||||
http.Error(w, "service-details access denied", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
if r.Method != httpm.GET {
|
||||
http.Error(w, "only GET allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
details := h.b.NetMap().GetVIPServiceDetails()
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
e := json.NewEncoder(w)
|
||||
e.SetIndent("", "\t")
|
||||
e.Encode(details)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user