gofiber-study/common/config/config.go
Shikong d152df3a1d 添加 waf
添加 访问频率限制测试
2022-10-25 15:01:57 +08:00

78 lines
2.0 KiB
Go

package config
import (
"image/color"
)
type BasicConfig struct {
Server ServerConfig `yaml:"server"`
Mysql MysqlConfig `yaml:"mysql"`
Redis RedisConfig `yaml:"redis"`
Jwt JwtConfig `yaml:"jwt"`
NanoId NanoIdConfig `yaml:"nanoId"`
Captcha CaptchaConfig `yaml:"captcha"`
Waf Waf `yaml:"waf"`
}
type NanoIdConfig struct {
Sequence string `yaml:"sequence"`
Length int `yaml:"length"`
}
type JwtConfig struct {
Secret string `yaml:"secret"`
Expire int64 `yaml:"expire"`
}
type MysqlConfig struct {
DataSources []string `yaml:"dataSources"`
AutoSync bool `yaml:"autoSync"`
}
type ServerConfig struct {
// 监听 地址:端口
Addr string `yaml:"addr"`
// 是否开启多进程
PreFork bool `yaml:"preFork"`
// 路由 大小写严格
CaseSensitive bool `yaml:"caseSensitive"`
// 严格路由 例: 设置为 true 时, /foo != /foo/
StrictRouting bool `yaml:"strictRouting"`
// 设置 Http 请求头中的 Server 名称
ServerHeader string `yaml:"serverHeader"`
// 是否添加 /routes 路由 用于获取所有路由信息
EnableRoutesMsg bool `yaml:"enableRoutesMsg"`
}
type RedisConfig struct {
Addr string `yaml:"addr"`
Pass string `yaml:"pass"`
DB int `yaml:"db"`
}
type CaptchaConfig struct {
Driver string `yaml:"driver"`
// Height png height in pixel.
Height int `yaml:"height"`
// Width Captcha png width in pixel.
Width int `yaml:"width"`
//NoiseCount text noise count.
NoiseCount int `yaml:"noiseCount"`
//ShowLineOptions := OptionShowHollowLine | OptionShowSlimeLine | OptionShowSineLine .
ShowLineOptions int `yaml:"showLineOptions"`
//Length random string length.
Length int `yaml:"length"`
//Source is a unicode which is the rand string from.
Source string `yaml:"source"`
//BgColor captcha image background color (optional)
BgColor *color.RGBA `yaml:"bgColor"`
//Expire 失效时间 (秒)
Expire int64 `json:"expired"`
}
type Waf struct {
//RateLimit 访问频率
RateLimit int64 `yaml:"rateLimit"`
}