forked from all_user/stat_center
- 新增 advitise v2: info/location/bind/click-stat/day-click-stat 模型与 对应的 service、api、router、proto 定义 - models/index.go 注册 5 个新模型的索引初始化 - 鉴权白名单: /rsdownload/ 改为 /download/,放行 advitise v2 的 get/click 接口 - statg/config: proxyUrl 增加 fileRes1 - common/genId: lid 生成逻辑补充 - 新增 91fans / huangguo 的 mobileconfig 描述文件 - 新增 deploy/nginx/cpcdownload.mfcg.me.conf 网关配置 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
99 lines
2.7 KiB
Go
99 lines
2.7 KiB
Go
package statg
|
|
|
|
import (
|
|
"stat/common/config"
|
|
"stat/common/enum/consts"
|
|
"stat/common/httputil"
|
|
"stat/common/log"
|
|
|
|
"github.com/dchest/captcha"
|
|
)
|
|
|
|
var (
|
|
Conf GlobalConfig
|
|
ProxyCfg *httputil.ProxyCfg
|
|
VerifyIMGStore captcha.Store
|
|
Tgbotsend string
|
|
)
|
|
|
|
type ChartsConfig struct {
|
|
Width int `json:"width"`
|
|
Height int `json:"height"`
|
|
}
|
|
|
|
type GlobalConfig struct {
|
|
ServerIndex ServerIndex `json:"serverIndex"` //1:麻豆,2:逼哩,3:知乎
|
|
RunMod consts.RunMod `json:"runMod"`
|
|
Pprof bool `json:"pprof"`
|
|
JwtKey string `json:"jwtKey"`
|
|
InnerKey string `json:"innerKey"`
|
|
InnerServers map[ServerIndex]string `json:"innerServers"`
|
|
Kafka struct {
|
|
Url string `json:"url"`
|
|
Group string `json:"group"`
|
|
} `json:"kafka"`
|
|
Mongo struct {
|
|
Url string `json:"url"`
|
|
} `json:"mongo"`
|
|
Redis struct {
|
|
Url string `json:"url"`
|
|
} `json:"redis"`
|
|
Limit struct {
|
|
Ip struct {
|
|
Capacity int64 `json:"capacity"`
|
|
Rate int64 `json:"rate"`
|
|
} `json:"ip"`
|
|
} `json:"limit"`
|
|
URL struct {
|
|
PackageUrl string `json:"packageUrl"`
|
|
BiliPackageUrl string `json:"biliPackageUrl"`
|
|
HuanqiuPackageUrl string `json:"huanqiuPackageUrl"`
|
|
ManhuaPackageUrl string `json:"manhuaPackageUrl"`
|
|
} `json:"url"`
|
|
ProxyUrl struct {
|
|
File string `json:"file"`
|
|
FileRes string `json:"fileRes"`
|
|
FileRes1 string `json:"fileRes1"`
|
|
} `json:"proxyUrl"`
|
|
KafkaServer bool `json:"kafkaServer"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
IsVersion bool `json:"versionServer"`
|
|
ImgUploadUrl string `json:"imgUploadUrl"`
|
|
LandPageCDN string `json:"landPageCDN"`
|
|
BotConfig BotConfig `json:"botConfig"`
|
|
TgbotSend string `json:"tgbotSend"`
|
|
ApkGenEnable bool `json:"apkGenEnable"`
|
|
ChartsConfig ChartsConfig `json:"chartsConfig"`
|
|
AppConfig Endpoints `json:"appConfig"`
|
|
}
|
|
|
|
func LoadConfig(path string) error {
|
|
err := config.LoadJSON(path, &Conf)
|
|
if err != nil {
|
|
log.Fatal("加载本地配置失败", log.E(err))
|
|
return err
|
|
}
|
|
// set default value
|
|
if Conf.Limit.Ip.Capacity <= 0 {
|
|
Conf.Limit.Ip.Capacity = 300
|
|
}
|
|
if Conf.Limit.Ip.Rate <= 0 {
|
|
Conf.Limit.Ip.Rate = 5
|
|
}
|
|
if Conf.ChartsConfig.Width <= 0 {
|
|
Conf.ChartsConfig.Width = 1600
|
|
}
|
|
if Conf.ChartsConfig.Height <= 0 {
|
|
Conf.ChartsConfig.Height = 400
|
|
}
|
|
Tgbotsend = Conf.TgbotSend
|
|
// app config
|
|
GlobalEndpoints = Conf.AppConfig
|
|
for _, item := range GlobalEndpoints {
|
|
GlobalIndexEndpoints[item.OwnerIndex] = append(GlobalIndexEndpoints[item.OwnerIndex], item)
|
|
GlobalAppIdEndpoints[item.AppId] = item
|
|
}
|
|
return nil
|
|
}
|