settings: move dynamic dns to network
and add tests
This commit is contained in:
+22
-1
@@ -5,7 +5,10 @@ exports = module.exports = {
|
||||
setBlocklist,
|
||||
|
||||
getTrustedIps,
|
||||
setTrustedIps
|
||||
setTrustedIps,
|
||||
|
||||
getDynamicDns,
|
||||
setDynamicDns
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -54,3 +57,21 @@ async function setTrustedIps(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getDynamicDns(req, res, next) {
|
||||
const [error, enabled] = await safe(network.getDynamicDns());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { enabled }));
|
||||
}
|
||||
|
||||
async function setDynamicDns(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled boolean is required'));
|
||||
|
||||
const [error] = await safe(network.setDynamicDns(req.body.enabled));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user