From 0cad34cea2ab0114bf6df3fcbe5329226aaef7e5 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 14 Jul 2023 11:01:01 +0800 Subject: [PATCH] =?UTF-8?q?WAF-=E5=8C=BA=E5=9F=9F=E5=B0=81=E7=A6=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA=E5=86=85=E5=AE=B9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../firewallconfigs/http_firewall_region_config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/serverconfigs/firewallconfigs/http_firewall_region_config.go b/pkg/serverconfigs/firewallconfigs/http_firewall_region_config.go index 76611ba..03174f4 100644 --- a/pkg/serverconfigs/firewallconfigs/http_firewall_region_config.go +++ b/pkg/serverconfigs/firewallconfigs/http_firewall_region_config.go @@ -3,6 +3,7 @@ package firewallconfigs import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/regionconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + "strings" ) type HTTPFirewallRegionConfig struct { @@ -15,9 +16,11 @@ type HTTPFirewallRegionConfig struct { CountryOnlyURLPatterns []*shared.URLPattern `yaml:"countryOnlyURLPatterns" json:"countryOnlyURLPatterns"` // 仅限的URL CountryExceptURLPatterns []*shared.URLPattern `yaml:"countryExceptURLPatterns" json:"countryExceptURLPatterns"` // 排除的URL + CountryHTML string `yaml:"countryHTML" json:"countryHTML"` // 提示HTML ProvinceOnlyURLPatterns []*shared.URLPattern `yaml:"provinceOnlyURLPatterns" json:"provinceOnlyURLPatterns"` // 仅限的URL ProvinceExceptURLPatterns []*shared.URLPattern `yaml:"provinceExceptURLPatterns" json:"provinceExceptURLPatterns"` // 排除的URL + ProvinceHTML string `yaml:"provinceHTML" json:"provinceHTML"` // 提示HTML isNotEmpty bool @@ -40,6 +43,8 @@ func (this *HTTPFirewallRegionConfig) Init() error { this.denyCountryIdMap[countryId] = true } + this.CountryHTML = strings.TrimSpace(this.CountryHTML) + this.allowProvinceIdMap = map[int64]bool{} for _, provinceId := range this.AllowProvinceIds { this.allowProvinceIdMap[provinceId] = true @@ -50,6 +55,8 @@ func (this *HTTPFirewallRegionConfig) Init() error { this.denyProvinceIdMap[provinceId] = true } + this.ProvinceHTML = strings.TrimSpace(this.ProvinceHTML) + // url patterns for _, pattern := range this.CountryExceptURLPatterns { err := pattern.Init()