mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
Ln节点可以指定访问IP
This commit is contained in:
@@ -295,6 +295,11 @@ func (this *DetailAction) RunGet(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
var lnAddrs = node.LnAddrs
|
||||
if lnAddrs == nil {
|
||||
lnAddrs = []string{}
|
||||
}
|
||||
|
||||
this.Data["node"] = maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
@@ -312,6 +317,7 @@ func (this *DetailAction) RunGet(params struct {
|
||||
"routes": routeMaps,
|
||||
"level": node.Level,
|
||||
"levelInfo": nodeconfigs.FindNodeLevel(int(node.Level)),
|
||||
"lnAddrs": lnAddrs,
|
||||
|
||||
"status": maps.Map{
|
||||
"isActive": status.IsActive,
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net"
|
||||
)
|
||||
|
||||
type UpdateAction struct {
|
||||
@@ -61,7 +62,7 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
ipAddressMaps := []maps.Map{}
|
||||
var ipAddressMaps = []maps.Map{}
|
||||
for _, addr := range ipAddressesResp.NodeIPAddresses {
|
||||
thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id)
|
||||
if err != nil {
|
||||
@@ -109,6 +110,12 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
"level": node.Level,
|
||||
}
|
||||
|
||||
if node.LnAddrs == nil {
|
||||
nodeMap["lnAddrs"] = []string{}
|
||||
} else {
|
||||
nodeMap["lnAddrs"] = node.LnAddrs
|
||||
}
|
||||
|
||||
if node.NodeCluster != nil {
|
||||
nodeMap["primaryCluster"] = maps.Map{
|
||||
"id": node.NodeCluster.Id,
|
||||
@@ -149,6 +156,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
SecondaryClusterIds []byte
|
||||
IsOn bool
|
||||
Level int32
|
||||
LnAddrs []string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -178,7 +186,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
// IP地址
|
||||
ipAddresses := []maps.Map{}
|
||||
var ipAddresses = []maps.Map{}
|
||||
if len(params.IPAddressesJSON) > 0 {
|
||||
err := json.Unmarshal(params.IPAddressesJSON, &ipAddresses)
|
||||
if err != nil {
|
||||
@@ -195,6 +203,27 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
this.Fail("没有权限修改节点级别:" + types.String(params.Level))
|
||||
}
|
||||
|
||||
// 检查Ln节点地址
|
||||
var lnAddrs = []string{}
|
||||
if params.Level > 1 {
|
||||
for _, lnAddr := range params.LnAddrs {
|
||||
if len(lnAddr) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 处理 host:port
|
||||
host, _, err := net.SplitHostPort(lnAddr)
|
||||
if err == nil {
|
||||
lnAddr = host
|
||||
}
|
||||
|
||||
if net.ParseIP(lnAddr) == nil {
|
||||
this.Fail("L2级别访问地址 '" + lnAddr + "' 格式错误,请纠正后再提交")
|
||||
}
|
||||
lnAddrs = append(lnAddrs, lnAddr)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := this.RPC().NodeRPC().UpdateNode(this.AdminContext(), &pb.UpdateNodeRequest{
|
||||
NodeId: params.NodeId,
|
||||
NodeGroupId: params.GroupId,
|
||||
@@ -204,6 +233,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
SecondaryNodeClusterIds: secondaryClusterIds,
|
||||
IsOn: params.IsOn,
|
||||
Level: params.Level,
|
||||
LnAddrs: lnAddrs,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -22,6 +22,11 @@ Vue.component("node-level-selector", {
|
||||
levelCode: levelCode
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
levelCode: function (code) {
|
||||
this.$emit("change", code)
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<select class="ui dropdown auto-width" name="level" v-model="levelCode">
|
||||
<option v-for="level in levels" :value="level.code">{{level.name}}</option>
|
||||
|
||||
@@ -91,6 +91,10 @@
|
||||
<td>级别</td>
|
||||
<td>
|
||||
<span :class="{blue: node.levelInfo.code > 1}">{{node.levelInfo.name}}</span>
|
||||
<span v-if="node.level > 1 && node.lnAddrs != null && node.lnAddrs.length > 0">
|
||||
<span v-for="lnAddr in node.lnAddrs" class="ui label tiny basic">{{lnAddr}}</span>
|
||||
</span>
|
||||
<p class="comment" v-if="node.level > 1 && node.lnAddrs != null && node.lnAddrs.length > 0">指定了Ln节点访问地址。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -48,10 +48,17 @@
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr v-if="teaIsPlus && canUpdateLevel">
|
||||
<tr v-show="teaIsPlus && canUpdateLevel">
|
||||
<td>级别</td>
|
||||
<td>
|
||||
<node-level-selector :v-node-level="node.level"></node-level-selector>
|
||||
<node-level-selector :v-node-level="node.level" @change="changeLevel"></node-level-selector>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="teaIsPlus && canUpdateLevel && nodeLevel > 1">
|
||||
<td>L2级别访问地址</td>
|
||||
<td>
|
||||
<values-box name="lnAddrs" :v-values="node.lnAddrs" placeholder="IP地址"></values-box>
|
||||
<p class="comment">如果不为空,边缘节点访问当前L2节点时将会使用这些IP地址;如果没有设置,将会使用当前节点已经填写的IP地址。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -26,4 +26,12 @@ Tea.context(function () {
|
||||
this.updateClusters = function () {
|
||||
this.showClustersBox = !this.showClustersBox
|
||||
}
|
||||
|
||||
/**
|
||||
* 级别相关
|
||||
*/
|
||||
this.nodeLevel = this.node.level
|
||||
this.changeLevel = function (level) {
|
||||
this.nodeLevel = level
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user