|
|
|
@ -70,6 +70,7 @@ var handler = map[string]localAPIHandler{
|
|
|
|
|
"debug-packet-filter-rules": (*Handler).serveDebugPacketFilterRules,
|
|
|
|
|
"derpmap": (*Handler).serveDERPMap,
|
|
|
|
|
"dev-set-state-store": (*Handler).serveDevSetStateStore,
|
|
|
|
|
"set-push-device-token": (*Handler).serveSetPushDeviceToken,
|
|
|
|
|
"dial": (*Handler).serveDial,
|
|
|
|
|
"file-targets": (*Handler).serveFileTargets,
|
|
|
|
|
"goroutines": (*Handler).serveGoroutines,
|
|
|
|
@ -1205,6 +1206,25 @@ func (h *Handler) serveDial(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
<-errc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) serveSetPushDeviceToken(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if !h.PermitWrite {
|
|
|
|
|
http.Error(w, "set push device token access denied", http.StatusForbidden)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if r.Method != "POST" {
|
|
|
|
|
http.Error(w, "unsupported method", http.StatusMethodNotAllowed)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var params apitype.SetPushDeviceTokenRequest
|
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(¶ms); err != nil {
|
|
|
|
|
http.Error(w, "invalid JSON body", 400)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
hostinfo.SetPushDeviceToken(params.PushDeviceToken)
|
|
|
|
|
h.b.ResendHostinfoIfNeeded()
|
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) serveUploadClientMetrics(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if r.Method != "POST" {
|
|
|
|
|
http.Error(w, "unsupported method", http.StatusMethodNotAllowed)
|
|
|
|
|