diff --git a/src/cloudron.js b/src/cloudron.js index bac4f13e7..67f65c349 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -267,12 +267,12 @@ async function prepareDashboardDomain(domain, auditSource) { const domainObject = await domains.get(domain); if (!domain) throw new BoxError(BoxError.NOT_FOUND, 'No such domain'); - const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject); + const fqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domainObject); const result = await apps.list(); if (result.some(app => app.fqdn === fqdn)) throw new BoxError(BoxError.BAD_STATE, 'Dashboard location conflicts with an existing app'); - const taskId = await tasks.add(tasks.TASK_SETUP_DNS_AND_CERT, [ constants.DASHBOARD_LOCATION, domain, auditSource ]); + const taskId = await tasks.add(tasks.TASK_SETUP_DNS_AND_CERT, [ constants.DASHBOARD_SUBDOMAIN, domain, auditSource ]); tasks.startTask(taskId, {}); @@ -290,7 +290,7 @@ async function setDashboardDomain(domain, auditSource) { if (!domain) throw new BoxError(BoxError.NOT_FOUND, 'No such domain'); await reverseProxy.writeDashboardConfig(domainObject); - const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject); + const fqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domainObject); await settings.setDashboardLocation(domain, fqdn); diff --git a/src/constants.js b/src/constants.js index 39552d89f..e289ada28 100644 --- a/src/constants.js +++ b/src/constants.js @@ -7,8 +7,8 @@ const CLOUDRON = process.env.BOX_ENV === 'cloudron', TEST = process.env.BOX_ENV === 'test'; exports = module.exports = { - SMTP_LOCATION: 'smtp', - IMAP_LOCATION: 'imap', + SMTP_SUBDOMAIN: 'smtp', + IMAP_SUBDOMAIN: 'imap', // These are combined into one array because users and groups become mailboxes RESERVED_NAMES: [ @@ -22,7 +22,7 @@ exports = module.exports = { 'admins', 'users' // ldap code uses 'users' pseudo group ], - DASHBOARD_LOCATION: 'my', + DASHBOARD_SUBDOMAIN: 'my', PORT: CLOUDRON ? 3000 : 5454, INTERNAL_SMTP_PORT: 2525, // this value comes from the mail container diff --git a/src/dns.js b/src/dns.js index 87d26fc7e..c2f1408e1 100644 --- a/src/dns.js +++ b/src/dns.js @@ -76,11 +76,11 @@ function validateHostname(subdomain, domainObject) { const hostname = fqdn(subdomain, domainObject); - const RESERVED_LOCATIONS = [ - constants.SMTP_LOCATION, - constants.IMAP_LOCATION + const RESERVED_SUBDOMAINS = [ + constants.SMTP_SUBDOMAIN, + constants.IMAP_SUBDOMAIN ]; - if (RESERVED_LOCATIONS.indexOf(subdomain) !== -1) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved`); + if (RESERVED_SUBDOMAINS.indexOf(subdomain) !== -1) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved`); if (hostname === settings.dashboardFqdn()) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved`); @@ -295,7 +295,7 @@ async function syncDnsRecords(options, progressCallback) { progress += Math.round(100/(1+allDomains.length)); let locations = []; - if (domain.domain === settings.dashboardDomain()) locations.push({ subdomain: constants.DASHBOARD_LOCATION, domain: settings.dashboardDomain() }); + if (domain.domain === settings.dashboardDomain()) locations.push({ subdomain: constants.DASHBOARD_SUBDOMAIN, domain: settings.dashboardDomain() }); if (domain.domain === settings.mailDomain() && settings.mailFqdn() !== settings.dashboardFqdn()) locations.push({ subdomain: mailSubdomain, domain: settings.mailDomain() }); for (const app of allApps) { diff --git a/src/dyndns.js b/src/dyndns.js index d37a289c3..b94565f19 100644 --- a/src/dyndns.js +++ b/src/dyndns.js @@ -36,8 +36,8 @@ async function sync(auditSource) { } debug(`refreshDNS: updating IP from ${info.ipv4} to ipv4: ${ipv4} (changed: ${ipv4Changed}) ipv6: ${ipv6} (changed: ${ipv6Changed})`); - if (ipv4Changed) await dns.upsertDnsRecords(constants.DASHBOARD_LOCATION, settings.dashboardDomain(), 'A', [ ipv4 ]); - if (ipv6Changed) await dns.upsertDnsRecords(constants.DASHBOARD_LOCATION, settings.dashboardDomain(), 'AAAA', [ ipv6 ]); + if (ipv4Changed) await dns.upsertDnsRecords(constants.DASHBOARD_SUBDOMAIN, settings.dashboardDomain(), 'A', [ ipv4 ]); + if (ipv6Changed) await dns.upsertDnsRecords(constants.DASHBOARD_SUBDOMAIN, settings.dashboardDomain(), 'AAAA', [ ipv6 ]); const result = await apps.list(); for (const app of result) { diff --git a/src/provision.js b/src/provision.js index 4d4b96c93..652e6fcaf 100644 --- a/src/provision.js +++ b/src/provision.js @@ -70,7 +70,7 @@ async function setupTask(domain, auditSource) { assert.strictEqual(typeof auditSource, 'object'); try { - await cloudron.setupDnsAndCert(constants.DASHBOARD_LOCATION, domain, auditSource, (progress) => setProgress('setup', progress.message)); + await cloudron.setupDnsAndCert(constants.DASHBOARD_SUBDOMAIN, domain, auditSource, (progress) => setProgress('setup', progress.message)); await ensureDhparams(); await cloudron.setDashboardDomain(domain, auditSource); setProgress('setup', 'Done'), @@ -111,7 +111,7 @@ async function setup(domainConfig, sysinfoConfig, auditSource) { dkimSelector: 'cloudron' }; - await settings.setMailLocation(domain, `${constants.DASHBOARD_LOCATION}.${domain}`); // default mail location. do this before we add the domain for upserting mail DNS + await settings.setMailLocation(domain, `${constants.DASHBOARD_SUBDOMAIN}.${domain}`); // default mail location. do this before we add the domain for upserting mail DNS await domains.add(domain, data, auditSource); await settings.setSysinfoConfig(sysinfoConfig); @@ -174,7 +174,7 @@ async function restoreTask(backupConfig, remotePath, sysinfoConfig, options, aud await reverseProxy.restoreFallbackCertificates(); const dashboardDomain = settings.dashboardDomain(); // load this fresh from after the backup.restore - if (!options.skipDnsSetup) await cloudron.setupDnsAndCert(constants.DASHBOARD_LOCATION, dashboardDomain, auditSource, (progress) => setProgress('restore', progress.message)); + if (!options.skipDnsSetup) await cloudron.setupDnsAndCert(constants.DASHBOARD_SUBDOMAIN, dashboardDomain, auditSource, (progress) => setProgress('restore', progress.message)); await cloudron.setDashboardDomain(dashboardDomain, auditSource); await settings.setBackupCredentials(backupConfig); // update just the credentials and not the policy and flags await eventlog.add(eventlog.ACTION_RESTORE, auditSource, { remotePath }); diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 3681df926..8da5692e3 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -434,7 +434,7 @@ async function writeDashboardConfig(domainObject) { debug(`writeDashboardConfig: writing admin config for ${domainObject.domain}`); - const dashboardFqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject); + const dashboardFqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domainObject); const certificatePath = await getCertificatePath(dashboardFqdn, domainObject.domain); await writeDashboardNginxConfig(dashboardFqdn, certificatePath); diff --git a/src/routes/test/apps-test.js b/src/routes/test/apps-test.js index 1bfc20e26..e05acc95d 100644 --- a/src/routes/test/apps-test.js +++ b/src/routes/test/apps-test.js @@ -333,10 +333,10 @@ xdescribe('App API', function () { it('app install fails - reserved smtp subdomain', function (done) { superagent.post(SERVER_URL + '/api/v1/apps/install') .query({ access_token: token }) - .send({ manifest: APP_MANIFEST, subdomain: constants.SMTP_LOCATION, accessRestriction: null, domain: DOMAIN_0.domain }) + .send({ manifest: APP_MANIFEST, subdomain: constants.SMTP_SUBDOMAIN, accessRestriction: null, domain: DOMAIN_0.domain }) .end(function (err, res) { expect(res.statusCode).to.equal(400); - expect(res.body.message).to.contain(constants.SMTP_LOCATION + ' is reserved'); + expect(res.body.message).to.contain(constants.SMTP_SUBDOMAIN + ' is reserved'); done(); }); }); diff --git a/src/userdirectory.js b/src/userdirectory.js index a2de383cf..b5cc0e72d 100644 --- a/src/userdirectory.js +++ b/src/userdirectory.js @@ -277,7 +277,7 @@ async function start() { }; const domainObject = await domains.get(settings.dashboardDomain()); - const dashboardFqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject); + const dashboardFqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domainObject); const certificatePath = await reverseproxy.getCertificatePath(dashboardFqdn, domainObject.domain); gServer = ldap.createServer({