File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -102,20 +102,26 @@ func hostsToIPAndDNS(hosts []string) ([]net.IP, []string) {
102
102
ips := []net.IP {}
103
103
dnsNames := []string {}
104
104
for _ , host := range hosts {
105
+ if host == "" {
106
+ continue
107
+ }
105
108
host := host
106
109
ip := net .ParseIP (host )
107
110
if ip != nil {
108
111
ips = append (ips , ip )
109
112
} else {
110
113
dnsNames = append (dnsNames , host )
111
-
112
114
for _ , network := range []string {"ip4" , "ip6" } {
113
115
addr , err := net .ResolveIPAddr (network , host )
114
- if err == nil {
115
- ips = append (ips , addr .IP )
116
- } else {
116
+ if err != nil {
117
117
log .Logf (10 , "failed to resolve %s: %s" , host , err )
118
+ continue
119
+ }
120
+ if addr == nil || addr .IP == nil {
121
+ log .Logf (10 , "failed to resolve %s: nil address returned" , host )
122
+ continue
118
123
}
124
+ ips = append (ips , addr .IP )
119
125
}
120
126
}
121
127
}
You can’t perform that action at this time.
0 commit comments