WAF-区域封禁增加提示内容设置

This commit is contained in:
GoEdgeLab
2023-07-14 11:00:50 +08:00
parent 48227373d8
commit 829e6ecde9
4 changed files with 42 additions and 2 deletions

View File

@@ -44,10 +44,13 @@ func (this *CountriesAction) RunGet(params struct {
}
var deniedCountryIds = []int64{}
var allowedCountryIds = []int64{}
var countryHTML = ""
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
deniedCountryIds = policyConfig.Inbound.Region.DenyCountryIds
allowedCountryIds = policyConfig.Inbound.Region.AllowCountryIds
countryHTML = policyConfig.Inbound.Region.CountryHTML
}
this.Data["countryHTML"] = countryHTML
countriesResp, err := this.RPC().RegionCountryRPC().FindAllRegionCountries(this.AdminContext(), &pb.FindAllRegionCountriesRequest{})
if err != nil {
@@ -97,12 +100,15 @@ func (this *CountriesAction) RunGet(params struct {
func (this *CountriesAction) RunPost(params struct {
FirewallPolicyId int64
DenyCountryIds []int64
AllowCountryIds []int64
DenyCountryIds []int64
AllowCountryIds []int64
ExceptURLPatternsJSON []byte
OnlyURLPatternsJSON []byte
CountryHTML string
Must *actions.Must
}) {
// 日志
@@ -153,6 +159,13 @@ func (this *CountriesAction) RunPost(params struct {
}
policyConfig.Inbound.Region.CountryOnlyURLPatterns = onlyURLPatterns
policyConfig.Inbound.Region.CountryHTML = params.CountryHTML
if len(params.CountryHTML) > 32<<10 {
this.Fail("提示内容长度不能超出32K")
return
}
err = policyConfig.Init()
if err != nil {
this.Fail("配置校验失败:" + err.Error())

View File

@@ -44,10 +44,13 @@ func (this *ProvincesAction) RunGet(params struct {
var deniedProvinceIds = []int64{}
var allowedProvinceIds = []int64{}
var provinceHTML = ""
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
deniedProvinceIds = policyConfig.Inbound.Region.DenyProvinceIds
allowedProvinceIds = policyConfig.Inbound.Region.AllowProvinceIds
provinceHTML = policyConfig.Inbound.Region.ProvinceHTML
}
this.Data["provinceHTML"] = provinceHTML
provincesResp, err := this.RPC().RegionProvinceRPC().FindAllRegionProvincesWithRegionCountryId(this.AdminContext(), &pb.FindAllRegionProvincesWithRegionCountryIdRequest{
RegionCountryId: regionconfigs.RegionChinaId,
@@ -98,12 +101,15 @@ func (this *ProvincesAction) RunGet(params struct {
func (this *ProvincesAction) RunPost(params struct {
FirewallPolicyId int64
DenyProvinceIds []int64
AllowProvinceIds []int64
ExceptURLPatternsJSON []byte
OnlyURLPatternsJSON []byte
ProvinceHTML string
Must *actions.Must
}) {
// 日志
@@ -152,6 +158,13 @@ func (this *ProvincesAction) RunPost(params struct {
}
policyConfig.Inbound.Region.ProvinceOnlyURLPatterns = onlyURLPatterns
if len(params.ProvinceHTML) > 32<<10 {
this.Fail("提示内容长度不能超出32K")
return
}
policyConfig.Inbound.Region.ProvinceHTML = params.ProvinceHTML
err = policyConfig.Init()
if err != nil {
this.Fail("配置校验失败:" + err.Error())