diff --git a/internal/web/actions/default/servers/components/waf/init.go b/internal/web/actions/default/servers/components/waf/init.go
index 08d435d9..6848024d 100644
--- a/internal/web/actions/default/servers/components/waf/init.go
+++ b/internal/web/actions/default/servers/components/waf/init.go
@@ -48,6 +48,7 @@ func init() {
GetPost("/ipadmin/createIPPopup", new(ipadmin.CreateIPPopupAction)).
GetPost("/ipadmin/updateIPPopup", new(ipadmin.UpdateIPPopupAction)).
Post("/ipadmin/deleteIP", new(ipadmin.DeleteIPAction)).
+ GetPost("/ipadmin/test", new(ipadmin.TestAction)).
EndAll()
})
diff --git a/internal/web/actions/default/servers/components/waf/ipadmin/test.go b/internal/web/actions/default/servers/components/waf/ipadmin/test.go
new file mode 100644
index 00000000..61b4cef5
--- /dev/null
+++ b/internal/web/actions/default/servers/components/waf/ipadmin/test.go
@@ -0,0 +1,85 @@
+package ipadmin
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/actions"
+ "github.com/iwind/TeaGo/maps"
+ timeutil "github.com/iwind/TeaGo/utils/time"
+)
+
+type TestAction struct {
+ actionutils.ParentAction
+}
+
+func (this *TestAction) Init() {
+ this.Nav("", "", "ipadmin")
+}
+
+func (this *TestAction) RunGet(params struct {
+ FirewallPolicyId int64
+}) {
+ this.Data["subMenuItem"] = "test"
+
+ this.Show()
+}
+
+func (this *TestAction) RunPost(params struct {
+ FirewallPolicyId int64
+ Ip string
+
+ Must *actions.Must
+}) {
+ resp, err := this.RPC().HTTPFirewallPolicyRPC().CheckHTTPFirewallPolicyIPStatus(this.AdminContext(), &pb.CheckHTTPFirewallPolicyIPStatusRequest{
+ HttpFirewallPolicyId: params.FirewallPolicyId,
+ Ip: params.Ip,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+
+ resultMap := maps.Map{
+ "isDone": true,
+ "isFound": resp.IsFound,
+ "isOk": resp.IsOk,
+ "error": resp.Error,
+ "isAllowed": resp.IsAllowed,
+ }
+
+ if resp.IpList != nil {
+ resultMap["list"] = maps.Map{
+ "id": resp.IpList.Id,
+ "name": resp.IpList.Name,
+ }
+ }
+ if resp.IpItem != nil {
+ resultMap["item"] = maps.Map{
+ "id": resp.IpItem.Id,
+ "ipFrom": resp.IpItem.IpFrom,
+ "ipTo": resp.IpItem.IpTo,
+ "reason": resp.IpItem.Reason,
+ "expiredAt": resp.IpItem.ExpiredAt,
+ "expiredTime": timeutil.FormatTime("Y-m-d H:i:s", resp.IpItem.ExpiredAt),
+ "type": resp.IpItem.Type,
+ }
+ }
+
+ if resp.RegionCountry != nil {
+ resultMap["country"] = maps.Map{
+ "id": resp.RegionCountry.Id,
+ "name": resp.RegionCountry.Name,
+ }
+ }
+
+ if resp.RegionProvince != nil {
+ resultMap["province"] = maps.Map{
+ "id": resp.RegionProvince.Id,
+ "name": resp.RegionProvince.Name,
+ }
+ }
+
+ this.Data["result"] = resultMap
+
+ this.Success()
+}
diff --git a/internal/web/actions/default/servers/server/settings/waf/init.go b/internal/web/actions/default/servers/server/settings/waf/init.go
index e53abf2e..667073ce 100644
--- a/internal/web/actions/default/servers/server/settings/waf/init.go
+++ b/internal/web/actions/default/servers/server/settings/waf/init.go
@@ -22,6 +22,7 @@ func init() {
GetPost("/ipadmin/createIPPopup", new(ipadmin.CreateIPPopupAction)).
GetPost("/ipadmin/updateIPPopup", new(ipadmin.UpdateIPPopupAction)).
Post("/ipadmin/deleteIP", new(ipadmin.DeleteIPAction)).
+ GetPost("/ipadmin/test", new(ipadmin.TestAction)).
// 规则相关
Get("/groups", new(GroupsAction)).
diff --git a/internal/web/actions/default/servers/server/settings/waf/ipadmin/test.go b/internal/web/actions/default/servers/server/settings/waf/ipadmin/test.go
new file mode 100644
index 00000000..1e7f4b15
--- /dev/null
+++ b/internal/web/actions/default/servers/server/settings/waf/ipadmin/test.go
@@ -0,0 +1,98 @@
+package ipadmin
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/actions"
+ "github.com/iwind/TeaGo/maps"
+ timeutil "github.com/iwind/TeaGo/utils/time"
+)
+
+type TestAction struct {
+ actionutils.ParentAction
+}
+
+func (this *TestAction) Init() {
+ this.Nav("", "setting", "test")
+ this.SecondMenu("waf")
+}
+
+func (this *TestAction) RunGet(params struct {
+ ServerId int64
+ FirewallPolicyId int64
+}) {
+ this.Data["featureIsOn"] = true
+ this.Data["firewallPolicyId"] = params.FirewallPolicyId
+ this.Data["subMenuItem"] = "province"
+
+ // WAF是否启用
+ webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ this.Data["wafIsOn"] = webConfig.FirewallRef != nil && webConfig.FirewallRef.IsOn
+
+ this.Show()
+}
+
+func (this *TestAction) RunPost(params struct {
+ FirewallPolicyId int64
+ Ip string
+
+ Must *actions.Must
+}) {
+ resp, err := this.RPC().HTTPFirewallPolicyRPC().CheckHTTPFirewallPolicyIPStatus(this.AdminContext(), &pb.CheckHTTPFirewallPolicyIPStatusRequest{
+ HttpFirewallPolicyId: params.FirewallPolicyId,
+ Ip: params.Ip,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+
+ resultMap := maps.Map{
+ "isDone": true,
+ "isFound": resp.IsFound,
+ "isOk": resp.IsOk,
+ "error": resp.Error,
+ "isAllowed": resp.IsAllowed,
+ }
+
+ if resp.IpList != nil {
+ resultMap["list"] = maps.Map{
+ "id": resp.IpList.Id,
+ "name": resp.IpList.Name,
+ }
+ }
+ if resp.IpItem != nil {
+ resultMap["item"] = maps.Map{
+ "id": resp.IpItem.Id,
+ "ipFrom": resp.IpItem.IpFrom,
+ "ipTo": resp.IpItem.IpTo,
+ "reason": resp.IpItem.Reason,
+ "expiredAt": resp.IpItem.ExpiredAt,
+ "expiredTime": timeutil.FormatTime("Y-m-d H:i:s", resp.IpItem.ExpiredAt),
+ "type": resp.IpItem.Type,
+ }
+ }
+
+ if resp.RegionCountry != nil {
+ resultMap["country"] = maps.Map{
+ "id": resp.RegionCountry.Id,
+ "name": resp.RegionCountry.Name,
+ }
+ }
+
+ if resp.RegionProvince != nil {
+ resultMap["province"] = maps.Map{
+ "id": resp.RegionProvince.Id,
+ "name": resp.RegionProvince.Name,
+ }
+ }
+
+ this.Data["result"] = resultMap
+
+ this.Success()
+}
diff --git a/web/public/js/components/iplist/ip-item-text.js b/web/public/js/components/iplist/ip-item-text.js
new file mode 100644
index 00000000..759066a4
--- /dev/null
+++ b/web/public/js/components/iplist/ip-item-text.js
@@ -0,0 +1,11 @@
+Vue.component("ip-item-text", {
+ props: ["v-item"],
+ template: `
+ *
+
+ {{vItem.ipFrom}}
+ - {{vItem.ipTo}}
+
+ {{vItem.ipFrom}}
+`
+})
\ No newline at end of file
diff --git a/web/views/@default/servers/components/waf/ipadmin/@menu.html b/web/views/@default/servers/components/waf/ipadmin/@menu.html
index 1a80b3d9..6c50ae16 100644
--- a/web/views/@default/servers/components/waf/ipadmin/@menu.html
+++ b/web/views/@default/servers/components/waf/ipadmin/@menu.html
@@ -1,10 +1,12 @@