2014-10-17 02:21:06 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
var miscUtil = require('./misc_util.js');
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var paths = require('path');
|
|
|
|
var async = require('async');
|
|
|
|
var _ = require('lodash');
|
2015-09-09 04:08:45 +00:00
|
|
|
var hjson = require('hjson');
|
2015-04-17 04:29:53 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
exports.init = init;
|
|
|
|
exports.getDefaultPath = getDefaultPath;
|
|
|
|
|
|
|
|
function init(configPath, cb) {
|
|
|
|
async.waterfall(
|
|
|
|
[
|
|
|
|
function loadUserConfig(callback) {
|
|
|
|
|
|
|
|
fs.readFile(configPath, { encoding : 'utf8' }, function configData(err, data) {
|
|
|
|
if(err) {
|
|
|
|
callback(null, { } );
|
|
|
|
} else {
|
|
|
|
try {
|
2015-09-09 04:08:45 +00:00
|
|
|
var configJson = hjson.parse(data);
|
2015-04-19 08:13:13 +00:00
|
|
|
callback(null, configJson);
|
|
|
|
} catch(e) {
|
|
|
|
callback(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2015-08-06 04:22:17 +00:00
|
|
|
function mergeWithDefaultConfig(configJson, callback) {
|
2015-08-20 22:35:04 +00:00
|
|
|
//var mergedConfig = _.defaultsDeep(configJson, getDefaultConfig());
|
|
|
|
var mergedConfig = _.merge(getDefaultConfig(), configJson, function mergeCustomizer(conf1, conf2) {
|
|
|
|
// Arrays should always concat
|
|
|
|
if(_.isArray(conf1)) {
|
|
|
|
// :TODO: look for collisions & override dupes
|
|
|
|
return conf1.concat(conf2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
callback(null, mergedConfig);
|
|
|
|
}
|
|
|
|
],
|
|
|
|
function complete(err, mergedConfig) {
|
|
|
|
exports.config = mergedConfig;
|
|
|
|
cb(err);
|
2014-10-17 02:21:06 +00:00
|
|
|
}
|
2015-04-19 08:13:13 +00:00
|
|
|
);
|
|
|
|
}
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
function getDefaultPath() {
|
|
|
|
var base = miscUtil.resolvePath('~/');
|
|
|
|
if(base) {
|
2015-09-09 04:08:45 +00:00
|
|
|
return paths.join(base, '.enigma-bbs', 'config.hjson');
|
2015-04-19 08:13:13 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
function getDefaultConfig() {
|
|
|
|
return {
|
|
|
|
general : {
|
2015-08-03 00:27:05 +00:00
|
|
|
boardName : 'Another Fine ENiGMA½ BBS',
|
2015-10-22 04:51:35 +00:00
|
|
|
|
2015-10-22 18:22:03 +00:00
|
|
|
closedSystem : false, // is the system closed to new users?
|
|
|
|
|
2015-10-22 04:51:35 +00:00
|
|
|
loginAttempts : 3,
|
2015-04-19 08:13:13 +00:00
|
|
|
},
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
preLoginTheme : '*',
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
users : {
|
|
|
|
usernameMin : 2,
|
2015-06-25 04:45:21 +00:00
|
|
|
usernameMax : 16, // Note that FidoNet wants 36 max
|
2015-04-19 08:13:13 +00:00
|
|
|
usernamePattern : '^[A-Za-z0-9~!@#$%^&*()\\-\\_+]+$',
|
|
|
|
passwordMin : 6,
|
2015-04-27 02:46:16 +00:00
|
|
|
passwordMax : 128,
|
2015-04-19 08:13:13 +00:00
|
|
|
requireActivation : true, // require SysOp activation?
|
|
|
|
invalidUsernames : [],
|
2015-08-21 04:29:16 +00:00
|
|
|
|
|
|
|
groups : [ 'users', 'sysops' ], // built in groups
|
2015-10-22 17:04:50 +00:00
|
|
|
defaultGroups : [ 'users' ], // default groups new users belong to
|
|
|
|
|
|
|
|
newUserNames : [ 'new', 'apply' ], // Names reserved for applying
|
2015-10-22 19:01:16 +00:00
|
|
|
badUserNames : [ 'sysop', 'admin', 'administrator', 'root' ],
|
2015-04-19 08:13:13 +00:00
|
|
|
},
|
2015-04-17 04:29:53 +00:00
|
|
|
|
2015-09-09 04:08:45 +00:00
|
|
|
// :TODO: better name for "defaults"... which is redundant here!
|
|
|
|
/*
|
|
|
|
Concept
|
|
|
|
"theme" : {
|
|
|
|
"default" : "defaultThemeName", // or "*"
|
|
|
|
"preLogin" : "*",
|
|
|
|
"passwordChar" : "*",
|
|
|
|
...
|
|
|
|
}
|
|
|
|
*/
|
2015-04-19 08:13:13 +00:00
|
|
|
defaults : {
|
2015-09-28 04:05:40 +00:00
|
|
|
theme : 'luciano_blocktronics',
|
2015-04-19 08:13:13 +00:00
|
|
|
passwordChar : '*', // TODO: move to user ?
|
2015-07-24 04:23:44 +00:00
|
|
|
dateFormat : {
|
2015-07-23 03:35:35 +00:00
|
|
|
short : 'MM/DD/YYYY',
|
2015-07-24 04:23:44 +00:00
|
|
|
},
|
|
|
|
timeFormat : {
|
2015-07-25 22:10:12 +00:00
|
|
|
short : 'h:mm a',
|
2015-09-02 04:42:54 +00:00
|
|
|
},
|
|
|
|
dateTimeFormat : {
|
|
|
|
short : 'MM/DD/YYYY h:mm a',
|
2015-07-23 03:35:35 +00:00
|
|
|
}
|
2015-04-19 08:13:13 +00:00
|
|
|
},
|
2015-04-15 04:27:07 +00:00
|
|
|
|
2015-09-09 04:08:45 +00:00
|
|
|
menus : {
|
|
|
|
cls : true, // Clear screen before each menu by default?
|
|
|
|
},
|
2015-05-14 04:21:55 +00:00
|
|
|
|
2015-04-19 08:13:13 +00:00
|
|
|
paths : {
|
|
|
|
mods : paths.join(__dirname, './../mods/'),
|
|
|
|
servers : paths.join(__dirname, './servers/'),
|
|
|
|
art : paths.join(__dirname, './../mods/art/'),
|
2015-05-14 22:49:19 +00:00
|
|
|
themes : paths.join(__dirname, './../mods/themes/'),
|
2015-04-19 08:13:13 +00:00
|
|
|
logs : paths.join(__dirname, './../logs/'), // :TODO: set up based on system, e.g. /var/logs/enigmabbs or such
|
|
|
|
db : paths.join(__dirname, './../db/'),
|
2015-08-03 00:27:05 +00:00
|
|
|
dropFiles : paths.join(__dirname, './../dropfiles/'), // + "/node<x>/
|
2015-04-19 08:13:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
servers : {
|
|
|
|
telnet : {
|
|
|
|
port : 8888,
|
|
|
|
enabled : true,
|
2015-10-22 16:36:08 +00:00
|
|
|
firstMenu : 'telnetConnected',
|
2014-10-17 02:21:06 +00:00
|
|
|
},
|
2015-04-19 08:13:13 +00:00
|
|
|
ssh : {
|
2015-10-22 18:22:03 +00:00
|
|
|
port : 8889,
|
|
|
|
enabled : true,
|
|
|
|
rsaPrivateKey : paths.join(__dirname, './../misc/default_key.rsa'),
|
|
|
|
dsaPrivateKey : paths.join(__dirname, './../misc/default_key.dsa'),
|
|
|
|
firstMenu : 'sshConnected',
|
|
|
|
firstMenuNewUser : 'sshConnectedNewUser',
|
2015-04-19 08:13:13 +00:00
|
|
|
}
|
|
|
|
},
|
2015-07-14 06:13:29 +00:00
|
|
|
|
2015-08-20 22:35:04 +00:00
|
|
|
messages : {
|
|
|
|
areas : [
|
2015-08-20 23:00:35 +00:00
|
|
|
{ name : 'private_mail', desc : 'Private Email', groups : [ 'users' ] }
|
2015-08-20 22:35:04 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2015-07-14 06:13:29 +00:00
|
|
|
networks : {
|
|
|
|
/*
|
|
|
|
networkName : { // e.g. fidoNet
|
|
|
|
address : {
|
|
|
|
zone : 0,
|
|
|
|
net : 0,
|
|
|
|
node : 0,
|
|
|
|
point : 0,
|
|
|
|
domain : 'l33t.codes'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
},
|
2015-07-21 04:56:48 +00:00
|
|
|
|
2015-08-05 04:35:59 +00:00
|
|
|
misc : {
|
2015-09-06 21:58:58 +00:00
|
|
|
idleLogoutSeconds : 60 * 6, // 6m
|
2015-08-05 04:35:59 +00:00
|
|
|
},
|
|
|
|
|
2015-07-21 04:56:48 +00:00
|
|
|
logging : {
|
|
|
|
level : 'debug'
|
|
|
|
}
|
2015-04-19 08:13:13 +00:00
|
|
|
};
|
|
|
|
}
|