add Location class

This commit is contained in:
Girish Ramakrishnan
2023-08-17 10:44:07 +05:30
parent de7879afb5
commit 3d0ba557e5
4 changed files with 38 additions and 18 deletions

View File

@@ -49,6 +49,7 @@ const acme2 = require('./acme2.js'),
ejs = require('ejs'),
eventlog = require('./eventlog.js'),
fs = require('fs'),
Location = require('./location.js'),
mailServer = require('./mailserver.js'),
network = require('./network.js'),
os = require('os'),
@@ -246,10 +247,10 @@ async function restoreFallbackCertificates() {
function getAppLocationsSync(app) {
assert.strictEqual(typeof app, 'object');
return [{ domain: app.domain, subdomain: app.subdomain, fqdn: app.fqdn, certificate: app.certificate, type: apps.LOCATION_TYPE_PRIMARY }]
.concat(app.secondaryDomains.map(sd => { return { domain: sd.domain, subdomain: sd.subdomain, certificate: sd.certificate, fqdn: sd.fqdn, type: apps.LOCATION_TYPE_SECONDARY }; }))
.concat(app.redirectDomains.map(rd => { return { domain: rd.domain, subdomain: rd.subdomain, certificate: rd.certificate, fqdn: rd.fqdn, type: apps.LOCATION_TYPE_REDIRECT }; }))
.concat(app.aliasDomains.map(ad => { return { domain: ad.domain, subdomain: ad.subdomain, certificate: ad.certificate, fqdn: ad.fqdn, type: apps.LOCATION_TYPE_ALIAS }; }));
return [new Location(app.subdomain, app.domain, Location.TYPE_PRIMARY, app.certificate)]
.concat(app.secondaryDomains.map(sd => new Location(sd.subdomin, sd.domain, Location.TYPE_SECONDARY, sd.certificate)))
.concat(app.redirectDomains.map(rd => new Location(rd.subdomin, rd.domain, Location.TYPE_REDIRECT, rd.certificate)))
.concat(app.aliasDomains.map(ad => new Location(ad.subdomin, ad.domain, Location.TYPE_ALIAS, ad.certificate)));
}
function getAcmeCertificateNameSync(fqdn, domainObject) {
@@ -645,11 +646,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 dashboardLocation = await dashboard.getLocation();
locations.push(dashboardLocation);
const { domain:mailDomain, fqdn:mailFqdn } = await mailServer.getLocation();
if (dashboardFqdn !== mailFqdn) locations.push({ domain: mailDomain, fqdn: mailFqdn, certificate: null, type: apps.LOCATION_TYPE_MAIL });
const mailLocation = await mailServer.getLocation();
if (dashboardLocation.fqdn !== mailLocation.fqdn) locations.push(mailLocation);
const allApps = (await apps.list()).filter(app => app.runState !== apps.RSTATE_STOPPED);
for (const app of allApps) {