mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
ipn/localapi: add set-gui-visible endpoint
Updates tailscale/corp#17859 Provides a local API endpoint to be called from the GUI to inform the backend when the client menu is opened or closed. cc @bradfitz Signed-off-by: Andrea Gottardo <andrea@gottardo.me> Signed-off-by: Andrea Gottardo <andrea@tailscale.com> Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
This commit is contained in:
parent
00373f07ac
commit
0cb86468ca
@ -110,6 +110,7 @@
|
|||||||
"serve-config": (*Handler).serveServeConfig,
|
"serve-config": (*Handler).serveServeConfig,
|
||||||
"set-dns": (*Handler).serveSetDNS,
|
"set-dns": (*Handler).serveSetDNS,
|
||||||
"set-expiry-sooner": (*Handler).serveSetExpirySooner,
|
"set-expiry-sooner": (*Handler).serveSetExpirySooner,
|
||||||
|
"set-gui-visible": (*Handler).serveSetGUIVisible,
|
||||||
"tailfs/fileserver-address": (*Handler).serveTailFSFileServerAddr,
|
"tailfs/fileserver-address": (*Handler).serveTailFSFileServerAddr,
|
||||||
"tailfs/shares": (*Handler).serveShares,
|
"tailfs/shares": (*Handler).serveShares,
|
||||||
"start": (*Handler).serveStart,
|
"start": (*Handler).serveStart,
|
||||||
@ -1904,6 +1905,27 @@ func (h *Handler) serveTKAStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Write(j)
|
w.Write(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handler) serveSetGUIVisible(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != httpm.POST {
|
||||||
|
http.Error(w, "use POST", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type setGUIVisibleRequest struct {
|
||||||
|
IsVisible bool // whether the Tailscale client UI is now presented to the user
|
||||||
|
SessionID string // the last SessionID sent to the client in ipn.Notify.SessionID
|
||||||
|
}
|
||||||
|
var req setGUIVisibleRequest
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
http.Error(w, "invalid JSON body", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(bradfitz): use `req.IsVisible == true` to flush netmap
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handler) serveTKASign(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) serveTKASign(w http.ResponseWriter, r *http.Request) {
|
||||||
if !h.PermitWrite {
|
if !h.PermitWrite {
|
||||||
http.Error(w, "lock sign access denied", http.StatusForbidden)
|
http.Error(w, "lock sign access denied", http.StatusForbidden)
|
||||||
|
Loading…
Reference in New Issue
Block a user