Skip to content

Commit

Permalink
feat: select lowest ttl for A record
Browse files Browse the repository at this point in the history
  • Loading branch information
red55 committed May 14, 2024
1 parent 295bcc0 commit 1110ce9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/dns/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ func Resolve(de /*in, out*/ *Entry) error {

de.ips = append(de.ips, a.A.String())
}

if ttl < cfg.AppCfg.Timeouts().TtlForZero() {
log.L().Debugf("Entry %s has ttl less than %d, so adjust it to default %d", de.Fqdn(),
cfg.AppCfg.Timeouts().TtlForZero(), cfg.AppCfg.Timeouts().TtlForZero())
ttl = cfg.AppCfg.Timeouts().TtlForZero()
}
de.SetTtl(ttl)
}
if ttl < cfg.AppCfg.Timeouts().TtlForZero() {
log.L().Debugf("Entry %s has ttl %d, so adjust it to default %d", de.Fqdn(),
ttl, cfg.AppCfg.Timeouts().TtlForZero())
ttl = cfg.AppCfg.Timeouts().TtlForZero()
}
de.SetTtl(ttl)

log.L().Debugf("Resolved: %v", de)

} else {
if r.Rcode != dns.RcodeSuccess {
return fmt.Errorf("DNS server answered bad RCode %d, %w ", r.Rcode, &errNXName{})
Expand Down

0 comments on commit 1110ce9

Please sign in to comment.