public async Task <SpfPollResult> Process(string domain) { Stopwatch stopwatch = Stopwatch.StartNew(); DnsResult <List <List <string> > > spfDnsRecords = await _dnsClient.GetSpfRecords(domain); if (!_config.AllowNullResults && (spfDnsRecords.IsErrored || spfDnsRecords.Value.Count == 0 || spfDnsRecords.Value.TrueForAll(x => x.TrueForAll(string.IsNullOrWhiteSpace)))) { throw new SpfPollerException($"Unable to retrieve spf records for {domain}."); } if (spfDnsRecords.IsErrored) { string message = string.Format(SpfProcessorResource.FailedSpfRecordQueryErrorMessage, domain, spfDnsRecords.Error); string markdown = string.Format(SpfProcessorMarkdownResource.FailedSpfRecordQueryErrorMessage, domain, spfDnsRecords.Error); Guid id = Guid.Parse("76390C8C-12D5-47FF-981E-D880D2B77216"); return(new SpfPollResult(new Error(id, ErrorType.Error, message, markdown))); } SpfRecords root = await _spfRecordsParser.Parse(domain, spfDnsRecords.Value, spfDnsRecords.MessageSize); int lookupCount = await _spfRecordExpander.ExpandSpfRecords(domain, root); SpfPollResult pollResult = new SpfPollResult(root, lookupCount, stopwatch.Elapsed); EvaluationResult <SpfPollResult> errors = await _pollResultRulesEvaluator.Evaluate(pollResult); pollResult.Errors.AddRange(errors.Errors); return(pollResult); }
public async Task <SpfRecords> Process(string domain, Term term) { Redirect redirect = term as Redirect; DnsResult <List <List <string> > > spfDnsRecords = await _dnsClient.GetSpfRecords(redirect.DomainSpec.Domain); if (spfDnsRecords.IsErrored) { string message = string.Format(SpfExpansionResource.FailedSpfRecordQueryErrorMessage, redirect.DomainSpec.Domain, spfDnsRecords.Error); string markdown = string.Format(SpfExpansionMarkdownResource.FailedSpfRecordQueryErrorMessage, redirect.DomainSpec.Domain, spfDnsRecords.Error); term.AddError(new Error(Id, ErrorType.Error, message, markdown)); return(null); } redirect.Records = await _recordsParser.Parse(redirect.DomainSpec.Domain, spfDnsRecords.Value, spfDnsRecords.MessageSize); return(redirect.Records); }