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) {
102102 ips := []net.IP {}
103103 dnsNames := []string {}
104104 for _ , host := range hosts {
105+ if host == "" {
106+ continue
107+ }
105108 host := host
106109 ip := net .ParseIP (host )
107110 if ip != nil {
108111 ips = append (ips , ip )
109112 } else {
110113 dnsNames = append (dnsNames , host )
111-
112114 for _ , network := range []string {"ip4" , "ip6" } {
113115 addr , err := net .ResolveIPAddr (network , host )
114- if err == nil {
115- ips = append (ips , addr .IP )
116- } else {
116+ if err != nil {
117117 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
118123 }
124+ ips = append (ips , addr .IP )
119125 }
120126 }
121127 }
You can’t perform that action at this time.
0 commit comments