WAF策略中的地区/省份封禁也支持自定义提示HTML

This commit is contained in:
刘祥超
2023-08-10 09:52:01 +08:00
parent 0f40b6438a
commit 03b46f4c24
5 changed files with 39 additions and 1 deletions

View File

@@ -40,10 +40,13 @@ func (this *IndexAction) RunGet(params struct {
var deniedCountryIds = []int64{}
var allowedCountryIds = []int64{}
var countryHTML string
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 {
@@ -91,6 +94,8 @@ func (this *IndexAction) RunPost(params struct {
ExceptURLPatternsJSON []byte
OnlyURLPatternsJSON []byte
CountryHTML string
Must *actions.Must
}) {
// 日志
@@ -128,6 +133,13 @@ func (this *IndexAction) RunPost(params struct {
}
policyConfig.Inbound.Region.CountryExceptURLPatterns = exceptURLPatterns
// 自定义提示
if len(params.CountryHTML) > 32<<10 {
this.Fail("提示内容长度不能超出32K")
return
}
policyConfig.Inbound.Region.CountryHTML = params.CountryHTML
// 限制URL
var onlyURLPatterns = []*shared.URLPattern{}
if len(params.OnlyURLPatternsJSON) > 0 {