Add a way to re-sync mail DNS records

Also, make restore resync the admin domain record which gets messed
up by the dns setup
This commit is contained in:
Girish Ramakrishnan
2018-03-08 17:26:07 -08:00
parent f284245e16
commit 6bc5add023
4 changed files with 44 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ exports = module.exports = {
add: add,
del: del,
update: update,
setMailFromValidation: setMailFromValidation,
setCatchAllAddress: setCatchAllAddress,
@@ -635,12 +636,19 @@ function txtRecordsWithSpf(domain, callback) {
function ensureDkimKeySync(domain) {
assert.strictEqual(typeof domain, 'string');
debug(`Generating new DKIM keys for ${domain}`);
const dkimPath = path.join(paths.MAIL_DATA_DIR, `dkim/${domain}`);
const dkimPrivateKeyFile = path.join(dkimPath, 'private');
const dkimPublicKeyFile = path.join(dkimPath, 'public');
const dkimSelectorFile = path.join(dkimPath, 'selector');
var dkimPath = path.join(paths.MAIL_DATA_DIR, `dkim/${domain}`);
var dkimPrivateKeyFile = path.join(dkimPath, 'private');
var dkimPublicKeyFile = path.join(dkimPath, 'public');
var dkimSelectorFile = path.join(dkimPath, 'selector');
if (safe.fs.existsSync(dkimPublicKeyFile) &&
safe.fs.existsSync(dkimPublicKeyFile) &&
safe.fs.existsSync(dkimPublicKeyFile)) {
debug(`Reusing existing DKIM keys for ${domain}`);
return null;
}
debug(`Generating new DKIM keys for ${domain}`);
if (!safe.fs.mkdirSync(dkimPath) && safe.error.code !== 'EEXIST') {
debug('Error creating dkim.', safe.error);
@@ -734,6 +742,20 @@ function add(domain, callback) {
});
}
// this is just a way to resync the mail "dns" records via the UI
function update(domain, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof callback, 'function');
get(domain, function (error) {
if (error) return callback(error);
addDnsRecords(domain, NOOP_CALLBACK);
callback();
});
}
function del(domain, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof callback, 'function');