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

Method relyOnDMARC

internal/check/spf/spf.go:243–268  ·  view source on GitHub ↗
(ctx context.Context, hdr textproto.Header)

Source from the content-addressed store, hash-verified

241}
242
243func (s *state) relyOnDMARC(ctx context.Context, hdr textproto.Header) bool {
244 fromDomain, err := maddydmarc.ExtractFromDomain(hdr)
245 if err != nil {
246 s.log.Error("DMARC domains extract", err)
247 return false
248 }
249
250 policyDomain, record, err := maddydmarc.FetchRecord(ctx, s.c.resolver, fromDomain)
251 if err != nil {
252 s.log.Error("DMARC fetch", err, "from_domain", fromDomain)
253 return false
254 }
255 if record == nil {
256 return false
257 }
258
259 policy := record.Policy
260 // We check for subdomain using non-equality since fromDomain is either the
261 // subdomain of policyDomain or policyDomain itself (due to the way
262 // FetchRecord handles it).
263 if !dns.Equal(policyDomain, fromDomain) && record.SubdomainPolicy != "" {
264 policy = record.SubdomainPolicy
265 }
266
267 return policy != dmarc.PolicyNone
268}
269
270func prepareMailFrom(from string) (string, error) {
271 // INTERNATIONALIZATION: RFC 8616, Section 4

Callers 1

CheckBodyMethod · 0.95

Calls 3

EqualFunction · 0.92
FetchRecordMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected