|
|
@@ -3,6 +3,7 @@ package main
|
|
|
import (
|
|
|
"bufio"
|
|
|
"context"
|
|
|
+ "crypto/subtle"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"io/fs"
|
|
|
@@ -505,3 +506,12 @@ func serviceControlHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
json.NewEncoder(w).Encode(map[string]bool{"ok": true})
|
|
|
}
|
|
|
+
|
|
|
+func checkOperationPassword(w http.ResponseWriter, r *http.Request) bool {
|
|
|
+ password := r.Header.Get("X-Operation-Password")
|
|
|
+ if subtle.ConstantTimeCompare([]byte(password), []byte("yfkj123456")) != 1 {
|
|
|
+ http.Error(w, "操作密码错误", http.StatusUnauthorized)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|