MCPcopy Create free account
hub / github.com/foxcpp/maddy / CheckCNAMEAD

Method CheckCNAMEAD

framework/dns/dnssec.go:211–248  ·  view source on GitHub ↗

CheckCNAMEAD is a special function for use in DANE lookups. It attempts to determine final (canonical) name of the host and also reports whether the whole chain of CNAME's and final zone are "secure". If there are no A or AAAA records for host, rname = "" is returned.

(ctx context.Context, host string)

Source from the content-addressed store, hash-verified

209//
210// If there are no A or AAAA records for host, rname = "" is returned.
211func (e ExtResolver) CheckCNAMEAD(ctx context.Context, host string) (ad bool, rname string, err error) {
212 msg := new(dns.Msg)
213 msg.SetQuestion(dns.Fqdn(host), dns.TypeA)
214 msg.SetEdns0(4096, false)
215 msg.AuthenticatedData = true
216 resp, err := e.exchange(ctx, msg)
217 if err != nil {
218 return false, "", err
219 }
220
221 for _, r := range resp.Answer {
222 switch r := r.(type) {
223 case *dns.A:
224 rname = r.Hdr.Name
225 ad = resp.AuthenticatedData // Use AD flag from response we used to determine rname
226 }
227 }
228
229 if rname == "" {
230 // IPv6-only host? Try to find out rname using AAAA lookup.
231 msg := new(dns.Msg)
232 msg.SetQuestion(dns.Fqdn(host), dns.TypeAAAA)
233 msg.SetEdns0(4096, false)
234 msg.AuthenticatedData = true
235 resp, err := e.exchange(ctx, msg)
236 if err == nil {
237 for _, r := range resp.Answer {
238 switch r := r.(type) {
239 case *dns.AAAA:
240 rname = r.Hdr.Name
241 ad = resp.AuthenticatedData
242 }
243 }
244 }
245 }
246
247 return ad, rname, nil
248}
249
250func (e ExtResolver) AuthLookupCNAME(ctx context.Context, host string) (ad bool, cname string, err error) {
251 msg := new(dns.Msg)

Callers

nothing calls this directly

Calls 1

exchangeMethod · 0.95

Tested by

no test coverage detected