From 676db1cac1cbed0288892ab956cbdc24e4f0418f Mon Sep 17 00:00:00 2001 From: Luca Wlcek Date: Fri, 17 Nov 2023 16:19:31 +0100 Subject: [PATCH] fixed padding and syntax --- backend/internal/nginx.js | 120 +++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/backend/internal/nginx.js b/backend/internal/nginx.js index a4fff1e2..8b570d0f 100644 --- a/backend/internal/nginx.js +++ b/backend/internal/nginx.js @@ -1,10 +1,10 @@ -const _ = require('lodash'); -const fs = require('fs'); -const logger = require('../logger').nginx; -const config = require('../lib/config'); -const utils = require('../lib/utils'); -const error = require('../lib/error'); -const passthroughHostModel = require('../models/ssl_passthrough_host'); +const _ = require('lodash'); +const fs = require('fs'); +const logger = require('../logger').nginx; +const config = require('../lib/config'); +const utils = require('../lib/utils'); +const error = require('../lib/error'); +const passthroughHostModel = require('../models/ssl_passthrough_host'); const internalNginx = { @@ -250,68 +250,68 @@ const internalNginx = { return; } - let locationsPromise; - let origLocations; + let locationsPromise; + let origLocations; - // Manipulate the data a bit before sending it to the template - if (host_type === 'ssl_passthrough_host') { - if (internalNginx.sslPassthroughEnabled()){ - const allHosts = await passthroughHostModel - .query() - .where('is_deleted', 0) - .groupBy('id') - .omit(['is_deleted']); - host = { - all_passthrough_hosts: allHosts.map((host) => { + // Manipulate the data a bit before sending it to the template + if (host_type === 'ssl_passthrough_host') { + if (internalNginx.sslPassthroughEnabled()){ + const allHosts = await passthroughHostModel + .query() + .where('is_deleted', 0) + .groupBy('id') + .omit(['is_deleted']); + host = { + all_passthrough_hosts: allHosts.map((host) => { // Replace dots in domain - host.forwarding_host = internalNginx.addIpv6Brackets(host.forwarding_host); - return host; - }), - }; - } else { - internalNginx.deleteConfig(host_type, host, false); - } - - } else if (host_type !== 'default') { - host.use_default_location = true; - if (typeof host.advanced_config !== 'undefined' && host.advanced_config) { - host.use_default_location = !internalNginx.advancedConfigHasDefaultLocation(host.advanced_config); - } - } - - if (host.locations) { - //logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2)); - origLocations = [].concat(host.locations); - locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => { - host.locations = renderedLocations; - }); - - // Allow someone who is using / custom location path to use it, and skip the default / location - _.map(host.locations, (location) => { - if (location.path === '/') { - host.use_default_location = false; + host.forwarding_host = internalNginx.addIpv6Brackets(host.forwarding_host); + return host; + }), + }; + } else { + internalNginx.deleteConfig(host_type, host, false); } - }); + + } else if (host_type !== 'default') { + host.use_default_location = true; + if (typeof host.advanced_config !== 'undefined' && host.advanced_config) { + host.use_default_location = !internalNginx.advancedConfigHasDefaultLocation(host.advanced_config); + } + } - } else { - locationsPromise = Promise.resolve(); - } + if (host.locations) { + //logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2)); + origLocations = [].concat(host.locations); + locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => { + host.locations = renderedLocations; + }); - // Set the IPv6 setting for the host - host.ipv6 = internalNginx.ipv6Enabled(); + // Allow someone who is using / custom location path to use it, and skip the default / location + _.map(host.locations, (location) => { + if (location.path === '/') { + host.use_default_location = false; + } + }); - return locationsPromise.then(() => { - renderEngine - .parseAndRender(template, host) - .then((config_text) => { - fs.writeFileSync(filename, config_text, {encoding: 'utf8'}); + } else { + locationsPromise = Promise.resolve(); + } + + // Set the IPv6 setting for the host + host.ipv6 = internalNginx.ipv6Enabled(); + + return locationsPromise.then(() => { + renderEngine + .parseAndRender(template, host) + .then((config_text) => { + fs.writeFileSync(filename, config_text, {encoding: 'utf8'}); if (config.debug()) { logger.success('Wrote config:', filename, config_text); } - // Restore locations array - host.locations = origLocations; + // Restore locations array + host.locations = origLocations; resolve(true); }) @@ -320,9 +320,9 @@ const internalNginx = { logger.warn('Could not write ' + filename + ':', err.message); } - throw new error.ConfigurationError(err.message); + throw new error.ConfigurationError(err.message); }); - }) + }); }); },