resolveTxt returns a 2d array
This commit is contained in:
parent
5417ef9e82
commit
73cfcb6a52
13
cloudron.js
13
cloudron.js
@ -256,11 +256,12 @@ Cloudron.prototype.reboot = function () {
|
||||
};
|
||||
|
||||
Cloudron.prototype.checkSPF = function (callback) {
|
||||
var that = this;
|
||||
dns.resolveTxt(this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
if (records.length !== 1 || records[0].length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' TXT records. Expecting 1 length 2d array'));
|
||||
|
||||
if (records[0].search(new RegExp('^v=spf1 ip4:' + this._box.ip + ' ~all$')) !== 0) return callback(new Error('Bad SPF record. ' + records[0]));
|
||||
if (records[0][0].search(new RegExp('^v=spf1 ip4:' + that._box.ip + ' ~all$')) !== 0) return callback(new Error('Bad SPF record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
@ -269,9 +270,9 @@ Cloudron.prototype.checkSPF = function (callback) {
|
||||
Cloudron.prototype.checkDKIM = function (callback) {
|
||||
dns.resolveTxt('mail._domainkey.' + this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
if (records.length !== 1 || records[0].length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' TXT records. Expecting 1 length 2d array'));
|
||||
|
||||
if (records[0].search(/^"v=DKIM1; t=s; p=.*"$/) !== 0) return callback(new Error('Bad DKIM record. ' + records[0]));
|
||||
if (records[0][0].search(/^"v=DKIM1; t=s; p=.*"$/) !== 0) return callback(new Error('Bad DKIM record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
@ -280,9 +281,9 @@ Cloudron.prototype.checkDKIM = function (callback) {
|
||||
Cloudron.prototype.checkDMARC = function (callback) {
|
||||
dns.resolveTxt('_dmarc.' + this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
if (records.length !== 1 || records[0].length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' TXT records. Expecting 1 length 2d array'));
|
||||
|
||||
if (records[0].search(/^"v=DMARC1; p=none; pct=100; rua=mailto:.*; ruf=.*"$/) !== 0) return callback(new Error('Bad DMARC record. ' + records[0]));
|
||||
if (records[0][0].search(/^"v=DMARC1; p=none; pct=100; rua=mailto:.*; ruf=.*"$/) !== 0) return callback(new Error('Bad DMARC record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user