Skip to content

Commit 3bcbde4

Browse files
committed
WAF区域封禁增加“允许搜索引擎”选项
1 parent c9ec1ee commit 3bcbde4

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

internal/web/actions/default/servers/components/waf/ipadmin/index.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ func (this *IndexAction) RunGet(params struct {
4141
var deniedCountryIds = []int64{}
4242
var allowedCountryIds = []int64{}
4343
var countryHTML string
44+
var allowSearchEngine bool
4445
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
4546
deniedCountryIds = policyConfig.Inbound.Region.DenyCountryIds
4647
allowedCountryIds = policyConfig.Inbound.Region.AllowCountryIds
4748
countryHTML = policyConfig.Inbound.Region.CountryHTML
49+
allowSearchEngine = policyConfig.Inbound.Region.AllowSearchEngine
4850
}
4951
this.Data["countryHTML"] = countryHTML
52+
this.Data["allowSearchEngine"] = allowSearchEngine
5053

5154
countriesResp, err := this.RPC().RegionCountryRPC().FindAllRegionCountries(this.AdminContext(), &pb.FindAllRegionCountriesRequest{})
5255
if err != nil {
@@ -94,7 +97,8 @@ func (this *IndexAction) RunPost(params struct {
9497
ExceptURLPatternsJSON []byte
9598
OnlyURLPatternsJSON []byte
9699

97-
CountryHTML string
100+
CountryHTML string
101+
AllowSearchEngine bool
98102

99103
Must *actions.Must
100104
}) {
@@ -139,6 +143,7 @@ func (this *IndexAction) RunPost(params struct {
139143
return
140144
}
141145
policyConfig.Inbound.Region.CountryHTML = params.CountryHTML
146+
policyConfig.Inbound.Region.AllowSearchEngine = params.AllowSearchEngine
142147

143148
// 限制URL
144149
var onlyURLPatterns = []*shared.URLPattern{}

internal/web/actions/default/servers/server/settings/waf/ipadmin/countries.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ func (this *CountriesAction) RunGet(params struct {
4646
var deniedCountryIds = []int64{}
4747
var allowedCountryIds = []int64{}
4848
var countryHTML = ""
49+
var allowSearchEngine bool
4950
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
5051
deniedCountryIds = policyConfig.Inbound.Region.DenyCountryIds
5152
allowedCountryIds = policyConfig.Inbound.Region.AllowCountryIds
5253
countryHTML = policyConfig.Inbound.Region.CountryHTML
54+
allowSearchEngine = policyConfig.Inbound.Region.AllowSearchEngine
5355
}
5456
this.Data["countryHTML"] = countryHTML
57+
this.Data["allowSearchEngine"] = allowSearchEngine
5558

5659
countriesResp, err := this.RPC().RegionCountryRPC().FindAllRegionCountries(this.AdminContext(), &pb.FindAllRegionCountriesRequest{})
5760
if err != nil {
@@ -126,7 +129,8 @@ func (this *CountriesAction) RunPost(params struct {
126129
ExceptURLPatternsJSON []byte
127130
OnlyURLPatternsJSON []byte
128131

129-
CountryHTML string
132+
CountryHTML string
133+
AllowSearchEngine bool
130134

131135
Must *actions.Must
132136
}) {
@@ -179,6 +183,7 @@ func (this *CountriesAction) RunPost(params struct {
179183
policyConfig.Inbound.Region.CountryOnlyURLPatterns = onlyURLPatterns
180184

181185
policyConfig.Inbound.Region.CountryHTML = params.CountryHTML
186+
policyConfig.Inbound.Region.AllowSearchEngine = params.AllowSearchEngine
182187

183188
if len(params.CountryHTML) > 32<<10 {
184189
this.Fail("提示内容长度不能超出32K")

web/views/@default/servers/components/waf/ipadmin/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
<p class="comment">当客户端所在区域被封禁时提示页面的HTML内容;不填则表示使用默认的提示内容;支持请求变量。</p>
4141
</td>
4242
</tr>
43+
<tr>
44+
<td>允许搜索引擎</td>
45+
<td>
46+
<checkbox name="allowSearchEngine" v-model="allowSearchEngine"></checkbox>
47+
<p class="comment">选中后,表示如果请求来自常见搜索引擎的IP,则不受区域限制。</p>
48+
</td>
49+
</tr>
4350
</tbody>
4451
</table>
4552
<submit-btn></submit-btn>

web/views/@default/servers/groups/group/settings/waf/ipadmin/countries.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
<td>限制URL &nbsp;<tip-icon content="只对这些URL做限制。"></tip-icon></td>
4040
<td><url-patterns-box v-model="onlyURLPatterns"></url-patterns-box></td>
4141
</tr>
42+
<tr>
43+
<td>允许搜索引擎</td>
44+
<td>
45+
<checkbox name="allowSearchEngine" v-model="allowSearchEngine"></checkbox>
46+
<p class="comment">选中后,表示如果请求来自常见搜索引擎的IP,则不受区域限制。</p>
47+
</td>
48+
</tr>
4249
</tbody>
4350
</table>
4451
<submit-btn></submit-btn>

web/views/@default/servers/server/settings/waf/ipadmin/countries.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
<p class="comment">当客户端所在区域被封禁时提示页面的HTML内容;不填则表示使用默认的提示内容;支持请求变量。</p>
5252
</td>
5353
</tr>
54+
<tr>
55+
<td>允许搜索引擎</td>
56+
<td>
57+
<checkbox name="allowSearchEngine" v-model="allowSearchEngine"></checkbox>
58+
<p class="comment">选中后,表示如果请求来自常见搜索引擎的IP,则不受区域限制。</p>
59+
</td>
60+
</tr>
5461
</tbody>
5562
</table>
5663
<submit-btn></submit-btn>

0 commit comments

Comments
 (0)