@@ -10,7 +10,7 @@ exports = module.exports = {
|
||||
getCloudronAvatar: getCloudronAvatar,
|
||||
setCloudronAvatar: setCloudronAvatar,
|
||||
|
||||
getEmailDnsRecords: getEmailDnsRecords,
|
||||
getEmailStatus: getEmailStatus,
|
||||
|
||||
getDnsConfig: getDnsConfig,
|
||||
setDnsConfig: setDnsConfig,
|
||||
@@ -150,8 +150,8 @@ function getCloudronAvatar(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function getEmailDnsRecords(req, res, next) {
|
||||
settings.getEmailDnsRecords(function (error, records) {
|
||||
function getEmailStatus(req, res, next) {
|
||||
settings.getEmailStatus(function (error, records) {
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, records));
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ function initializeExpressSync() {
|
||||
router.post('/api/v1/settings/cloudron_name', settingsScope, routes.user.requireAdmin, routes.settings.setCloudronName);
|
||||
router.get ('/api/v1/settings/cloudron_avatar', settingsScope, routes.user.requireAdmin, routes.settings.getCloudronAvatar);
|
||||
router.post('/api/v1/settings/cloudron_avatar', settingsScope, routes.user.requireAdmin, multipart, routes.settings.setCloudronAvatar);
|
||||
router.get ('/api/v1/settings/email_dns_records', settingsScope, routes.user.requireAdmin, routes.settings.getEmailDnsRecords);
|
||||
router.get ('/api/v1/settings/email_status', settingsScope, routes.user.requireAdmin, routes.settings.getEmailStatus);
|
||||
router.get ('/api/v1/settings/dns_config', settingsScope, routes.user.requireAdmin, routes.settings.getDnsConfig);
|
||||
router.post('/api/v1/settings/dns_config', settingsScope, routes.user.requireAdmin, routes.settings.setDnsConfig);
|
||||
router.get ('/api/v1/settings/backup_config', settingsScope, routes.user.requireAdmin, routes.settings.getBackupConfig);
|
||||
|
||||
+45
-5
@@ -6,7 +6,7 @@ exports = module.exports = {
|
||||
initialize: initialize,
|
||||
uninitialize: uninitialize,
|
||||
|
||||
getEmailDnsRecords: getEmailDnsRecords,
|
||||
getEmailStatus: getEmailStatus,
|
||||
|
||||
getAutoupdatePattern: getAutoupdatePattern,
|
||||
setAutoupdatePattern: setAutoupdatePattern,
|
||||
@@ -74,6 +74,7 @@ var assert = require('assert'),
|
||||
cloudron = require('./cloudron.js'),
|
||||
CloudronError = cloudron.CloudronError,
|
||||
moment = require('moment-timezone'),
|
||||
net = require('net'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
settingsdb = require('./settingsdb.js'),
|
||||
@@ -143,10 +144,10 @@ function uninitialize(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
function getEmailDnsRecords(callback) {
|
||||
function getEmailStatus(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
var records = {};
|
||||
var records = {}, outboundPort25 = {};
|
||||
|
||||
var dkimKey = cloudron.readDkimPublicKeySync();
|
||||
if (!dkimKey) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, new Error('Failed to read dkim public key')));
|
||||
@@ -279,6 +280,44 @@ function getEmailDnsRecords(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function checkOutbound25(callback) {
|
||||
var smtpServer = _.sample([
|
||||
'smtp.gmail.com',
|
||||
'smtp.live.com',
|
||||
'smtp.mail.yahoo.com',
|
||||
'smtp.o2.ie',
|
||||
'smtp.comcast.net',
|
||||
'outgoing.verizon.net'
|
||||
]);
|
||||
|
||||
outboundPort25 = {
|
||||
value: 'OK',
|
||||
status: false
|
||||
};
|
||||
|
||||
var client = new net.Socket();
|
||||
client.setTimeout(5000);
|
||||
client.connect(25, smtpServer);
|
||||
client.on('connect', function () {
|
||||
outboundPort25.status = true;
|
||||
outboundPort25.value = 'OK';
|
||||
client.end();
|
||||
callback();
|
||||
});
|
||||
client.on('timeout', function () {
|
||||
outboundPort25.status = false;
|
||||
outboundPort25.value = 'Connect to ' + smtpServer + ' timed out';
|
||||
client.destroy();
|
||||
callback(new Error('Timeout'));
|
||||
});
|
||||
client.on('error', function (error) {
|
||||
outboundPort25.status = false;
|
||||
outboundPort25.value = 'Connect to ' + smtpServer + ' failed: ' + error.message;
|
||||
client.destroy();
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
|
||||
function ignoreError(what, func) {
|
||||
return function (callback) {
|
||||
func(function (error) {
|
||||
@@ -298,9 +337,10 @@ function getEmailDnsRecords(callback) {
|
||||
ignoreError('spf', checkSpf),
|
||||
ignoreError('dmarc', checkDmarc),
|
||||
ignoreError('dkim', checkDkim),
|
||||
ignoreError('ptr', checkPtr)
|
||||
ignoreError('ptr', checkPtr),
|
||||
ignoreError('port25', checkOutbound25)
|
||||
], function () {
|
||||
callback(null, records);
|
||||
callback(null, { dns: records, outboundPort25: outboundPort25 } );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -440,8 +440,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.getExpectedDnsRecords = function (callback) {
|
||||
get('/api/v1/settings/email_dns_records').success(function(data, status) {
|
||||
Client.prototype.getEmailStatus = function (callback) {
|
||||
get('/api/v1/settings/email_status').success(function(data, status) {
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
callback(null, data);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
|
||||
@@ -76,10 +76,10 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
|
||||
if (result.provider === 'caas') return;
|
||||
|
||||
Client.getExpectedDnsRecords(function (error, result) {
|
||||
Client.getEmailStatus(function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
if (!result.spf.status || !result.dkim.status || !result.ptr.status) {
|
||||
if (!result.dns.spf.status || !result.dns.dkim.status || !result.dns.ptr.status || !result.outboundPort25.status) {
|
||||
var actionScope = $scope.$new(true);
|
||||
actionScope.action = '/#/settings';
|
||||
|
||||
|
||||
@@ -319,6 +319,21 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-if="mailConfig.enabled">
|
||||
<div class="col-xs-12">
|
||||
<h4 class="text-muted">
|
||||
Outbound SMTP (Port 25) <i ng-class="outboundPort25.status ? 'fa fa-check-circle text-success' : 'fa fa-exclamation-triangle text-danger'" aria-hidden="true"></i>
|
||||
<button class="btn btn-xs btn-default" ng-click="email.refresh()" ng-disabled="email.refreshBusy" ng-show="!outboundPort25.status"><i class="fa fa-refresh" ng-class="{ 'fa-pulse': email.refreshBusy }"></i></button>
|
||||
</h4>
|
||||
<a href="" data-toggle="collapse" data-parent="#accordion" data-target="#collapse_dns_{{ record.value }}">Advanced</a>
|
||||
<div id="collapse_dns_{{ record.value }}" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<p><b> {{ outboundPort25.value }} </b> </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
@@ -8,6 +8,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.backupConfig = {};
|
||||
$scope.dnsConfig = {};
|
||||
$scope.outboundPort25 = {};
|
||||
$scope.expectedDnsRecords = {};
|
||||
$scope.expectedDnsRecordsTypes = [
|
||||
{ name: 'MX', value: 'mx' },
|
||||
@@ -509,10 +510,11 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
function showExpectedDnsRecords(callback) {
|
||||
callback = callback || function (error) { if (error) console.error(error); };
|
||||
|
||||
Client.getExpectedDnsRecords(function (error, dnsRecords) {
|
||||
Client.getEmailStatus(function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
$scope.expectedDnsRecords = dnsRecords;
|
||||
$scope.expectedDnsRecords = result.dns;
|
||||
$scope.outboundPort25 = result.outboundPort25;
|
||||
|
||||
callback(null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user