diff --git a/backend/src/utils/settings.js b/backend/src/utils/settings.js index 770cd63..9efdda7 100644 --- a/backend/src/utils/settings.js +++ b/backend/src/utils/settings.js @@ -71,6 +71,13 @@ const DEFAULTS = { invoice_footer: 'Thank you for using Cross Events.', // Replies to billing emails go here (blank: business_email). billing_reply_to: '', + // Servers and the agent (2.1.0). The port list hands out ports in this range (match frps's + // allow_ports); install_defaults is the .env defaults layer (JSON, NAME → value); the central + // server's IP is used to check a new install's DNS. + port_range_start: '20000', + port_range_end: '29999', + install_defaults: '{"HUB_URL":"https://hub.crosscode.co.za"}', + central_server_ip: '', }; // Stored encrypted and never sent to the browser: only "is one saved" (_set). diff --git a/backend/tests/servers.test.js b/backend/tests/servers.test.js index 5e0af6f..46b3175 100644 --- a/backend/tests/servers.test.js +++ b/backend/tests/servers.test.js @@ -285,3 +285,12 @@ describe('reusing a short name (found in the VM test)', () => { await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.other.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'SHORT_NAME_TAKEN' }); }); }); + +describe('settings for servers (found in the VM test)', () => { + test('install defaults, the port range and the central IP are saved', async () => { + const { setSettings } = require('../src/utils/settings'); + await setSettings({ install_defaults: '{"HUB_URL":"https://hub.test","SENTRY_DSN":"x"}', port_range_start: '21000', port_range_end: '21100', central_server_ip: '203.0.113.10' }); + expect(await servers.installDefaults()).toEqual({ HUB_URL: 'https://hub.test', SENTRY_DSN: 'x' }); + expect(await servers.portRange()).toEqual({ from: 21000, to: 21100 }); + }); +});