forked from toolshed/abra
fix: ensure ipv4 is checked, not sometimes ipv6
See coop-cloud/organising#490
This commit is contained in:
@ -7,11 +7,16 @@ import (
|
||||
|
||||
// EnsureIPv4 ensures that an ipv4 address is set for a domain name
|
||||
func EnsureIPv4(domainName string) (string, error) {
|
||||
ipv4, err := net.ResolveIPAddr("ip", domainName)
|
||||
ipv4, err := net.ResolveIPAddr("ip4", domainName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// NOTE(d1): e.g. when there is only an ipv6 record available
|
||||
if ipv4 == nil {
|
||||
return "", fmt.Errorf("unable to resolve ipv4 address for %s", domainName)
|
||||
}
|
||||
|
||||
return ipv4.String(), nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user