@@ -62,11 +62,10 @@ type localAPIHandler func(*Handler, http.ResponseWriter, *http.Request)
6262// then it's a prefix match.
6363var handler = map [string ]localAPIHandler {
6464 // The prefix match handlers end with a slash:
65- "cert/" : (* Handler ).serveCert ,
66- "file-put/" : (* Handler ).serveFilePut ,
67- "files/" : (* Handler ).serveFiles ,
68- "profiles/" : (* Handler ).serveProfiles ,
69- "webclient/" : (* Handler ).serveWebClient ,
65+ "cert/" : (* Handler ).serveCert ,
66+ "file-put/" : (* Handler ).serveFilePut ,
67+ "files/" : (* Handler ).serveFiles ,
68+ "profiles/" : (* Handler ).serveProfiles ,
7069
7170 // The other /localapi/v0/NAME handlers are exact matches and contain only NAME
7271 // without a trailing slash:
@@ -2243,43 +2242,6 @@ func (h *Handler) serveDebugWebClient(w http.ResponseWriter, r *http.Request) {
22432242 w .Header ().Set ("Content-Type" , "application/json" )
22442243}
22452244
2246- func (h * Handler ) serveWebClient (w http.ResponseWriter , r * http.Request ) {
2247- if ! h .PermitWrite {
2248- http .Error (w , "access denied" , http .StatusForbidden )
2249- return
2250- }
2251- if r .Method != httpm .POST {
2252- http .Error (w , "use POST" , http .StatusMethodNotAllowed )
2253- return
2254- }
2255- switch r .URL .Path {
2256- case "/localapi/v0/webclient/start" :
2257- if err := h .b .WebClientInit (); err != nil {
2258- http .Error (w , err .Error (), http .StatusInternalServerError )
2259- return
2260- }
2261- // try to set pref, but ignore errors
2262- _ , _ = h .b .EditPrefs (& ipn.MaskedPrefs {
2263- Prefs : ipn.Prefs {RunWebClient : true },
2264- RunWebClientSet : true ,
2265- })
2266- w .WriteHeader (http .StatusOK )
2267- return
2268- case "/localapi/v0/webclient/stop" :
2269- h .b .WebClientShutdown ()
2270- // try to set pref, but ignore errors
2271- _ , _ = h .b .EditPrefs (& ipn.MaskedPrefs {
2272- Prefs : ipn.Prefs {RunWebClient : false },
2273- RunWebClientSet : true ,
2274- })
2275- w .WriteHeader (http .StatusOK )
2276- return
2277- default :
2278- http .Error (w , "invalid action" , http .StatusBadRequest )
2279- return
2280- }
2281- }
2282-
22832245func defBool (a string , def bool ) bool {
22842246 if a == "" {
22852247 return def
0 commit comments