FetchRecord prepares the Verifier by starting the policy lookup. Lookup is performed asynchronously to improve performance. If panic occurs in the lookup goroutine - call to Apply will panic.
(ctx context.Context, header textproto.Header)
| 82 | // |
| 83 | // If panic occurs in the lookup goroutine - call to Apply will panic. |
| 84 | func (v *Verifier) FetchRecord(ctx context.Context, header textproto.Header) { |
| 85 | fromDomain, err := ExtractFromDomain(header) |
| 86 | if err != nil { |
| 87 | v.fetchCh <- verifyData{ |
| 88 | recordErr: err, |
| 89 | } |
| 90 | return |
| 91 | } |
| 92 | |
| 93 | ctx, v.fetchCancel = context.WithCancel(ctx) |
| 94 | go func() { |
| 95 | defer func() { |
| 96 | if err := recover(); err != nil { |
| 97 | v.fetchCh <- verifyData{ |
| 98 | recordErr: errPanic{err: err}, |
| 99 | } |
| 100 | } |
| 101 | }() |
| 102 | |
| 103 | defer trace.StartRegion(ctx, "DMARC/FetchRecord").End() |
| 104 | |
| 105 | policyDomain, record, err := FetchRecord(ctx, v.resolver, fromDomain) |
| 106 | v.fetchCh <- verifyData{ |
| 107 | policyDomain: policyDomain, |
| 108 | fromDomain: fromDomain, |
| 109 | record: record, |
| 110 | recordErr: err, |
| 111 | } |
| 112 | }() |
| 113 | } |
| 114 | |
| 115 | // Apply actually performs all actions necessary to apply a DMARC policy to the message. |
| 116 | // |