move dashboard setting into dashboard.js

This commit is contained in:
Girish Ramakrishnan
2023-08-11 19:41:05 +05:30
parent 27ce8f9351
commit eee49a8291
25 changed files with 157 additions and 156 deletions

View File

@@ -41,6 +41,7 @@ const acme2 = require('./acme2.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
crypto = require('crypto'),
dashboard = require('./dashboard.js'),
debug = require('debug')('box:reverseproxy'),
dns = require('./dns.js'),
docker = require('./docker.js'),
@@ -306,7 +307,8 @@ async function getMailCertificate() {
}
async function getDirectoryServerCertificate() {
return await getCertificate({ domain: settings.dashboardDomain(), fqdn: settings.dashboardFqdn(), certificate: null, type: apps.LOCATION_TYPE_DIRECTORY_SERVER });
const { domain, fqdn } = await dashboard.getLocation();
return await getCertificate({ domain, fqdn, certificate: null, type: apps.LOCATION_TYPE_DIRECTORY_SERVER });
}
// write if contents mismatch (thus preserving mtime)
@@ -643,9 +645,11 @@ async function checkCerts(options, auditSource, progressCallback) {
assert.strictEqual(typeof progressCallback, 'function');
let locations = [];
const { domain:dashboardDomain, fqdn:dashboardFqdn } = await dashboard.getLocation();
locations.push({ domain: dashboardDomain, fqdn: dashboardFqdn, certificate: null, type: apps.LOCATION_TYPE_DASHBOARD });
const { domain:mailDomain, fqdn:mailFqdn } = await mailServer.getLocation();
if (settings.dashboardFqdn() !== mailFqdn) locations.push({ domain: mailDomain, fqdn: mailFqdn, certificate: null, type: apps.LOCATION_TYPE_MAIL });
locations.push({ domain: settings.dashboardDomain(), fqdn: settings.dashboardFqdn(), certificate: null, type: apps.LOCATION_TYPE_DASHBOARD });
if (dashboardFqdn !== mailFqdn) locations.push({ domain: mailDomain, fqdn: mailFqdn, certificate: null, type: apps.LOCATION_TYPE_MAIL });
const allApps = (await apps.list()).filter(app => app.runState !== apps.RSTATE_STOPPED);
for (const app of allApps) {
@@ -664,7 +668,8 @@ async function checkCerts(options, auditSource, progressCallback) {
for (const app of allApps) {
await writeAppConfigs(app);
}
await writeDashboardConfig(settings.dashboardDomain());
const { domain:dashboardDomain } = await dashboard.getLocation();
await writeDashboardConfig(dashboardDomain);
await notifyCertChange(); // this allows user to "rebuild" using UI just in case we crashed and went out of sync
safe.fs.unlinkSync(paths.REVERSE_PROXY_REBUILD_FILE);
} else {