mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-21 14:52:27 +01:00
fixing up SSL support on startup to fallback to non-SSL mode if files are not present
This commit is contained in:
@@ -56,9 +56,9 @@ var validateEnvironmentVariable = function() {
|
||||
console.log();
|
||||
if (!environmentFiles.length) {
|
||||
if (process.env.NODE_ENV) {
|
||||
console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
|
||||
console.error(chalk.red('+ Error: No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
|
||||
} else {
|
||||
console.error(chalk.red('NODE_ENV is not defined! Using default development environment'));
|
||||
console.error(chalk.red('+ Error: NODE_ENV is not defined! Using default development environment'));
|
||||
}
|
||||
process.env.NODE_ENV = 'development';
|
||||
}
|
||||
@@ -66,6 +66,24 @@ var validateEnvironmentVariable = function() {
|
||||
console.log(chalk.white(''));
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate Secure=true parameter can actually be turned on
|
||||
* because it requires certs and key files to be available
|
||||
*/
|
||||
var validateSecureMode = function(config) {
|
||||
|
||||
if (config.secure !== true)
|
||||
return true;
|
||||
|
||||
var privateKey = fs.existsSync('./config/sslcerts/key.pem');
|
||||
var certificate = fs.existsSync('./config/sslcerts/cert.pem');
|
||||
|
||||
if (!privateKey || !certificate) {
|
||||
chalk.red(console.log('+ Error: Certificate file or key file is missing, falling back to non-SSL mode'));
|
||||
config.secure = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize global configuration files
|
||||
*/
|
||||
@@ -148,6 +166,9 @@ var initGlobalConfig = function() {
|
||||
// Initialize global globbed folders
|
||||
initGlobalConfigFolders(config, assets);
|
||||
|
||||
// Validate Secure SSL mode can be used
|
||||
validateSecureMode(config);
|
||||
|
||||
// Expose configuration utilities
|
||||
config.utils = {
|
||||
getGlobbedPaths: getGlobbedPaths
|
||||
|
||||
0
scripts/generate-ssl-certs.sh
Normal file → Executable file
0
scripts/generate-ssl-certs.sh
Normal file → Executable file
0
scripts/reset-password.js
Normal file → Executable file
0
scripts/reset-password.js
Normal file → Executable file
Reference in New Issue
Block a user