settings: move ipv6/ipv4 config into network
this also rename sysinfo_config to ipv4_config
This commit is contained in:
@@ -7,9 +7,6 @@ exports = module.exports = {
|
||||
getTimeZone,
|
||||
setTimeZone,
|
||||
|
||||
getIPv6Config,
|
||||
setIPv6Config,
|
||||
|
||||
getBackupPolicy,
|
||||
setBackupPolicy,
|
||||
|
||||
@@ -25,9 +22,6 @@ exports = module.exports = {
|
||||
getLanguage,
|
||||
setLanguage,
|
||||
|
||||
getSysinfoConfig,
|
||||
setSysinfoConfig,
|
||||
|
||||
getProfileConfig,
|
||||
setProfileConfig,
|
||||
|
||||
@@ -71,7 +65,7 @@ exports = module.exports = {
|
||||
EXTERNAL_LDAP_KEY: 'external_ldap_config',
|
||||
DIRECTORY_SERVER_KEY: 'user_directory_config',
|
||||
REGISTRY_CONFIG_KEY: 'registry_config',
|
||||
SYSINFO_CONFIG_KEY: 'sysinfo_config', // misnomer: ipv4 config
|
||||
IPV4_CONFIG_KEY: 'ipv4_config',
|
||||
SUPPORT_CONFIG_KEY: 'support_config',
|
||||
PROFILE_CONFIG_KEY: 'profile_config',
|
||||
GHOSTS_CONFIG_KEY: 'ghosts_config',
|
||||
@@ -123,7 +117,6 @@ const assert = require('assert'),
|
||||
mounts = require('./mounts.js'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
sysinfo = require('./sysinfo.js'),
|
||||
tokens = require('./tokens.js'),
|
||||
translation = require('./translation.js'),
|
||||
users = require('./users.js'),
|
||||
@@ -136,9 +129,6 @@ const gDefaults = (function () {
|
||||
const result = { };
|
||||
result[exports.AUTOUPDATE_PATTERN_KEY] = cron.DEFAULT_AUTOUPDATE_PATTERN;
|
||||
result[exports.TIME_ZONE_KEY] = 'UTC';
|
||||
result[exports.IPV6_CONFIG_KEY] = {
|
||||
provider: 'noop'
|
||||
};
|
||||
result[exports.LANGUAGE_KEY] = 'en';
|
||||
result[exports.BACKUP_CONFIG_KEY] = {
|
||||
provider: 'filesystem',
|
||||
@@ -154,9 +144,6 @@ const gDefaults = (function () {
|
||||
result[exports.REGISTRY_CONFIG_KEY] = {
|
||||
provider: 'noop'
|
||||
};
|
||||
result[exports.SYSINFO_CONFIG_KEY] = {
|
||||
provider: 'generic'
|
||||
};
|
||||
result[exports.PROFILE_CONFIG_KEY] = {
|
||||
lockUserProfiles: false,
|
||||
mandatory2FA: false
|
||||
@@ -254,24 +241,6 @@ async function getTimeZone() {
|
||||
return tz;
|
||||
}
|
||||
|
||||
async function getIPv6Config() {
|
||||
const value = await get(exports.IPV6_CONFIG_KEY);
|
||||
if (value === null) return gDefaults[exports.IPV6_CONFIG_KEY];
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
async function setIPv6Config(ipv6Config) {
|
||||
assert.strictEqual(typeof ipv6Config, 'object');
|
||||
|
||||
if (isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
|
||||
|
||||
const error = await sysinfo.testIPv6Config(ipv6Config);
|
||||
if (error) throw error;
|
||||
|
||||
await set(exports.IPV6_CONFIG_KEY, JSON.stringify(ipv6Config));
|
||||
notifyChange(exports.IPV6_CONFIG_KEY, ipv6Config);
|
||||
}
|
||||
|
||||
async function getBackupPolicy() {
|
||||
const result = await get(exports.BACKUP_POLICY_KEY);
|
||||
if (result === null) return gDefaults[exports.BACKUP_POLICY_KEY];
|
||||
@@ -378,25 +347,6 @@ async function setRegistryConfig(registryConfig) {
|
||||
notifyChange(exports.REGISTRY_CONFIG_KEY, registryConfig);
|
||||
}
|
||||
|
||||
async function getSysinfoConfig() {
|
||||
const value = await get(exports.SYSINFO_CONFIG_KEY);
|
||||
if (value === null) return gDefaults[exports.SYSINFO_CONFIG_KEY];
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
async function setSysinfoConfig(sysinfoConfig) {
|
||||
assert.strictEqual(typeof sysinfoConfig, 'object');
|
||||
|
||||
if (isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
|
||||
|
||||
const error = await sysinfo.testIPv4Config(sysinfoConfig);
|
||||
if (error) throw error;
|
||||
|
||||
await set(exports.SYSINFO_CONFIG_KEY, JSON.stringify(sysinfoConfig));
|
||||
|
||||
notifyChange(exports.SYSINFO_CONFIG_KEY, sysinfoConfig);
|
||||
}
|
||||
|
||||
async function getProfileConfig() {
|
||||
const value = await get(exports.PROFILE_CONFIG_KEY);
|
||||
if (value === null) return gDefaults[exports.PROFILE_CONFIG_KEY];
|
||||
@@ -464,8 +414,8 @@ async function list() {
|
||||
result[exports.DEMO_KEY] = !!result[exports.DEMO_KEY];
|
||||
|
||||
// convert JSON objects
|
||||
[exports.BACKUP_POLICY_KEY, exports.BACKUP_CONFIG_KEY, exports.IPV6_CONFIG_KEY, exports.PROFILE_CONFIG_KEY, exports.SERVICES_CONFIG_KEY,
|
||||
exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY, exports.REVERSE_PROXY_CONFIG_KEY ].forEach(function (key) {
|
||||
[exports.BACKUP_POLICY_KEY, exports.BACKUP_CONFIG_KEY, exports.PROFILE_CONFIG_KEY, exports.SERVICES_CONFIG_KEY,
|
||||
exports.REGISTRY_CONFIG_KEY ].forEach(function (key) {
|
||||
result[key] = typeof result[key] === 'object' ? result[key] : safe.JSON.parse(result[key]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user