add separate route to get ipv4 and ipv6

This commit is contained in:
Girish Ramakrishnan
2022-02-15 12:47:16 -08:00
parent c6da8c8167
commit d0c59c1f75
2 changed files with 14 additions and 7 deletions

View File

@@ -19,7 +19,8 @@ exports = module.exports = {
updateDashboardDomain,
prepareDashboardDomain,
renewCerts,
getServerIp,
getServerIpv4,
getServerIpv6,
getLanguages,
syncExternalLdap,
syncDnsRecords
@@ -293,13 +294,18 @@ async function syncExternalLdap(req, res, next) {
next(new HttpSuccess(202, { taskId }));
}
async function getServerIp(req, res, next) {
const [ipv4Error, ipv4] = await safe(sysinfo.getServerIPv4());
if (ipv4Error) return next(BoxError.toHttpError(ipv4Error));
async function getServerIpv4(req, res, next) {
const [error, ipv4] = await safe(sysinfo.getServerIPv4());
if (error) return next(BoxError.toHttpError(error));
const [, ipv6] = await safe(sysinfo.getServerIPv6(), { debug }); // ignore any error
next(new HttpSuccess(200, { ipv4 }));
}
next(new HttpSuccess(200, { ipv4, ipv6 }));
async function getServerIpv6(req, res, next) {
const [error, ipv6] = await safe(sysinfo.getServerIPv6()); // ignore any error
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, { ipv6 }));
}
async function getLanguages(req, res, next) {