forked from Harry-zklcdc/go-proxy-bingai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys-config.go
40 lines (36 loc) · 975 Bytes
/
sys-config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package api
import (
"adams549659584/go-proxy-bingai/common"
"adams549659584/go-proxy-bingai/common/helper"
"net/http"
"net/url"
"github.com/Harry-zklcdc/bing-lib/lib/aes"
)
type SysConfig struct {
// 是否系统配置 cookie
IsSysCK bool `json:"isSysCK"`
// 是否已授权
IsAuth bool `json:"isAuth"`
Info string `json:"info"`
}
func SysConf(w http.ResponseWriter, r *http.Request) {
IG := r.URL.Query().Get("IG")
T, _ := url.QueryUnescape(r.URL.Query().Get("T"))
token, err := aes.Decrypt(T, IG)
if err != nil {
helper.ErrorResult(w, http.StatusInternalServerError, "Server Error")
common.Logger.Error("SysConf Decrypt Error: %v", err)
return
}
if token != common.AUTHOR {
helper.ErrorResult(w, http.StatusUnavailableForLegalReasons, "T error")
return
}
isAuth := helper.CheckAuth(r)
conf := SysConfig{
IsSysCK: len(common.USER_TOKEN_LIST) > 0,
IsAuth: isAuth,
Info: common.ANNOUNCEMENT,
}
helper.SuccessResult(w, conf)
}