check mx records

This commit is contained in:
Girish Ramakrishnan 2016-05-17 23:31:50 -07:00
parent dd4404ddc2
commit 1933bc79b9
3 changed files with 16 additions and 1 deletions

View File

@ -395,6 +395,18 @@ Cloudron.prototype.checkSPF = function (callback) {
});
};
Cloudron.prototype.checkMX = function (callback) {
var that = this;
dns.resolveMx(this._box.domain, function (error, records) {
if (error) return callback(error);
if (records.length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' MX records. Expecting 1 length array'));
if (records[0].exchange !== this._adminFqdn) return callback(new Error('Bad MX record. ' + records[0]));
callback(null, records);
});
};
Cloudron.prototype.checkDKIM = function (callback) {
dns.resolveTxt('cloudron._domainkey.' + this._box.domain, function (error, records) {
if (error) return callback(error);

View File

@ -159,6 +159,7 @@ describe('Custom domain test', function () {
// cloudron.checkA.bind(cloudron), // this is at user's discretion
cloudron.checkSPF.bind(cloudron),
cloudron.checkDKIM.bind(cloudron),
cloudron.checkMX.bind(cloudron),
// cloudron.checkDMARC.bind(cloudron)
], done);
});

View File

@ -87,6 +87,7 @@ describe('Appstore new user flow', function () {
async.series([
cloudron.checkA.bind(cloudron),
cloudron.checkSPF.bind(cloudron),
cloudron.checkMX.bind(cloudron),
cloudron.checkDKIM.bind(cloudron),
cloudron.checkDMARC.bind(cloudron)
], done);
@ -113,7 +114,8 @@ describe('Appstore new user flow', function () {
expectError('checkA', cloudron.checkA.bind(cloudron)),
expectError('checkSPF', cloudron.checkSPF.bind(cloudron)),
expectError('checkDKIM', cloudron.checkDKIM.bind(cloudron)),
expectError('checkDMARC', cloudron.checkDMARC.bind(cloudron))
expectError('checkDMARC', cloudron.checkDMARC.bind(cloudron)),
expectError('checkMX', cloudron.checkMX.bind(cloudron))
], done);
});