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/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
@@ -201,6 +202,19 @@ func (this *ImportAction) createItemFromValues(values []string, countIgnore *int
|
|||||||
item.Reason = values[5]
|
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 {
|
if net.ParseIP(item.IpFrom) == nil {
|
||||||
*countIgnore++
|
*countIgnore++
|
||||||
return nil
|
return nil
|
||||||
@@ -209,5 +223,6 @@ func (this *ImportAction) createItemFromValues(values []string, countIgnore *int
|
|||||||
*countIgnore++
|
*countIgnore++
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ Vue.component("node-ip-address-thresholds-box", {
|
|||||||
|
|
||||||
let avgRequests = {
|
let avgRequests = {
|
||||||
duration: "",
|
duration: "",
|
||||||
operator: "lt",
|
operator: "lte",
|
||||||
value: ""
|
value: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
let avgTrafficOut = {
|
let avgTrafficOut = {
|
||||||
duration: "",
|
duration: "",
|
||||||
operator: "lt",
|
operator: "lte",
|
||||||
value: ""
|
value: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
let avgTrafficIn = {
|
let avgTrafficIn = {
|
||||||
duration: "",
|
duration: "",
|
||||||
operator: "lt",
|
operator: "lte",
|
||||||
value: ""
|
value: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ Vue.component("node-ip-address-thresholds-box", {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="ui dropdown auto-width" v-model="avgRequests.operator">
|
<select class="ui dropdown auto-width" v-model="avgRequests.operator">
|
||||||
<option value="lt">小于</option>
|
<option value="lte">小于等于</option>
|
||||||
<option value="gt">大于</option>
|
<option value="gt">大于</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -175,7 +175,7 @@ Vue.component("node-ip-address-thresholds-box", {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="ui dropdown auto-width" v-model="avgTrafficOut.operator">
|
<select class="ui dropdown auto-width" v-model="avgTrafficOut.operator">
|
||||||
<option value="lt">小于</option>
|
<option value="lte">小于等于</option>
|
||||||
<option value="gt">大于</option>
|
<option value="gt">大于</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -196,7 +196,7 @@ Vue.component("node-ip-address-thresholds-box", {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="ui dropdown auto-width" v-model="avgTrafficIn.operator">
|
<select class="ui dropdown auto-width" v-model="avgTrafficIn.operator">
|
||||||
<option value="lt">小于</option>
|
<option value="lte">小于等于</option>
|
||||||
<option value="gt">大于</option>
|
<option value="gt">大于</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
{$template "node_menu"}
|
{$template "node_menu"}
|
||||||
|
|
||||||
<h3>节点详情</h3>
|
|
||||||
<table class="ui table definition selectable">
|
<table class="ui table definition selectable">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">节点名称</td>
|
<td class="title">节点名称</td>
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.success = function (resp) {
|
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()
|
teaweb.reload()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user