mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	更好地支持IPv6
This commit is contained in:
		@@ -5,44 +5,23 @@ import (
 | 
			
		||||
	"encoding/binary"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/iwind/TeaGo/types"
 | 
			
		||||
	"math/big"
 | 
			
		||||
	"net"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// IP2Long 将IP转换为整型
 | 
			
		||||
// 为临时过渡的函数
 | 
			
		||||
func IP2Long(ip string) uint64 {
 | 
			
		||||
	s := net.ParseIP(ip)
 | 
			
		||||
	if len(s) != 16 {
 | 
			
		||||
	var i = net.ParseIP(ip)
 | 
			
		||||
	if len(i) == 0 {
 | 
			
		||||
		return 0
 | 
			
		||||
	}
 | 
			
		||||
	if i.To4() != nil {
 | 
			
		||||
		return uint64(binary.BigEndian.Uint32(i.To4()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.Contains(ip, ":") { // IPv6
 | 
			
		||||
		bigInt := big.NewInt(0)
 | 
			
		||||
		bigInt.SetBytes(s.To16())
 | 
			
		||||
		return bigInt.Uint64()
 | 
			
		||||
	}
 | 
			
		||||
	return uint64(binary.BigEndian.Uint32(s.To4()))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsIPv4 判断是否为IPv4
 | 
			
		||||
func IsIPv4(ip string) bool {
 | 
			
		||||
	if !regexp.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`).MatchString(ip) {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if IP2Long(ip) == 0 {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsIPv6 判断是否为IPv6
 | 
			
		||||
func IsIPv6(ip string) bool {
 | 
			
		||||
	if !strings.Contains(ip, ":") {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	return len(net.ParseIP(ip)) == net.IPv6len
 | 
			
		||||
	// TODO 支持IPv6
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExtractIP 分解IP
 | 
			
		||||
 
 | 
			
		||||
@@ -5,86 +5,6 @@ import (
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestIP2Long(t *testing.T) {
 | 
			
		||||
	for _, ip := range []string{
 | 
			
		||||
		"0.0.0.1",
 | 
			
		||||
		"0.0.0.2",
 | 
			
		||||
		"127.0.0.1",
 | 
			
		||||
		"192.0.0.2",
 | 
			
		||||
		"255.255.255.255",
 | 
			
		||||
		"2001:db8:0:1::101",
 | 
			
		||||
		"2001:db8:0:1::102",
 | 
			
		||||
		"2406:8c00:0:3409:133:18:203:0",
 | 
			
		||||
		"2406:8c00:0:3409:133:18:203:158",
 | 
			
		||||
		"2406:8c00:0:3409:133:18:203:159",
 | 
			
		||||
		"2406:8c00:0:3409:133:18:203:160",
 | 
			
		||||
	} {
 | 
			
		||||
		t.Log(ip, " -> ", IP2Long(ip))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIsIPv4(t *testing.T) {
 | 
			
		||||
	type testIP struct {
 | 
			
		||||
		ip string
 | 
			
		||||
		ok bool
 | 
			
		||||
	}
 | 
			
		||||
	for _, item := range []testIP{
 | 
			
		||||
		{
 | 
			
		||||
			ip: "1",
 | 
			
		||||
			ok: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "192.168.0.1",
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "1.1.0.1",
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "255.255.255.255",
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "192.168.0.1233",
 | 
			
		||||
			ok: false,
 | 
			
		||||
		},
 | 
			
		||||
	} {
 | 
			
		||||
		if IsIPv4(item.ip) != item.ok {
 | 
			
		||||
			t.Fatal(item.ip, "should be", item.ok)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIsIPv6(t *testing.T) {
 | 
			
		||||
	type testIP struct {
 | 
			
		||||
		ip string
 | 
			
		||||
		ok bool
 | 
			
		||||
	}
 | 
			
		||||
	for _, item := range []testIP{
 | 
			
		||||
		{
 | 
			
		||||
			ip: "1",
 | 
			
		||||
			ok: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "2406:8c00:0:3409:133:18:203:158",
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "2406::8c00:0:3409:133:18:203:158",
 | 
			
		||||
			ok: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ip: "2001:db8:0:1::101",
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
	} {
 | 
			
		||||
		if IsIPv6(item.ip) != item.ok {
 | 
			
		||||
			t.Fatal(item.ip, "should be", item.ok)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestExtractIP(t *testing.T) {
 | 
			
		||||
	t.Log(ExtractIP("192.168.1.100"))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,11 @@ package node
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
			
		||||
@@ -178,7 +178,7 @@ func (this *DetailAction) RunGet(params struct {
 | 
			
		||||
 | 
			
		||||
			for _, route := range dnsInfo.Routes {
 | 
			
		||||
				var recordType = "A"
 | 
			
		||||
				if utils.IsIPv6(addr.Ip) {
 | 
			
		||||
				if iputils.IsIPv6(addr.Ip) {
 | 
			
		||||
					recordType = "AAAA"
 | 
			
		||||
				}
 | 
			
		||||
				recordMaps = append(recordMaps, maps.Map{
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,8 @@
 | 
			
		||||
package dns
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	timeutil "github.com/iwind/TeaGo/utils/time"
 | 
			
		||||
@@ -110,7 +110,7 @@ func (this *RecordsAction) RunGet(params struct {
 | 
			
		||||
				var isResolved = false
 | 
			
		||||
				if isInstalled && cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
 | 
			
		||||
					var recordType = "A"
 | 
			
		||||
					if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
					if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
						recordType = "AAAA"
 | 
			
		||||
					}
 | 
			
		||||
					checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
@@ -148,7 +148,7 @@ func (this *RecordsAction) RunGet(params struct {
 | 
			
		||||
			var isResolved = false
 | 
			
		||||
			if isInstalled && len(defaultRoute) > 0 {
 | 
			
		||||
				var recordType = "A"
 | 
			
		||||
				if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
				if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
					recordType = "AAAA"
 | 
			
		||||
				}
 | 
			
		||||
				checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package clusters
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	timeutil "github.com/iwind/TeaGo/utils/time"
 | 
			
		||||
@@ -107,7 +107,7 @@ func (this *ClusterAction) RunGet(params struct {
 | 
			
		||||
				var isResolved = false
 | 
			
		||||
				if isInstalled && cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
 | 
			
		||||
					var recordType = "A"
 | 
			
		||||
					if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
					if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
						recordType = "AAAA"
 | 
			
		||||
					}
 | 
			
		||||
					checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
@@ -145,7 +145,7 @@ func (this *ClusterAction) RunGet(params struct {
 | 
			
		||||
			var isResolved = false
 | 
			
		||||
			if isInstalled && len(defaultRoute) > 0 {
 | 
			
		||||
				var recordType = "A"
 | 
			
		||||
				if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
				if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
					recordType = "AAAA"
 | 
			
		||||
				}
 | 
			
		||||
				checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package domains
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
)
 | 
			
		||||
@@ -65,7 +65,7 @@ func (this *NodesPopupAction) RunGet(params struct {
 | 
			
		||||
					var isResolved = false
 | 
			
		||||
					if len(route.Name) > 0 && len(node.IpAddr) > 0 && len(cluster.DnsName) > 0 {
 | 
			
		||||
						var recordType = "A"
 | 
			
		||||
						if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
						if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
							recordType = "AAAA"
 | 
			
		||||
						}
 | 
			
		||||
						checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
@@ -99,7 +99,7 @@ func (this *NodesPopupAction) RunGet(params struct {
 | 
			
		||||
				var isResolved = false
 | 
			
		||||
				if len(defaultRoute) > 0 {
 | 
			
		||||
					var recordType = "A"
 | 
			
		||||
					if utils.IsIPv6(node.IpAddr) {
 | 
			
		||||
					if iputils.IsIPv6(node.IpAddr) {
 | 
			
		||||
						recordType = "AAAA"
 | 
			
		||||
					}
 | 
			
		||||
					checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package ipadmin
 | 
			
		||||
 | 
			
		||||
import (	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/actions"
 | 
			
		||||
@@ -72,13 +73,13 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom/ipTo)
 | 
			
		||||
		var ipFromLong uint64
 | 
			
		||||
		if !utils.IsIPv4(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv4(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的开始IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipFromLong = utils.IP2Long(params.IpFrom)
 | 
			
		||||
 | 
			
		||||
		var ipToLong uint64
 | 
			
		||||
		if len(params.IpTo) > 0 && !utils.IsIPv4(params.IpTo) {
 | 
			
		||||
		if len(params.IpTo) > 0 && !iputils.IsIPv4(params.IpTo) {
 | 
			
		||||
			this.Fail("请输入正确的结束IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipToLong = utils.IP2Long(params.IpTo)
 | 
			
		||||
@@ -92,7 +93,7 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
			Require("请输入IP")
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom)
 | 
			
		||||
		if !utils.IsIPv6(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv6(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的IPv6地址")
 | 
			
		||||
		}
 | 
			
		||||
	case "all":
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,10 @@
 | 
			
		||||
package iplists
 | 
			
		||||
 | 
			
		||||
import (	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
 | 
			
		||||
@@ -89,13 +91,13 @@ func (this *CreateIPPopupAction) RunPost(params struct {
 | 
			
		||||
				Require("请输入开始IP")
 | 
			
		||||
 | 
			
		||||
			var ipFromLong uint64
 | 
			
		||||
			if !utils.IsIPv4(params.IpFrom) {
 | 
			
		||||
			if !iputils.IsIPv4(params.IpFrom) {
 | 
			
		||||
				this.Fail("请输入正确的开始IP")
 | 
			
		||||
			}
 | 
			
		||||
			ipFromLong = utils.IP2Long(params.IpFrom)
 | 
			
		||||
 | 
			
		||||
			var ipToLong uint64
 | 
			
		||||
			if len(params.IpTo) > 0 && !utils.IsIPv4(params.IpTo) {
 | 
			
		||||
			if len(params.IpTo) > 0 && !iputils.IsIPv4(params.IpTo) {
 | 
			
		||||
				this.Fail("请输入正确的结束IP")
 | 
			
		||||
			}
 | 
			
		||||
			ipToLong = utils.IP2Long(params.IpTo)
 | 
			
		||||
@@ -170,7 +172,7 @@ func (this *CreateIPPopupAction) RunPost(params struct {
 | 
			
		||||
				Require("请输入IP")
 | 
			
		||||
 | 
			
		||||
			// 校验IP格式(ipFrom)
 | 
			
		||||
			if !utils.IsIPv6(params.IpFrom) {
 | 
			
		||||
			if !iputils.IsIPv6(params.IpFrom) {
 | 
			
		||||
				this.Fail("请输入正确的IPv6地址")
 | 
			
		||||
			}
 | 
			
		||||
		} else if params.Method == "batch" {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package iplists
 | 
			
		||||
 | 
			
		||||
import (	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/actions"
 | 
			
		||||
@@ -71,13 +72,13 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom/ipTo)
 | 
			
		||||
		var ipFromLong uint64
 | 
			
		||||
		if !utils.IsIPv4(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv4(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的开始IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipFromLong = utils.IP2Long(params.IpFrom)
 | 
			
		||||
 | 
			
		||||
		var ipToLong uint64
 | 
			
		||||
		if len(params.IpTo) > 0 && !utils.IsIPv4(params.IpTo) {
 | 
			
		||||
		if len(params.IpTo) > 0 && !iputils.IsIPv4(params.IpTo) {
 | 
			
		||||
			this.Fail("请输入正确的结束IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipToLong = utils.IP2Long(params.IpTo)
 | 
			
		||||
@@ -91,7 +92,7 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
			Require("请输入IP")
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom)
 | 
			
		||||
		if !utils.IsIPv6(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv6(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的IPv6地址")
 | 
			
		||||
		}
 | 
			
		||||
	case "all":
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package ipadmin
 | 
			
		||||
 | 
			
		||||
import (	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/actions"
 | 
			
		||||
@@ -71,13 +72,13 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom/ipTo)
 | 
			
		||||
		var ipFromLong uint64
 | 
			
		||||
		if !utils.IsIPv4(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv4(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的开始IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipFromLong = utils.IP2Long(params.IpFrom)
 | 
			
		||||
 | 
			
		||||
		var ipToLong uint64
 | 
			
		||||
		if len(params.IpTo) > 0 && !utils.IsIPv4(params.IpTo) {
 | 
			
		||||
		if len(params.IpTo) > 0 && !iputils.IsIPv4(params.IpTo) {
 | 
			
		||||
			this.Fail("请输入正确的结束IP")
 | 
			
		||||
		}
 | 
			
		||||
		ipToLong = utils.IP2Long(params.IpTo)
 | 
			
		||||
@@ -91,7 +92,7 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
 | 
			
		||||
			Require("请输入IP")
 | 
			
		||||
 | 
			
		||||
		// 校验IP格式(ipFrom)
 | 
			
		||||
		if !utils.IsIPv6(params.IpFrom) {
 | 
			
		||||
		if !iputils.IsIPv6(params.IpFrom) {
 | 
			
		||||
			this.Fail("请输入正确的IPv6地址")
 | 
			
		||||
		}
 | 
			
		||||
	case "all":
 | 
			
		||||
 
 | 
			
		||||
@@ -202,8 +202,9 @@ Vue.component("ip-list-table", {
 | 
			
		||||
						<div v-if="item.isExpired" style="margin-top: 0.5em">
 | 
			
		||||
							<span class="ui label tiny basic red">已过期</span>
 | 
			
		||||
						</div>
 | 
			
		||||
						<div  v-if="item.lifeSeconds != null && item.lifeSeconds > 0">
 | 
			
		||||
							<span class="small grey">{{formatSeconds(item.lifeSeconds)}}</span>
 | 
			
		||||
						<div  v-if="item.lifeSeconds != null">
 | 
			
		||||
							<span class="small grey" v-if="item.lifeSeconds > 0">{{formatSeconds(item.lifeSeconds)}}</span>
 | 
			
		||||
							<span class="small red">已过期</span>
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
					<span v-else class="disabled">不过期</span>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user