69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"finclip-app-manager/domain/entity"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type BundleInfoCfg struct {
|
|
BundleID string `json:"bundleId"`
|
|
Remark string `json:"remark"`
|
|
SDKKey string `json:"SDKKey"`
|
|
SDKID string `json:"SDKID"`
|
|
}
|
|
|
|
type BindingWhiteListInfo struct {
|
|
Desc string `json:"desc"`
|
|
SDKList []BundleInfoCfg `json:"sdkList"`
|
|
BindingList []entity.Binding `json:"bindingList"`
|
|
}
|
|
|
|
//创建白名单应用
|
|
var WhiteSDKList []BundleInfoCfg
|
|
var WhiteSDKArry []string //SDKKey
|
|
var WhiteBundleIdArry []string //bundleId
|
|
var BindingWhiteList BindingWhiteListInfo
|
|
|
|
func init() {
|
|
//私有化部署的版本隐藏应用凡泰助手
|
|
filePtr, err := os.Open("./conf/bindingWhiteList.json")
|
|
if GetConfig().IsHcc {
|
|
if GetConfig().HccEnv == "dev" {
|
|
filePtr, err = os.Open("./conf/bindingWhiteListHccDev.json")
|
|
} else {
|
|
filePtr, err = os.Open("./conf/bindingWhiteListHccUat.json")
|
|
}
|
|
}
|
|
if err != nil {
|
|
fmt.Println("Open file failed [Err:%s]", err.Error())
|
|
panic(err.Error())
|
|
}
|
|
defer filePtr.Close()
|
|
// 创建json解码器
|
|
decoder := json.NewDecoder(filePtr)
|
|
err = decoder.Decode(&BindingWhiteList)
|
|
if err != nil {
|
|
fmt.Println("Decoder failed", err.Error())
|
|
panic(err.Error())
|
|
}
|
|
WhiteSDKList = BindingWhiteList.SDKList
|
|
for _, v := range BindingWhiteList.SDKList {
|
|
WhiteSDKArry = append(WhiteSDKArry, v.SDKKey)
|
|
WhiteBundleIdArry = append(WhiteBundleIdArry, v.BundleID)
|
|
}
|
|
fmt.Println("[config/sdk_list.go:48] binding white list:", BindingWhiteList)
|
|
fmt.Println("[handler/sdk_list.go:49] sdk-key list:", WhiteSDKArry)
|
|
fmt.Println("[handler/sdk_list.go:50] bundle-id list:", WhiteBundleIdArry)
|
|
}
|
|
|
|
func WhiteListGetSDKKeyAndId(bundleId string) (string, string) {
|
|
for _, v := range WhiteSDKList {
|
|
if v.BundleID == bundleId {
|
|
return v.SDKKey, v.SDKID
|
|
}
|
|
}
|
|
return "", ""
|
|
}
|