check / check (push) Successful in 1m6s
For a name with a CNAME, a nameserver answers a query of any type with that CNAME, and the records of every answer were added, so the CNAME was stored once for each of the eight record types asked for. collectAnswerRecords now adds each value once per record type. A state file saved before this holds the repeated values. Load keeps each record value once, so the first check after upgrading sees no record change and notifies nothing for them. Model: opus-5-5
78 lines
1.8 KiB
Go
78 lines
1.8 KiB
Go
package resolver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
// ExtractRecordValue exports extractRecordValue for testing.
|
|
func ExtractRecordValue(rr dns.RR) string {
|
|
return extractRecordValue(rr)
|
|
}
|
|
|
|
// CollectAnswerRecords exports collectAnswerRecords for testing.
|
|
func CollectAnswerRecords(msg *dns.Msg, resp *NameserverResponse) {
|
|
var state queryState
|
|
|
|
collectAnswerRecords(msg, resp, &state)
|
|
}
|
|
|
|
// UsableReply exports usableReply for testing.
|
|
func UsableReply(resp *dns.Msg, zone string, name string) bool {
|
|
return usableReply(resp, zone, name)
|
|
}
|
|
|
|
// NSSetFrom exports nsSetFrom for testing.
|
|
func NSSetFrom(resp *dns.Msg, domain string) []string {
|
|
return nsSetFrom(resp, domain)
|
|
}
|
|
|
|
// CollectIPs exports collectIPs for testing.
|
|
func CollectIPs(
|
|
results map[string]*NameserverResponse,
|
|
) ([]string, string, error) {
|
|
return collectIPs(results)
|
|
}
|
|
|
|
// QueryServers exports queryServers for testing.
|
|
func (r *Resolver) QueryServers(
|
|
ctx context.Context,
|
|
servers []string,
|
|
zone string,
|
|
name string,
|
|
qtype uint16,
|
|
) (*dns.Msg, error) {
|
|
return r.queryServers(ctx, servers, zone, name, qtype)
|
|
}
|
|
|
|
// QueryEachNS exports queryEachNS for testing.
|
|
func (r *Resolver) QueryEachNS(
|
|
ctx context.Context,
|
|
nameservers []string,
|
|
hostname string,
|
|
) (map[string]*NameserverResponse, error) {
|
|
return r.queryEachNS(ctx, nameservers, hostname, recordTypes())
|
|
}
|
|
|
|
// ResolveNSIPs exports resolveNSIPs for testing.
|
|
func (r *Resolver) ResolveNSIPs(
|
|
ctx context.Context,
|
|
nsNames []string,
|
|
) []string {
|
|
return r.resolveNSIPs(ctx, nsNames)
|
|
}
|
|
|
|
// RootServerList exports rootServerList for testing.
|
|
func RootServerList() []string {
|
|
return rootServerList()
|
|
}
|
|
|
|
// Shuffled exports shuffled for testing.
|
|
func Shuffled(
|
|
servers []string,
|
|
shuffle func(n int, swap func(i, j int)),
|
|
) []string {
|
|
return shuffled(servers, shuffle)
|
|
}
|