diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 4fdddb4b0..0ddbbc5dc 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -734,7 +734,8 @@ async function handleCertificateProviderChanged(domain) { } async function getTrustedIps() { - return await settings.getTrustedIps(); + const value = await settings.get(settings.TRUSTED_IPS_KEY); + return value || ''; } async function setTrustedIps(trustedIps) { @@ -750,7 +751,7 @@ async function setTrustedIps(trustedIps) { trustedIpsConfig += `set_real_ip_from ${rangeOrIP};\n`; } - await settings.setTrustedIps(trustedIps); + await settings.set(settings.TRUSTED_IPS_KEY, trustedIps); if (!safe.fs.writeFileSync(paths.NGINX_TRUSTED_IPS_FILE, trustedIpsConfig, 'utf8')) throw new BoxError(BoxError.FS_ERROR, safe.error.message); await reload(); } diff --git a/src/settings.js b/src/settings.js index 272cbd50e..795cd1abf 100644 --- a/src/settings.js +++ b/src/settings.js @@ -72,9 +72,6 @@ exports = module.exports = { getFirewallBlocklist, setFirewallBlocklist, - getTrustedIps, - setTrustedIps, - getGhosts, setGhosts, @@ -99,6 +96,9 @@ exports = module.exports = { isDemo, + get, + set, + // booleans. if you add an entry here, be sure to fix list() DYNAMIC_DNS_KEY: 'dynamic_dns', UNSTABLE_APPS_KEY: 'unstable_apps', @@ -230,7 +230,6 @@ const gDefaults = (function () { result[exports.MAIL_FQDN_KEY] = ''; result[exports.FIREWALL_BLOCKLIST_KEY] = ''; - result[exports.TRUSTED_IPS_KEY] = ''; result[exports.API_SERVER_ORIGIN_KEY] = 'https://api.cloudron.io'; result[exports.WEB_SERVER_ORIGIN_KEY] = 'https://cloudron.io'; @@ -666,19 +665,6 @@ async function setFirewallBlocklist(blocklist) { await setBlob(exports.FIREWALL_BLOCKLIST_KEY, Buffer.from(blocklist)); } -async function getTrustedIps() { - const value = await get(exports.TRUSTED_IPS_KEY); - if (value === null) return gDefaults[exports.TRUSTED_IPS_KEY]; - - return value; -} - -async function setTrustedIps(trustedIps) { - assert.strictEqual(typeof trustedIps, 'string'); - - await set(exports.TRUSTED_IPS_KEY, trustedIps); -} - async function getGhosts() { const value = await get(exports.GHOSTS_CONFIG_KEY); if (value === null) return gDefaults[exports.GHOSTS_CONFIG_KEY];