mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Fixes eslint errors
This commit is contained in:
parent
02d3093d88
commit
f650137c84
@ -118,8 +118,8 @@ const internalHost = {
|
|||||||
|
|
||||||
if (promises_results[3]) {
|
if (promises_results[3]) {
|
||||||
// SSL Passthrough Hosts
|
// SSL Passthrough Hosts
|
||||||
response_object.ssl_passthrough_hosts = internalHost._getHostsWithDomains(promises_results[3], domain_names);
|
response_object.ssl_passthrough_hosts = internalHost._getHostsWithDomains(promises_results[3], domain_names);
|
||||||
response_object.total_count += response_object.ssl_passthrough_hosts.length;
|
response_object.total_count += response_object.ssl_passthrough_hosts.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response_object;
|
return response_object;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const logger = require('../logger').nginx;
|
const logger = require('../logger').nginx;
|
||||||
const utils = require('../lib/utils');
|
const utils = require('../lib/utils');
|
||||||
const error = require('../lib/error');
|
const error = require('../lib/error');
|
||||||
const { Liquid } = require('liquidjs');
|
const { Liquid } = require('liquidjs');
|
||||||
const passthroughHostModel = require('../models/ssl_passthrough_host');
|
const passthroughHostModel = require('../models/ssl_passthrough_host');
|
||||||
const debug_mode = process.env.NODE_ENV !== 'production' || !!process.env.DEBUG;
|
const debug_mode = process.env.NODE_ENV !== 'production' || !!process.env.DEBUG;
|
||||||
|
|
||||||
const internalNginx = {
|
const internalNginx = {
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const internalNginx = {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
configure: (model, host_type, host) => {
|
configure: (model, host_type, host) => {
|
||||||
let combined_meta = {};
|
let combined_meta = {};
|
||||||
const sslPassthroughEnabled = internalNginx.sslPassthroughEnabled();
|
const sslPassthroughEnabled = internalNginx.sslPassthroughEnabled();
|
||||||
|
|
||||||
return internalNginx.test()
|
return internalNginx.test()
|
||||||
@ -34,7 +34,7 @@ const internalNginx = {
|
|||||||
return internalNginx.deleteConfig(host_type, host); // Don't throw errors, as the file may not exist at all
|
return internalNginx.deleteConfig(host_type, host); // Don't throw errors, as the file may not exist at all
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if(host_type === 'ssl_passthrough_host' && !sslPassthroughEnabled){
|
if (host_type === 'ssl_passthrough_host' && !sslPassthroughEnabled){
|
||||||
// ssl passthrough is disabled
|
// ssl passthrough is disabled
|
||||||
const meta = {
|
const meta = {
|
||||||
nginx_online: false,
|
nginx_online: false,
|
||||||
@ -64,7 +64,7 @@ const internalNginx = {
|
|||||||
nginx_err: null
|
nginx_err: null
|
||||||
});
|
});
|
||||||
|
|
||||||
if(host_type === 'ssl_passthrough_host'){
|
if (host_type === 'ssl_passthrough_host'){
|
||||||
// If passthrough is disabled we have already marked the hosts as offline
|
// If passthrough is disabled we have already marked the hosts as offline
|
||||||
if (sslPassthroughEnabled) {
|
if (sslPassthroughEnabled) {
|
||||||
return passthroughHostModel
|
return passthroughHostModel
|
||||||
@ -109,7 +109,7 @@ const internalNginx = {
|
|||||||
nginx_err: valid_lines.join('\n')
|
nginx_err: valid_lines.join('\n')
|
||||||
});
|
});
|
||||||
|
|
||||||
if(host_type === 'ssl_passthrough_host'){
|
if (host_type === 'ssl_passthrough_host'){
|
||||||
return passthroughHostModel
|
return passthroughHostModel
|
||||||
.query()
|
.query()
|
||||||
.where('is_deleted', 0)
|
.where('is_deleted', 0)
|
||||||
@ -235,7 +235,7 @@ const internalNginx = {
|
|||||||
* @param {Object} host
|
* @param {Object} host
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
generateConfig: (host_type, host) => {
|
generateConfig: async (host_type, host) => {
|
||||||
host_type = host_type.replace(new RegExp('-', 'g'), '_');
|
host_type = host_type.replace(new RegExp('-', 'g'), '_');
|
||||||
|
|
||||||
if (debug_mode) {
|
if (debug_mode) {
|
||||||
@ -248,90 +248,87 @@ const internalNginx = {
|
|||||||
root: __dirname + '/../templates/'
|
root: __dirname + '/../templates/'
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
let template = null;
|
||||||
let template = null;
|
let filename = internalNginx.getConfigName(host_type, host.id);
|
||||||
let filename = internalNginx.getConfigName(host_type, host.id);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
template = fs.readFileSync(__dirname + '/../templates/' + host_type + '.conf', {encoding: 'utf8'});
|
template = fs.readFileSync(__dirname + '/../templates/' + host_type + '.conf', {encoding: 'utf8'});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(new error.ConfigurationError(err.message));
|
throw new error.ConfigurationError(err.message);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let locationsPromise;
|
let locationsPromise;
|
||||||
let origLocations;
|
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) => {
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// 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 {
|
} else {
|
||||||
locationsPromise = Promise.resolve();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set the IPv6 setting for the host
|
if (host.locations) {
|
||||||
host.ipv6 = internalNginx.ipv6Enabled();
|
//logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2));
|
||||||
|
origLocations = [].concat(host.locations);
|
||||||
locationsPromise.then(() => {
|
locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => {
|
||||||
renderEngine
|
host.locations = renderedLocations;
|
||||||
.parseAndRender(template, host)
|
|
||||||
.then((config_text) => {
|
|
||||||
fs.writeFileSync(filename, config_text, {encoding: 'utf8'});
|
|
||||||
|
|
||||||
if (debug_mode) {
|
|
||||||
logger.success('Wrote config:', filename, config_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore locations array
|
|
||||||
host.locations = origLocations;
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
if (debug_mode) {
|
|
||||||
logger.warn('Could not write ' + filename + ':', err.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
reject(new error.ConfigurationError(err.message));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} 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 (debug_mode) {
|
||||||
|
logger.success('Wrote config:', filename, config_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore locations array
|
||||||
|
host.locations = origLocations;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
if (debug_mode) {
|
||||||
|
logger.warn('Could not write ' + filename + ':', err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new error.ConfigurationError(err.message);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -514,12 +511,12 @@ const internalNginx = {
|
|||||||
* Helper function to add brackets to an IP if it is IPv6
|
* Helper function to add brackets to an IP if it is IPv6
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
addIpv6Brackets: function (ip) {
|
addIpv6Brackets: function (ip) {
|
||||||
// Only run check if ipv6 is enabled
|
// Only run check if ipv6 is enabled
|
||||||
if (internalNginx.ipv6Enabled()) {
|
if (internalNginx.ipv6Enabled()) {
|
||||||
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/gi;
|
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/gi;
|
||||||
if(ipv6Regex.test(ip)){
|
if (ipv6Regex.test(ip)){
|
||||||
return `[${ip}]`
|
return `[${ip}]`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ip;
|
return ip;
|
||||||
|
@ -27,23 +27,23 @@ exports.up = function (knex/*, Promise*/) {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
logger.info('[' + migrate_name + '] Table created');
|
logger.info('[' + migrate_name + '] Table created');
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return knex.schema.table('user_permission', (table) => {
|
return knex.schema.table('user_permission', (table) => {
|
||||||
table.string('ssl_passthrough_hosts').notNull();
|
table.string('ssl_passthrough_hosts').notNull();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return knex('user_permission').update('ssl_passthrough_hosts', knex.ref('streams'));
|
return knex('user_permission').update('ssl_passthrough_hosts', knex.ref('streams'));
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return knex.schema.alterTable('user_permission', (table) => {
|
return knex.schema.alterTable('user_permission', (table) => {
|
||||||
table.string('ssl_passthrough_hosts').notNullable().alter();
|
table.string('ssl_passthrough_hosts').notNullable().alter();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
logger.info('[' + migrate_name + '] permissions updated');
|
logger.info('[' + migrate_name + '] permissions updated');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ exports.down = function (knex/*, Promise*/) {
|
|||||||
return knex.schema.dropTable('stream').then(() => {
|
return knex.schema.dropTable('stream').then(() => {
|
||||||
return knex.schema.table('user_permission', (table) => {
|
return knex.schema.table('user_permission', (table) => {
|
||||||
table.dropColumn('ssl_passthrough_hosts');
|
table.dropColumn('ssl_passthrough_hosts');
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.then(function () {
|
.then(function () {
|
||||||
logger.info('[' + migrate_name + '] Table altered and permissions updated');
|
logger.info('[' + migrate_name + '] Table altered and permissions updated');
|
||||||
|
@ -42,7 +42,7 @@ router.use('/nginx/certificates', require('./nginx/certificates'));
|
|||||||
|
|
||||||
router.get('/ssl-passthrough-enabled', (req, res/*, next*/) => {
|
router.get('/ssl-passthrough-enabled', (req, res/*, next*/) => {
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
status: 'OK',
|
status: 'OK',
|
||||||
ssl_passthrough_enabled: internalNginx.sslPassthroughEnabled()
|
ssl_passthrough_enabled: internalNginx.sslPassthroughEnabled()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@ router
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
host_id: req.params.host_id,
|
host_id: req.params.host_id,
|
||||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
return internalSslPassthrough.get(res.locals.access, {
|
return internalSslPassthrough.get(res.locals.access, {
|
||||||
|
Loading…
Reference in New Issue
Block a user