|
@@ -51,6 +51,19 @@ func downloadCBDAppLog(w http.ResponseWriter, r *http.Request) {
|
|
|
http.ServeFile(w, r, tmpFile)
|
|
http.ServeFile(w, r, tmpFile)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func cbdUnlockHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
+ if r.Method != http.MethodPost {
|
|
|
|
|
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if !checkOperationPassword(w, r) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ w.WriteHeader(http.StatusOK)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func cbdWriteMCUDataHandler(w http.ResponseWriter, r *http.Request) {
|
|
func cbdWriteMCUDataHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method != http.MethodPost {
|
|
if r.Method != http.MethodPost {
|
|
|
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
@@ -173,9 +186,15 @@ func cbdUploadFirmwareHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
func cbdServerCfgHandler(w http.ResponseWriter, r *http.Request) {
|
|
func cbdServerCfgHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
switch r.Method {
|
|
switch r.Method {
|
|
|
case http.MethodGet:
|
|
case http.MethodGet:
|
|
|
|
|
+ if !checkOperationPassword(w, r) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
callRPCResponse(w, r, cbdLocalRPCPort, "core.getServerCfg", nil)
|
|
callRPCResponse(w, r, cbdLocalRPCPort, "core.getServerCfg", nil)
|
|
|
|
|
|
|
|
case http.MethodPost:
|
|
case http.MethodPost:
|
|
|
|
|
+ if !checkOperationPassword(w, r) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
var params json.RawMessage
|
|
var params json.RawMessage
|
|
|
if err := json.NewDecoder(r.Body).Decode(¶ms); err != nil {
|
|
if err := json.NewDecoder(r.Body).Decode(¶ms); err != nil {
|
|
|
http.Error(w, "服务器配置无效: "+err.Error(), http.StatusBadRequest)
|
|
http.Error(w, "服务器配置无效: "+err.Error(), http.StatusBadRequest)
|