fix: Handle CNAMEs with a trailing dot
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2024-01-06 20:00:55 +01:00
parent be42e60731
commit 2fb1e36b06

View File

@ -61,10 +61,13 @@ func LookupCNAME(domain string) (string, error) {
return cname.(string), nil
}
cname, err := net.LookupCNAME(domain)
query, err := net.LookupCNAME(domain)
if err == nil {
cnameCache.Set(domain, cname, cache.DefaultExpiration)
return cname.(string), nil
if query[len(query)-1] == '.' {
query = query[:len(query)-1]
}
cnameCache.Set(domain, query, cache.DefaultExpiration)
return query, nil
}
return "", err