Compare commits

..

2 Commits

Author SHA1 Message Date
be42e60731 test: Disable CNAME lookup caching
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-06 19:53:03 +01:00
cb40a0689b feat: Add more logging to CNAME resolution 2024-01-06 19:52:12 +01:00
2 changed files with 2 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package dns package dns
import ( import (
"errors"
"net" "net"
"strings" "strings"
"time" "time"
@ -59,10 +58,6 @@ func LookupRepoTXT(domain string) (string, error) {
func LookupCNAME(domain string) (string, error) { func LookupCNAME(domain string) (string, error) {
cname, found := cnameCache.Get(domain) cname, found := cnameCache.Get(domain)
if found { if found {
if cname == "" {
return "", errors.New("Previous request failure")
}
return cname.(string), nil return cname.(string), nil
} }
@ -72,6 +67,5 @@ func LookupCNAME(domain string) (string, error) {
return cname.(string), nil return cname.(string), nil
} }
cnameCache.Set(domain, "", cache.DefaultExpiration)
return "", err return "", err
} }

View File

@ -73,9 +73,9 @@ func MakeTlsConfig(pagesDomain, cachePath string, cache *certificates.Certificat
// Note: We do not check err here because err != nil // Note: We do not check err here because err != nil
// always implies that cname == "", which does not have // always implies that cname == "", which does not have
// pagesDomain as a suffix. // pagesDomain as a suffix.
cname, _ = dns.LookupCNAME(info.ServerName) cname, err := dns.LookupCNAME(info.ServerName)
if !strings.HasSuffix(cname, pagesDomain) { if !strings.HasSuffix(cname, pagesDomain) {
log.Warnf("Got ServerName for Domain %s that we're not responsible for", info.ServerName) log.Warnf("Got ServerName for Domain %s that we're not responsible for. CNAME '%s', err: %v", info.ServerName, cname, err)
return cache.FallbackCertificate.TlsCertificate, nil return cache.FallbackCertificate.TlsCertificate, nil
} }
} }