mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
IP名单批量导入IP支持CIDR
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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", {
|
||||
</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" v-model="avgRequests.operator">
|
||||
<option value="lt">小于</option>
|
||||
<option value="lte">小于等于</option>
|
||||
<option value="gt">大于</option>
|
||||
</select>
|
||||
</td>
|
||||
@@ -175,7 +175,7 @@ Vue.component("node-ip-address-thresholds-box", {
|
||||
</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" v-model="avgTrafficOut.operator">
|
||||
<option value="lt">小于</option>
|
||||
<option value="lte">小于等于</option>
|
||||
<option value="gt">大于</option>
|
||||
</select>
|
||||
</td>
|
||||
@@ -196,7 +196,7 @@ Vue.component("node-ip-address-thresholds-box", {
|
||||
</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" v-model="avgTrafficIn.operator">
|
||||
<option value="lt">小于</option>
|
||||
<option value="lte">小于等于</option>
|
||||
<option value="gt">大于</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
{$template "node_menu"}
|
||||
|
||||
<h3>节点详情</h3>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">节点名称</td>
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user