Skip to content

Commit

Permalink
When a fixed IP is used and the hostname is invalid, no exception is …
Browse files Browse the repository at this point in the history
…thrown.
  • Loading branch information
wesky2012 committed Nov 18, 2024
1 parent bbc003d commit bfcae95
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fastdialer/dialer_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ func (d *Dialer) dial(ctx context.Context, opts *dialOptions) (conn net.Conn, er

// check if data is in cache
hostname = asAscii(hostname)
data, err := d.GetDNSData(hostname)
if err != nil {
// otherwise attempt to retrieve it
data, err = d.dnsclient.Resolve(hostname)
}
if data == nil {
return nil, ResolveHostError
}
if err != nil || len(data.A)+len(data.AAAA) == 0 {
return nil, NoAddressFoundError
}

// use fixed ip as first
if fixedIP != "" {
IPS = append(IPS, fixedIP)
} else {
data, err := d.GetDNSData(hostname)
if err != nil {
// otherwise attempt to retrieve it
data, err = d.dnsclient.Resolve(hostname)
}
if data == nil {
return nil, ResolveHostError
}
if err != nil || len(data.A)+len(data.AAAA) == 0 {
return nil, NoAddressFoundError
}
IPS = append(IPS, append(data.A, data.AAAA...)...)
}

Expand Down

0 comments on commit bfcae95

Please sign in to comment.