resolver: lower-case DNS names in record values (closes #157)
check / check (push) Successful in 55s
check / check (push) Successful in 55s
Nameservers may answer with DNS names in any letter case. For eeqj.de, y.ns.joker.com answers in upper case while its peers answer in lower case, so the inconsistency check fired on every cycle. extractRecordValue now lower-cases CNAME, MX, SRV and NS targets, so the inconsistency check and the record-change check both compare names regardless of case. A, AAAA, TXT and CAA values are formatted as before. State saved before this change can hold upper-case names, which report a one-time record change on the first check after upgrading. Model: opus-5-5
This commit is contained in:
@@ -608,7 +608,10 @@ func classifyResponse(resp *NameserverResponse, state queryState) {
|
||||
}
|
||||
}
|
||||
|
||||
// extractRecordValue formats a DNS RR value as a string.
|
||||
// extractRecordValue formats a DNS RR value as a string. DNS names
|
||||
// are case-insensitive and nameservers may answer in any letter case,
|
||||
// so names are lower-cased to compare equal. TXT and CAA values keep
|
||||
// their letter case.
|
||||
func extractRecordValue(rr dns.RR) string {
|
||||
switch r := rr.(type) {
|
||||
case *dns.A:
|
||||
@@ -616,22 +619,22 @@ func extractRecordValue(rr dns.RR) string {
|
||||
case *dns.AAAA:
|
||||
return r.AAAA.String()
|
||||
case *dns.CNAME:
|
||||
return r.Target
|
||||
return strings.ToLower(r.Target)
|
||||
case *dns.MX:
|
||||
return fmt.Sprintf("%d %s", r.Preference, r.Mx)
|
||||
return fmt.Sprintf("%d %s", r.Preference, strings.ToLower(r.Mx))
|
||||
case *dns.TXT:
|
||||
return strings.Join(r.Txt, "")
|
||||
case *dns.SRV:
|
||||
return fmt.Sprintf(
|
||||
"%d %d %d %s",
|
||||
r.Priority, r.Weight, r.Port, r.Target,
|
||||
r.Priority, r.Weight, r.Port, strings.ToLower(r.Target),
|
||||
)
|
||||
case *dns.CAA:
|
||||
return fmt.Sprintf(
|
||||
"%d %s \"%s\"", r.Flag, r.Tag, r.Value,
|
||||
)
|
||||
case *dns.NS:
|
||||
return r.Ns
|
||||
return strings.ToLower(r.Ns)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user