Skip to content

Commit

Permalink
fix GetHostIP func
Browse files Browse the repository at this point in the history
  • Loading branch information
mdutka-dell committed Feb 13, 2024
1 parent c052e93 commit b57be36
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions service/utils/emcutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ func GetHostIP() ([]string, error) {
var lookupIps []string
for _, ip := range ips {
lookupResp, err := net.LookupAddr(ip)
if err == nil && strings.Contains(lookupResp[0], hostname) {
lookupIps = append(lookupIps, ip)
if err == nil {
for _, resp := range lookupResp {
if strings.Contains(resp, hostname) {
lookupIps = append(lookupIps, ip)
}
}
}
}
if len(lookupIps) == 0 {
lookupIps = append(lookupIps, ips[0])
return nil, errors.New("host ip not found")
}
return lookupIps, nil
}
Expand Down

0 comments on commit b57be36

Please sign in to comment.