This commit is contained in:
Girish Ramakrishnan
2023-06-30 11:35:34 +05:30
parent 5433552710
commit aea58a2b76

View File

@@ -312,7 +312,7 @@ async function checkSpf(domain, mailFqdn) {
assert.strictEqual(typeof mailFqdn, 'string');
const spf = {
domain: domain,
domain,
name: '@',
type: 'TXT',
value: null,
@@ -350,7 +350,7 @@ async function checkMx(domain, mailFqdn) {
assert.strictEqual(typeof mailFqdn, 'string');
const mx = {
domain: domain,
domain,
name: '@',
type: 'MX',
value: null,
@@ -395,7 +395,7 @@ function txtToDict(txt) {
async function checkDmarc(domain) {
const dmarc = {
domain: '_dmarc.' + domain,
domain: `_dmarc.${domain}`,
name: '_dmarc',
type: 'TXT',
value: null,
@@ -923,17 +923,17 @@ async function upsertDnsRecords(domain, mailFqdn) {
const publicKey = mailDomain.dkimKey.publicKey.split('\n').slice(1, -2).join(''); // remove header, footer and new lines
// t=s limits the domainkey to this domain and not it's subdomains
const dkimRecord = { subdomain: `${mailDomain.dkimSelector}._domainkey`, domain: domain, type: 'TXT', values: [ `"v=DKIM1; t=s; p=${publicKey}"` ] };
const dkimRecord = { subdomain: `${mailDomain.dkimSelector}._domainkey`, domain, type: 'TXT', values: [ `"v=DKIM1; t=s; p=${publicKey}"` ] };
const records = [];
records.push(dkimRecord);
if (mailDomain.enabled) records.push({ subdomain: '', domain: domain, type: 'MX', values: [ '10 ' + mailFqdn + '.' ] });
if (mailDomain.enabled) records.push({ subdomain: '', domain, type: 'MX', values: [ '10 ' + mailFqdn + '.' ] });
const txtRecords = await txtRecordsWithSpf(domain, mailFqdn);
if (txtRecords) records.push({ subdomain: '', domain: domain, type: 'TXT', values: txtRecords });
if (txtRecords) records.push({ subdomain: '', domain, type: 'TXT', values: txtRecords });
const dmarcRecords = await dns.getDnsRecords('_dmarc', domain, 'TXT'); // only update dmarc if absent. this allows user to set email for reporting
if (dmarcRecords.length === 0) records.push({ subdomain: '_dmarc', domain: domain, type: 'TXT', values: [ '"v=DMARC1; p=reject; pct=100"' ] });
if (dmarcRecords.length === 0) records.push({ subdomain: '_dmarc', domain, type: 'TXT', values: [ '"v=DMARC1; p=reject; pct=100"' ] });
debug(`upsertDnsRecords: will update ${domain} with ${JSON.stringify(records)}`);