mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/kube-vip/kube-vip.git
synced 2026-09-20 08:03:47 +08:00
Merge pull request #1064 from kube-vip/resolver
Resolver, this will ensure that an address that is not an IP address is resolved first to determine the CIDR
This commit is contained in:
@@ -60,7 +60,7 @@ var kubeManifestPod = &cobra.Command{
|
||||
if initConfig.VIPCIDR == "" && initConfig.Address != "" {
|
||||
initConfig.VIPCIDR, err = GenerateCidrRange(initConfig.Address)
|
||||
if err != nil {
|
||||
log.Error("No interface is specified for kube-vip to bind to")
|
||||
log.Error("config parse", "err", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ var kubeManifestDaemon = &cobra.Command{
|
||||
if initConfig.VIPCIDR == "" && initConfig.Address != "" {
|
||||
initConfig.VIPCIDR, err = GenerateCidrRange(initConfig.Address)
|
||||
if err != nil {
|
||||
log.Error("No interface is specified for kube-vip to bind to")
|
||||
log.Error("config parse", "err", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,9 +463,12 @@ func GenerateCidrRange(address string) (string, error) {
|
||||
addresses := strings.Split(address, ",")
|
||||
for _, a := range addresses {
|
||||
ip := net.ParseIP(a)
|
||||
|
||||
if ip == nil {
|
||||
return "", fmt.Errorf("invalid IP address: %s from [%s]", a, address)
|
||||
ips, err := net.LookupIP(a)
|
||||
if len(ips) == 0 || err != nil {
|
||||
return "", fmt.Errorf("invalid IP address: %s from [%s], %v", a, address, err)
|
||||
}
|
||||
ip = ips[0]
|
||||
}
|
||||
|
||||
if ip.To4() != nil {
|
||||
|
||||
Reference in New Issue
Block a user