reverseproxy: move renew and trusted ip routes
This commit is contained in:
@@ -17,7 +17,6 @@ exports = module.exports = {
|
||||
getLogStream,
|
||||
updateDashboardDomain,
|
||||
prepareDashboardDomain,
|
||||
renewCerts,
|
||||
getLanguages,
|
||||
getSystemGraphs,
|
||||
getPlatformStatus,
|
||||
@@ -272,15 +271,6 @@ async function prepareDashboardDomain(req, res, next) {
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
|
||||
async function renewCerts(req, res, next) {
|
||||
if ('rebuild' in req.body && typeof req.body.rebuild !== 'boolean') return next(new HttpError(400, 'rebuild must be a boolean'));
|
||||
|
||||
const [error, taskId] = await safe(cloudron.renewCerts(req.body, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
|
||||
async function getLanguages(req, res, next) {
|
||||
const [error, languages] = await safe(translation.getLanguages());
|
||||
if (error) return next(new BoxError.toHttpError(error));
|
||||
|
||||
@@ -22,6 +22,7 @@ exports = module.exports = {
|
||||
oidc: require('./oidc.js'),
|
||||
profile: require('./profile.js'),
|
||||
provision: require('./provision.js'),
|
||||
reverseProxy: require('./reverseProxy.js'),
|
||||
services: require('./services.js'),
|
||||
settings: require('./settings.js'),
|
||||
support: require('./support.js'),
|
||||
|
||||
@@ -4,9 +4,6 @@ exports = module.exports = {
|
||||
getBlocklist,
|
||||
setBlocklist,
|
||||
|
||||
getTrustedIps,
|
||||
setTrustedIps,
|
||||
|
||||
getDynamicDns,
|
||||
setDynamicDns,
|
||||
|
||||
@@ -49,24 +46,6 @@ async function setBlocklist(req, res, next) {
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getTrustedIps(req, res, next) {
|
||||
const [error, trustedIps] = await safe(reverseProxy.getTrustedIps());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { trustedIps }));
|
||||
}
|
||||
|
||||
async function setTrustedIps(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.trustedIps !== 'string') return next(new HttpError(400, 'trustedIps must be a string'));
|
||||
|
||||
const [error] = await safe(reverseProxy.setTrustedIps(req.body.trustedIps, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getDynamicDns(req, res, next) {
|
||||
const [error, enabled] = await safe(network.getDynamicDns());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getTrustedIps,
|
||||
setTrustedIps,
|
||||
|
||||
renewCerts,
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
AuditSource = require('../auditsource.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
reverseProxy = require('../reverseproxy.js'),
|
||||
safe = require('safetydance');
|
||||
|
||||
async function getTrustedIps(req, res, next) {
|
||||
const [error, trustedIps] = await safe(reverseProxy.getTrustedIps());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { trustedIps }));
|
||||
}
|
||||
|
||||
async function setTrustedIps(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.trustedIps !== 'string') return next(new HttpError(400, 'trustedIps must be a string'));
|
||||
|
||||
const [error] = await safe(reverseProxy.setTrustedIps(req.body.trustedIps, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function renewCerts(req, res, next) {
|
||||
if ('rebuild' in req.body && typeof req.body.rebuild !== 'boolean') return next(new HttpError(400, 'rebuild must be a boolean'));
|
||||
|
||||
const [error, taskId] = await safe(reverseProxy.startRenewCerts(req.body, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
Reference in New Issue
Block a user