Update ip
This commit is contained in:
parent
d0fb2f06f5
commit
a77b5d1954
1 changed files with 18 additions and 12 deletions
|
@ -90,7 +90,7 @@ func CheckNetwork() {
|
|||
networkId := ""
|
||||
address := ""
|
||||
networkNames := gjson.ParseBytes(respBody).Array()
|
||||
|
||||
routers := ""
|
||||
for _, v := range networkNames {
|
||||
res, err := httper.ZTGet("/controller/network/" + v.Str)
|
||||
if err != nil {
|
||||
|
@ -100,10 +100,11 @@ func CheckNetwork() {
|
|||
name := gjson.GetBytes(res, "name").Str
|
||||
if name == common.RANW_NAME {
|
||||
networkId = gjson.GetBytes(res, "id").Str
|
||||
routers = gjson.GetBytes(res, "routes.0.target").Str
|
||||
break
|
||||
}
|
||||
}
|
||||
ip, s, e, c := getZTIP()
|
||||
ip, s, e, c := getZTIP(routers)
|
||||
logger.Info("ip", zap.Any("ip", ip))
|
||||
if len(networkId) == 0 {
|
||||
if len(address) == 0 {
|
||||
|
@ -224,7 +225,7 @@ func GetZTIPs() []gjson.Result {
|
|||
return a.Array()
|
||||
}
|
||||
|
||||
func getZTIP() (ip, start, end, cidr string) {
|
||||
func getZTIP(routes string) (ip, start, end, cidr string) {
|
||||
excluded := GetZTIPs()
|
||||
cidrs := []string{
|
||||
"10.147.11.0/24",
|
||||
|
@ -259,6 +260,9 @@ func getZTIP() (ip, start, end, cidr string) {
|
|||
"172.30.0.0/16",
|
||||
}
|
||||
filteredCidrs := make([]string, 0)
|
||||
if len(routes) > 0 {
|
||||
filteredCidrs = append(filteredCidrs, routes)
|
||||
} else {
|
||||
for _, cidr := range cidrs {
|
||||
isExcluded := false
|
||||
for _, excludedIP := range excluded {
|
||||
|
@ -271,6 +275,8 @@ func getZTIP() (ip, start, end, cidr string) {
|
|||
filteredCidrs = append(filteredCidrs, cidr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
ip = ""
|
||||
if len(filteredCidrs) > 0 {
|
||||
|
|
Loading…
Reference in a new issue