diff --git a/internal/web/actions/default/servers/iplists/import.go b/internal/web/actions/default/servers/iplists/import.go index 23ef2d59..79cb40d7 100644 --- a/internal/web/actions/default/servers/iplists/import.go +++ b/internal/web/actions/default/servers/iplists/import.go @@ -7,6 +7,7 @@ import ( "encoding/csv" "encoding/json" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/lists" @@ -201,6 +202,19 @@ func (this *ImportAction) createItemFromValues(values []string, countIgnore *int item.Reason = values[5] } + // CIDR + if strings.Contains(item.IpFrom, "/") { + ipFrom, ipTo, err := configutils.ParseCIDR(item.IpFrom) + if err == nil { + item.IpFrom = ipFrom + item.IpTo = ipTo + } + } + + if len(item.EventLevel) == 0 { + item.EventLevel = "critical" + } + if net.ParseIP(item.IpFrom) == nil { *countIgnore++ return nil @@ -209,5 +223,6 @@ func (this *ImportAction) createItemFromValues(values []string, countIgnore *int *countIgnore++ return nil } + return item } diff --git a/web/public/js/components/node/node-ip-address-thresholds-box.js b/web/public/js/components/node/node-ip-address-thresholds-box.js index d4be0912..296a3327 100644 --- a/web/public/js/components/node/node-ip-address-thresholds-box.js +++ b/web/public/js/components/node/node-ip-address-thresholds-box.js @@ -9,19 +9,19 @@ Vue.component("node-ip-address-thresholds-box", { let avgRequests = { duration: "", - operator: "lt", + operator: "lte", value: "" } let avgTrafficOut = { duration: "", - operator: "lt", + operator: "lte", value: "" } let avgTrafficIn = { duration: "", - operator: "lt", + operator: "lte", value: "" } @@ -154,7 +154,7 @@ Vue.component("node-ip-address-thresholds-box", {
| 节点名称 | diff --git a/web/views/@default/servers/iplists/import.js b/web/views/@default/servers/iplists/import.js index 9c911bd9..f90e6bb9 100644 --- a/web/views/@default/servers/iplists/import.js +++ b/web/views/@default/servers/iplists/import.js @@ -1,6 +1,10 @@ Tea.context(function () { this.success = function (resp) { - teaweb.success("成功导入" + resp.data.count + "个IP", function () { + let message = "成功导入" + resp.data.count + "个IP" + if (resp.data.countIgnore > 0) { + message += ",并忽略" + resp.data.countIgnore + "个格式错误的IP" + } + teaweb.success(message, function () { teaweb.reload() }) }