实现IP黑白名单、国家|地区封禁、省份封禁

This commit is contained in:
刘祥超
2020-11-09 10:43:47 +08:00
parent 80562162d8
commit a95b1df21c
10 changed files with 340 additions and 79 deletions
@@ -24,6 +24,14 @@ func (this *HTTPFirewallInboundConfig) Init() error {
return err
}
}
if this.Region != nil {
err := this.Region.Init()
if err != nil {
return err
}
}
return nil
}
@@ -4,4 +4,15 @@ type HTTPFirewallRegionConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"`
DenyCountryIds []int64 `yaml:"denyCountryIds" json:"denyCountryIds"` // 封禁的国家|地区
DenyProvinceIds []int64 `yaml:"denyProvinceIds" json:"denyProvinceIds"` // 封禁的省或自治区
isNotEmpty bool
}
func (this *HTTPFirewallRegionConfig) Init() error {
this.isNotEmpty = len(this.DenyCountryIds) > 0 || len(this.DenyProvinceIds) > 0
return nil
}
func (this *HTTPFirewallRegionConfig) IsNotEmpty() bool {
return this.isNotEmpty
}