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 := ""
|
networkId := ""
|
||||||
address := ""
|
address := ""
|
||||||
networkNames := gjson.ParseBytes(respBody).Array()
|
networkNames := gjson.ParseBytes(respBody).Array()
|
||||||
|
routers := ""
|
||||||
for _, v := range networkNames {
|
for _, v := range networkNames {
|
||||||
res, err := httper.ZTGet("/controller/network/" + v.Str)
|
res, err := httper.ZTGet("/controller/network/" + v.Str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -100,10 +100,11 @@ func CheckNetwork() {
|
||||||
name := gjson.GetBytes(res, "name").Str
|
name := gjson.GetBytes(res, "name").Str
|
||||||
if name == common.RANW_NAME {
|
if name == common.RANW_NAME {
|
||||||
networkId = gjson.GetBytes(res, "id").Str
|
networkId = gjson.GetBytes(res, "id").Str
|
||||||
|
routers = gjson.GetBytes(res, "routes.0.target").Str
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ip, s, e, c := getZTIP()
|
ip, s, e, c := getZTIP(routers)
|
||||||
logger.Info("ip", zap.Any("ip", ip))
|
logger.Info("ip", zap.Any("ip", ip))
|
||||||
if len(networkId) == 0 {
|
if len(networkId) == 0 {
|
||||||
if len(address) == 0 {
|
if len(address) == 0 {
|
||||||
|
@ -224,7 +225,7 @@ func GetZTIPs() []gjson.Result {
|
||||||
return a.Array()
|
return a.Array()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getZTIP() (ip, start, end, cidr string) {
|
func getZTIP(routes string) (ip, start, end, cidr string) {
|
||||||
excluded := GetZTIPs()
|
excluded := GetZTIPs()
|
||||||
cidrs := []string{
|
cidrs := []string{
|
||||||
"10.147.11.0/24",
|
"10.147.11.0/24",
|
||||||
|
@ -259,18 +260,23 @@ func getZTIP() (ip, start, end, cidr string) {
|
||||||
"172.30.0.0/16",
|
"172.30.0.0/16",
|
||||||
}
|
}
|
||||||
filteredCidrs := make([]string, 0)
|
filteredCidrs := make([]string, 0)
|
||||||
for _, cidr := range cidrs {
|
if len(routes) > 0 {
|
||||||
isExcluded := false
|
filteredCidrs = append(filteredCidrs, routes)
|
||||||
for _, excludedIP := range excluded {
|
} else {
|
||||||
if cidr == excludedIP.Str {
|
for _, cidr := range cidrs {
|
||||||
isExcluded = true
|
isExcluded := false
|
||||||
break
|
for _, excludedIP := range excluded {
|
||||||
|
if cidr == excludedIP.Str {
|
||||||
|
isExcluded = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !isExcluded {
|
||||||
|
filteredCidrs = append(filteredCidrs, cidr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isExcluded {
|
|
||||||
filteredCidrs = append(filteredCidrs, cidr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
ip = ""
|
ip = ""
|
||||||
if len(filteredCidrs) > 0 {
|
if len(filteredCidrs) > 0 {
|
||||||
|
|
Loading…
Reference in a new issue