private bool CheckDomainDns(DnsCheckTaskDto taskDto) { if (string.IsNullOrEmpty(taskDto.domain_name)) { return(false); } try { var dnsLookup = new DnsLookup(); var mxVerified = dnsLookup.IsDomainMxRecordExists(taskDto.domain_name, taskDto.mx_record); var spfVerified = dnsLookup.IsDomainTxtRecordExists(taskDto.domain_name, taskDto.spf); var dkimVerified = dnsLookup.IsDomainDkimRecordExists(taskDto.domain_name, taskDto.dkim_selector, taskDto.dkim_public_key); _log.Info("Domain '{0}' MX={1} SPF={2} DKIM={3}", taskDto.domain_name, mxVerified, spfVerified, dkimVerified); return(mxVerified && spfVerified && dkimVerified); } catch (Exception ex) { _log.Error("CheckDomainDns() Exception: \r\n {0} \r\n", ex.ToString()); } return(false); }
public void DkimExists() { const string domain = "onlyoffice.com"; const string dkim_record = "v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDiblqlVejxACSfc3Y0OzRzyFFtnUHgkw65k+QGjG4WvjmJJQNcfdJNaaLo9xKPIfw9vTRVigZa78KgeYFymGlqXtR0z323EwiHaNh82Qo1oBICOZT2AVjWpPjBUGwD6qTorulmLnY9+YKn1bV8B7mt964ewpPHDDsqaHddhV7hqQIDAQAB"; var dnsLoopup = new DnsLookup(); var exists = dnsLoopup.IsDomainDkimRecordExists(domain, "dkim", dkim_record); Assert.IsTrue(exists); }
public bool CheckDnsStatus(string domainName = "") { var checkDomainName = string.IsNullOrEmpty(DomainName) ? domainName : DomainName; if (string.IsNullOrEmpty(checkDomainName)) { return(false); } var dnsLookup = new DnsLookup(); MxVerified = dnsLookup.IsDomainMxRecordExists(checkDomainName, MxHost); SpfVerified = dnsLookup.IsDomainTxtRecordExists(checkDomainName, SpfRecord); DkimVerified = dnsLookup.IsDomainDkimRecordExists(checkDomainName, DkimSelector, DkimPublicKey); return(MxVerified && SpfVerified && DkimVerified); }
public static bool CheckDnsStatus(this ServerDomainDnsData dnsData, string domain) { if (string.IsNullOrEmpty(domain)) { return(false); } var dnsLookup = new DnsLookup(); var mxVerified = dnsLookup.IsDomainMxRecordExists(domain, dnsData.MxRecord.Host); dnsData.MxRecord.IsVerified = mxVerified; var spfVerified = dnsLookup.IsDomainTxtRecordExists(domain, dnsData.SpfRecord.Value); dnsData.SpfRecord.IsVerified = spfVerified; var dkimVerified = dnsLookup.IsDomainDkimRecordExists(domain, dnsData.DkimRecord.Selector, dnsData.DkimRecord.PublicKey); dnsData.DkimRecord.IsVerified = dkimVerified; return(mxVerified && spfVerified && dkimVerified); }