fix: ensure ipv4 is checked, not sometimes ipv6

See coop-cloud/organising#490
This commit is contained in:
2023-10-04 03:24:30 +02:00
committed by decentral1se
parent 379915587c
commit 422c642949
2 changed files with 35 additions and 4 deletions

View File

@ -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
}