mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:10:26 +08:00
在WAF中增加检查IP状态功能
This commit is contained in:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user