mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-21 06:01:42 +00:00
ipn/localapi: remove webclient endpoint
Managing starting/stopping tailscaled web client purely via setting the RunWebClient pref. Updates tailscale/corp#14335 Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:
parent
b370274b29
commit
da31ce3a64
@ -66,7 +66,6 @@ var handler = map[string]localAPIHandler{
|
|||||||
"file-put/": (*Handler).serveFilePut,
|
"file-put/": (*Handler).serveFilePut,
|
||||||
"files/": (*Handler).serveFiles,
|
"files/": (*Handler).serveFiles,
|
||||||
"profiles/": (*Handler).serveProfiles,
|
"profiles/": (*Handler).serveProfiles,
|
||||||
"webclient/": (*Handler).serveWebClient,
|
|
||||||
|
|
||||||
// The other /localapi/v0/NAME handlers are exact matches and contain only NAME
|
// The other /localapi/v0/NAME handlers are exact matches and contain only NAME
|
||||||
// without a trailing slash:
|
// without a trailing slash:
|
||||||
@ -2243,43 +2242,6 @@ func (h *Handler) serveDebugWebClient(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) serveWebClient(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if !h.PermitWrite {
|
|
||||||
http.Error(w, "access denied", http.StatusForbidden)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if r.Method != httpm.POST {
|
|
||||||
http.Error(w, "use POST", http.StatusMethodNotAllowed)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch r.URL.Path {
|
|
||||||
case "/localapi/v0/webclient/start":
|
|
||||||
if err := h.b.WebClientInit(); err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// try to set pref, but ignore errors
|
|
||||||
_, _ = h.b.EditPrefs(&ipn.MaskedPrefs{
|
|
||||||
Prefs: ipn.Prefs{RunWebClient: true},
|
|
||||||
RunWebClientSet: true,
|
|
||||||
})
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
return
|
|
||||||
case "/localapi/v0/webclient/stop":
|
|
||||||
h.b.WebClientShutdown()
|
|
||||||
// try to set pref, but ignore errors
|
|
||||||
_, _ = h.b.EditPrefs(&ipn.MaskedPrefs{
|
|
||||||
Prefs: ipn.Prefs{RunWebClient: false},
|
|
||||||
RunWebClientSet: true,
|
|
||||||
})
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
http.Error(w, "invalid action", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func defBool(a string, def bool) bool {
|
func defBool(a string, def bool) bool {
|
||||||
if a == "" {
|
if a == "" {
|
||||||
return def
|
return def
|
||||||
|
Loading…
x
Reference in New Issue
Block a user