Files
EdgeCommon/pkg/systemconfigs/security_config.go
2021-08-11 09:36:21 +08:00

34 lines
1.1 KiB
Go

package systemconfigs
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
// SecurityConfig 安全相关配置
type SecurityConfig struct {
Frame string `json:"frame"` // Frame嵌套
AllowCountryIds []int64 `json:"allowCountryIds"` // 允许的国家/地区
AllowProvinceIds []int64 `json:"allowProvinceIds"` // 允许的省份
AllowLocal bool `json:"allowLocal"` // 允许本地+局域网IP访问
AllowIPs []string `json:"allowIPs"` // 允许访问的IP
AllowRememberLogin bool `json:"allowRememberLogin"` // 是否允许在设备上记住登录
allowIPRanges []*shared.IPRangeConfig
}
// Init 初始化
func (this *SecurityConfig) Init() error {
this.allowIPRanges = []*shared.IPRangeConfig{}
for _, allowIP := range this.AllowIPs {
r, err := shared.ParseIPRange(allowIP)
if err != nil {
return err
}
this.allowIPRanges = append(this.allowIPRanges, r)
}
return nil
}
// AllowIPRanges 查询允许的IP区域
func (this *SecurityConfig) AllowIPRanges() []*shared.IPRangeConfig {
return this.allowIPRanges
}