mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	节点IP增加是否启用、是否在线状态
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,3 @@
 | 
			
		||||
*_plus.go
 | 
			
		||||
*-plus.sh
 | 
			
		||||
*-plus.sh
 | 
			
		||||
*@plus.js
 | 
			
		||||
@@ -84,6 +84,8 @@ func (this *DetailAction) RunGet(params struct {
 | 
			
		||||
			"name":      addr.Name,
 | 
			
		||||
			"ip":        addr.Ip,
 | 
			
		||||
			"canAccess": addr.CanAccess,
 | 
			
		||||
			"isOn":      addr.IsOn,
 | 
			
		||||
			"isUp":      addr.IsUp,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -121,7 +123,7 @@ func (this *DetailAction) RunGet(params struct {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, addr := range ipAddresses {
 | 
			
		||||
			if !addr.CanAccess {
 | 
			
		||||
			if !addr.CanAccess || !addr.IsUp || !addr.IsOn {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			for _, route := range dnsInfo.Routes {
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,8 @@ func (this *UpdateAction) RunGet(params struct {
 | 
			
		||||
			"name":      addr.Name,
 | 
			
		||||
			"ip":        addr.Ip,
 | 
			
		||||
			"canAccess": addr.CanAccess,
 | 
			
		||||
			"isOn":      addr.IsOn,
 | 
			
		||||
			"isUp":      addr.IsUp,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,8 @@ func (this *CreatePopupAction) RunPost(params struct {
 | 
			
		||||
		"canAccess": params.CanAccess,
 | 
			
		||||
		"ip":        params.IP,
 | 
			
		||||
		"id":        0,
 | 
			
		||||
		"isOn":      true,
 | 
			
		||||
		"isUp":      true,
 | 
			
		||||
	}
 | 
			
		||||
	this.Success()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,11 +18,18 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
 | 
			
		||||
	for _, addr := range addresses {
 | 
			
		||||
		addrId := addr.GetInt64("id")
 | 
			
		||||
		if addrId > 0 {
 | 
			
		||||
			var isOn = false
 | 
			
		||||
			if !addr.Has("isOn") { // 兼容老版本
 | 
			
		||||
				isOn = true
 | 
			
		||||
			} else {
 | 
			
		||||
				isOn = addr.GetBool("isOn")
 | 
			
		||||
			}
 | 
			
		||||
			_, err = parentAction.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(parentAction.AdminContext(), &pb.UpdateNodeIPAddressRequest{
 | 
			
		||||
				AddressId: addrId,
 | 
			
		||||
				Ip:        addr.GetString("ip"),
 | 
			
		||||
				Name:      addr.GetString("name"),
 | 
			
		||||
				CanAccess: addr.GetBool("canAccess"),
 | 
			
		||||
				IsOn:      isOn,
 | 
			
		||||
			})
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package ipAddresses
 | 
			
		||||
 | 
			
		||||
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"
 | 
			
		||||
	"net"
 | 
			
		||||
@@ -26,15 +27,25 @@ func (this *UpdatePopupAction) RunPost(params struct {
 | 
			
		||||
	IP        string `alias:"ip"`
 | 
			
		||||
	Name      string
 | 
			
		||||
	CanAccess bool
 | 
			
		||||
	IsOn      bool
 | 
			
		||||
 | 
			
		||||
	Must *actions.Must
 | 
			
		||||
}) {
 | 
			
		||||
	// TODO 严格校验IP地址
 | 
			
		||||
 | 
			
		||||
	params.Must.
 | 
			
		||||
		Field("ip", params.IP).
 | 
			
		||||
		Require("请输入IP地址")
 | 
			
		||||
 | 
			
		||||
	// 获取IP地址信息
 | 
			
		||||
	addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{AddressId: params.AddressId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	var address = addressResp.IpAddress
 | 
			
		||||
	if address == nil {
 | 
			
		||||
		this.Fail("找不到要修改的地址")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ip := net.ParseIP(params.IP)
 | 
			
		||||
	if len(ip) == 0 {
 | 
			
		||||
		this.Fail("请输入正确的IP")
 | 
			
		||||
@@ -45,6 +56,8 @@ func (this *UpdatePopupAction) RunPost(params struct {
 | 
			
		||||
		"ip":        params.IP,
 | 
			
		||||
		"id":        params.AddressId,
 | 
			
		||||
		"canAccess": params.CanAccess,
 | 
			
		||||
		"isOn":      params.IsOn,
 | 
			
		||||
		"isUp":      address.IsUp,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this.Success()
 | 
			
		||||
 
 | 
			
		||||
@@ -22,3 +22,9 @@ Vue.component("tiny-basic-label", {
 | 
			
		||||
Vue.component("micro-basic-label", {
 | 
			
		||||
	template: `<span class="ui label tiny basic" style="margin-bottom: 0.5em; font-size: 0.7em; padding: 4px"><slot></slot></span>`
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 灰色的Label
 | 
			
		||||
Vue.component("grey-label", {
 | 
			
		||||
	template: `<span class="grey small"><slot></slot></span>`
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
// 节点IP地址管理(标签形式)
 | 
			
		||||
Vue.component("node-ip-addresses-box", {
 | 
			
		||||
	props: ["vIpAddresses"],
 | 
			
		||||
	data: function () {
 | 
			
		||||
@@ -48,6 +49,9 @@ Vue.component("node-ip-addresses-box", {
 | 
			
		||||
				<span v-if="isIPv6(address.ip)" class="grey">[IPv6]</span> {{address.ip}}
 | 
			
		||||
				<span class="small grey" v-if="address.name.length > 0">({{address.name}}<span v-if="!address.canAccess">,不可访问</span>)</span>
 | 
			
		||||
				<span class="small grey" v-if="address.name.length == 0 && !address.canAccess">(不可访问)</span>
 | 
			
		||||
				<span class="small red" v-if="!address.isOn">[off]</span>
 | 
			
		||||
				<span class="small red" v-if="!address.isUp">[down]</span>
 | 
			
		||||
				 
 | 
			
		||||
				<a href="" title="修改" @click.prevent="updateIPAddress(index, address)"><i class="icon pencil small"></i></a>
 | 
			
		||||
				<a href="" title="删除" @click.prevent="removeIPAddress(index)"><i class="icon remove"></i></a>
 | 
			
		||||
			</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,8 @@
 | 
			
		||||
                            <span v-if="address.ip.indexOf(':') > -1" class="grey">[IPv6]</span> {{address.ip}}
 | 
			
		||||
							<span class="small grey" v-if="address.name.length > 0">({{address.name}}<span v-if="!address.canAccess">,不可访问</span>)</span>
 | 
			
		||||
							<span class="small grey" v-if="address.name.length == 0 && !address.canAccess">(不可访问)</span>
 | 
			
		||||
                            <span class="small red" v-if="!address.isOn">[off]</span>
 | 
			
		||||
                            <span class="small red" v-if="!address.isUp">[down]</span>
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
				</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
 | 
			
		||||
	<table class="ui table definition selectable">
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td>IP地址 *</td>
 | 
			
		||||
			<td class="title">IP地址 *</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				<input type="text" name="ip" maxlength="128" ref="focus"/>
 | 
			
		||||
			</td>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
	<input type="hidden" name="addressId" :value="address.id"/>
 | 
			
		||||
	<table class="ui table definition selectable">
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td>IP地址 *</td>
 | 
			
		||||
			<td class="title">IP地址 *</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				<input type="text" name="ip" maxlength="128" ref="focus" v-model="address.ip"/>
 | 
			
		||||
			</td>
 | 
			
		||||
@@ -21,12 +21,27 @@
 | 
			
		||||
				<p class="comment">是否为可以公开访问的IP,如果选中,也会作为DNS解析记录的值使用。</p>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td class="title">备注</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				<input type="text" name="name" maxlength="50" v-model="address.name"/>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td colspan="2"><more-options-indicator></more-options-indicator></td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tbody v-show="moreOptionsVisible">
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>是否启用</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <div class="ui checkbox">
 | 
			
		||||
                        <input type="checkbox" name="isOn" value="1" v-model="address.isOn"/>
 | 
			
		||||
                        <label></label>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <p class="comment">选中表示当前IP有效。</p>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td class="title">备注</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <input type="text" name="name" maxlength="50" v-model="address.name"/>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
        </tbody>
 | 
			
		||||
	</table>
 | 
			
		||||
	<submit-btn></submit-btn>
 | 
			
		||||
</form>
 | 
			
		||||
@@ -41,16 +41,16 @@
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tr v-for="record in records">
 | 
			
		||||
        <td>{{record.name}}</td>
 | 
			
		||||
        <td><keyword :v-word="keyword">{{record.name}}</keyword></td>
 | 
			
		||||
        <td>{{record.type}}</td>
 | 
			
		||||
        <td>{{record.value}}</td>
 | 
			
		||||
        <td><keyword :v-word="keyword">{{record.value}}</keyword></td>
 | 
			
		||||
        <td>{{formatTTL(record.ttl)}}</td>
 | 
			
		||||
        <td>
 | 
			
		||||
            <div v-for="route in record.routes" style="margin-top: 0.3em; margin-bottom: 0.3em">
 | 
			
		||||
                <span class="ui label basic text tiny">{{route.name}}</span>
 | 
			
		||||
            </div>
 | 
			
		||||
        </td>
 | 
			
		||||
        <td>{{record.description}}</td>
 | 
			
		||||
        <td><keyword :v-word="keyword">{{record.description}}</keyword></td>
 | 
			
		||||
        <td><label-on :v-is-on="record.isOn"></label-on></td>
 | 
			
		||||
        <td>
 | 
			
		||||
            <a href="" @click.prevent="updateRecord(record.id)">修改</a>  
 | 
			
		||||
 
 | 
			
		||||
@@ -81,7 +81,7 @@
 | 
			
		||||
	<tr v-for="server in servers">
 | 
			
		||||
        <td><a :href="'/servers/server?serverId=' + server.id"><keyword :v-word="keyword">{{server.name}}</keyword></a>
 | 
			
		||||
			<div style="margin-top:0.4em">
 | 
			
		||||
				<tiny-basic-label>{{server.serverTypeName}}</tiny-basic-label>
 | 
			
		||||
				<grey-label>{{server.serverTypeName}}</grey-label>
 | 
			
		||||
			</div>
 | 
			
		||||
		</td>
 | 
			
		||||
		<td>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user