From dc420256e22704f34641fac09c49ea1727d280a1 Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Fri, 3 Nov 2023 18:19:45 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BD=91=E7=AB=99=20WAF=20=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=20user-agent=20=E8=BF=87=E6=BB=A4=20(#2796)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/dto/request/file.go | 4 ++--
backend/app/dto/request/nginx.go | 8 ++++----
backend/app/dto/request/website.go | 12 ++++++------
backend/app/dto/request/website_ssl.go | 4 ++--
frontend/src/lang/modules/en.ts | 1 +
frontend/src/lang/modules/tw.ts | 1 +
frontend/src/lang/modules/zh.ts | 1 +
.../views/website/website/config/safety/index.vue | 3 +++
8 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/backend/app/dto/request/file.go b/backend/app/dto/request/file.go
index 6f6df07ce..8c6ae201a 100644
--- a/backend/app/dto/request/file.go
+++ b/backend/app/dto/request/file.go
@@ -94,7 +94,7 @@ type FileDownload struct {
Paths []string `json:"paths" validate:"required"`
Type string `json:"type" validate:"required"`
Name string `json:"name" validate:"required"`
- Compress bool `json:"compress" validate:"required"`
+ Compress bool `json:"compress"`
}
type FileChunkDownload struct {
@@ -114,7 +114,7 @@ type FileRoleUpdate struct {
Path string `json:"path" validate:"required"`
User string `json:"user" validate:"required"`
Group string `json:"group" validate:"required"`
- Sub bool `json:"sub" validate:"required"`
+ Sub bool `json:"sub"`
}
type FileReadByLineReq struct {
diff --git a/backend/app/dto/request/nginx.go b/backend/app/dto/request/nginx.go
index 744740ff1..88c583f13 100644
--- a/backend/app/dto/request/nginx.go
+++ b/backend/app/dto/request/nginx.go
@@ -4,7 +4,7 @@ import "github.com/1Panel-dev/1Panel/backend/app/dto"
type NginxConfigFileUpdate struct {
Content string `json:"content" validate:"required"`
- Backup bool `json:"backup" validate:"required"`
+ Backup bool `json:"backup"`
}
type NginxScopeReq struct {
@@ -56,7 +56,7 @@ type NginxAntiLeechUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Extends string `json:"extends" validate:"required"`
Return string `json:"return" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
+ Enable bool `json:"enable" `
ServerNames []string `json:"serverNames"`
Cache bool `json:"cache"`
CacheTime int `json:"cacheTime"`
@@ -70,8 +70,8 @@ type NginxRedirectReq struct {
Name string `json:"name" validate:"required"`
WebsiteID uint `json:"websiteID" validate:"required"`
Domains []string `json:"domains"`
- KeepPath bool `json:"keepPath" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
+ KeepPath bool `json:"keepPath"`
+ Enable bool `json:"enable"`
Type string `json:"type" validate:"required"`
Redirect string `json:"redirect" validate:"required"`
Path string `json:"path"`
diff --git a/backend/app/dto/request/website.go b/backend/app/dto/request/website.go
index 4314e8220..90ae19693 100644
--- a/backend/app/dto/request/website.go
+++ b/backend/app/dto/request/website.go
@@ -78,13 +78,13 @@ type WebsiteWafReq struct {
type WebsiteRedirectUpdate struct {
WebsiteID uint `json:"websiteId" validate:"required"`
Key string `json:"key" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
+ Enable bool `json:"enable"`
}
type WebsiteWafUpdate struct {
WebsiteID uint `json:"websiteId" validate:"required"`
Key string `json:"key" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
+ Enable bool `json:"enable"`
}
type WebsiteRecover struct {
@@ -121,7 +121,7 @@ type WebsiteDomainDelete struct {
type WebsiteHTTPSOp struct {
WebsiteID uint `json:"websiteId" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
+ Enable bool `json:"enable"`
WebsiteSSLID uint `json:"websiteSSLId"`
Type string `json:"type" validate:"oneof=existed auto manual"`
PrivateKey string `json:"privateKey"`
@@ -168,7 +168,7 @@ type WebsitePHPFileUpdate struct {
type WebsitePHPVersionReq struct {
WebsiteID uint `json:"websiteID" validate:"required"`
RuntimeID uint `json:"runtimeID" validate:"required"`
- RetainConfig bool `json:"retainConfig" validate:"required"`
+ RetainConfig bool `json:"retainConfig" `
}
type WebsiteUpdateDir struct {
@@ -185,8 +185,8 @@ type WebsiteUpdateDirPermission struct {
type WebsiteProxyConfig struct {
ID uint `json:"id" validate:"required"`
Operate string `json:"operate" validate:"required"`
- Enable bool `json:"enable" validate:"required"`
- Cache bool `json:"cache" validate:"required"`
+ Enable bool `json:"enable" `
+ Cache bool `json:"cache" `
CacheTime int `json:"cacheTime" validate:"required"`
CacheUnit string `json:"cacheUnit" validate:"required"`
Name string `json:"name" validate:"required"`
diff --git a/backend/app/dto/request/website_ssl.go b/backend/app/dto/request/website_ssl.go
index a6f979b84..f148efe3b 100644
--- a/backend/app/dto/request/website_ssl.go
+++ b/backend/app/dto/request/website_ssl.go
@@ -13,7 +13,7 @@ type WebsiteSSLCreate struct {
Provider string `json:"provider" validate:"required"`
AcmeAccountID uint `json:"acmeAccountId" validate:"required"`
DnsAccountID uint `json:"dnsAccountId"`
- AutoRenew bool `json:"autoRenew" validate:"required"`
+ AutoRenew bool `json:"autoRenew"`
}
type WebsiteDNSReq struct {
@@ -48,7 +48,7 @@ type WebsiteResourceReq struct {
type WebsiteSSLUpdate struct {
ID uint `json:"id" validate:"required"`
- AutoRenew bool `json:"autoRenew" validate:"required"`
+ AutoRenew bool `json:"autoRenew"`
}
type WebsiteSSLUpload struct {
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 4cef12905..0748b0b81 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -1788,6 +1788,7 @@ const message = {
allIP: 'All IP',
portRule: 'Port rule',
ipRule: 'IP rule',
+ userAgent: 'User-Agent filter',
},
runtime: {
runtime: 'Runtime',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index f75f8e7e9..ded2fa3f3 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -1688,6 +1688,7 @@ const message = {
allIP: '所有 IP',
portRule: '端口規則',
ipRule: 'IP 規則',
+ userAgent: 'User-Agent 過濾',
},
runtime: {
runtime: '運行環境',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 9d4e51cd2..a92f293fe 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1688,6 +1688,7 @@ const message = {
allIP: '所有 IP',
portRule: '端口规则',
ipRule: 'IP 规则',
+ userAgent: 'User-Agent 过滤',
},
runtime: {
runtime: '运行环境',
diff --git a/frontend/src/views/website/website/config/safety/index.vue b/frontend/src/views/website/website/config/safety/index.vue
index 32209db56..caccb600a 100644
--- a/frontend/src/views/website/website/config/safety/index.vue
+++ b/frontend/src/views/website/website/config/safety/index.vue
@@ -44,6 +44,9 @@
+
+
+