settings: move dynamic dns to network
and add tests
This commit is contained in:
@@ -3,10 +3,14 @@
|
||||
exports = module.exports = {
|
||||
getBlocklist,
|
||||
setBlocklist,
|
||||
|
||||
getDynamicDns,
|
||||
setDynamicDns,
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
cron = require('./cron.js'),
|
||||
ipaddr = require('ipaddr.js'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
@@ -53,3 +57,15 @@ async function setBlocklist(blocklist, auditSource) {
|
||||
const [error] = await safe(shell.promises.sudo('setBlocklist', [ SET_BLOCKLIST_CMD ], {}));
|
||||
if (error) throw new BoxError(BoxError.IPTABLES_ERROR, `Error setting blocklist: ${error.message}`);
|
||||
}
|
||||
|
||||
async function getDynamicDns() {
|
||||
const enabled = await settings.get(settings.DYNAMIC_DNS_KEY);
|
||||
return enabled ? !!enabled : false; // db holds string values only
|
||||
}
|
||||
|
||||
async function setDynamicDns(enabled) {
|
||||
assert.strictEqual(typeof enabled, 'boolean');
|
||||
|
||||
await settings.set(settings.DYNAMIC_DNS_KEY, enabled ? 'enabled' : ''); // db holds string values only
|
||||
cron.dynamicDnsChanged(enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user