Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs
This commit is contained in:
commit
358fc486fb
|
@ -3,7 +3,11 @@
|
||||||
|
|
||||||
var logger = require('./logger.js');
|
var logger = require('./logger.js');
|
||||||
|
|
||||||
|
var _ = require('lodash');
|
||||||
|
var moment = require('moment');
|
||||||
|
|
||||||
exports.getActiveConnections = getActiveConnections;
|
exports.getActiveConnections = getActiveConnections;
|
||||||
|
exports.getActiveNodeList = getActiveNodeList;
|
||||||
exports.addNewClient = addNewClient;
|
exports.addNewClient = addNewClient;
|
||||||
exports.removeClient = removeClient;
|
exports.removeClient = removeClient;
|
||||||
|
|
||||||
|
@ -14,6 +18,33 @@ function getActiveConnections() {
|
||||||
return clientConnections;
|
return clientConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActiveNodeList() {
|
||||||
|
const now = moment();
|
||||||
|
|
||||||
|
return _.map(getActiveConnections(), ac => {
|
||||||
|
let entry = {
|
||||||
|
node : ac.node,
|
||||||
|
authenticated : ac.user.isAuthenticated(),
|
||||||
|
userId : ac.user.userId,
|
||||||
|
action : _.has(ac, 'currentMenuModule.menuConfig.desc') ? ac.currentMenuModule.menuConfig.desc : 'Unknown',
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// There may be a connection, but not a logged in user as of yet
|
||||||
|
//
|
||||||
|
if(ac.user.isAuthenticated()) {
|
||||||
|
entry.userName = ac.user.username;
|
||||||
|
entry.realName = ac.user.properties.real_name;
|
||||||
|
entry.location = ac.user.properties.location;
|
||||||
|
entry.affils = ac.user.properties.affiliation;
|
||||||
|
|
||||||
|
const diff = now.diff(moment(ac.user.properties.last_login_timestamp), 'minutes');
|
||||||
|
entry.timeOn = moment.duration(diff, 'minutes');
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addNewClient(client, clientSock) {
|
function addNewClient(client, clientSock) {
|
||||||
var id = client.session.id = clientConnections.push(client) - 1;
|
var id = client.session.id = clientConnections.push(client) - 1;
|
||||||
|
|
||||||
|
|
|
@ -209,12 +209,7 @@ function getMergedTheme(menuConfig, promptConfig, theme) {
|
||||||
var mergedThemeMenu = mergedTheme[areaName][menuName];
|
var mergedThemeMenu = mergedTheme[areaName][menuName];
|
||||||
|
|
||||||
if(_.has(theme, [ 'customization', areaName, menuName ])) {
|
if(_.has(theme, [ 'customization', areaName, menuName ])) {
|
||||||
|
var menuTheme = theme.customization[areaName][menuName];
|
||||||
if('telnetConnected' === menuName || 'mainMenuLastCallers' === menuName) {
|
|
||||||
console.log('break me')
|
|
||||||
}
|
|
||||||
|
|
||||||
var menuTheme = theme.customization[areaName][menuName];
|
|
||||||
|
|
||||||
// config block is direct assign/overwrite
|
// config block is direct assign/overwrite
|
||||||
// :TODO: should probably be _.merge()
|
// :TODO: should probably be _.merge()
|
||||||
|
|
|
@ -8,9 +8,21 @@ TL;DR? This should get you started...
|
||||||
* [Node.js](https://nodejs.org/) version **v0.12.2 or higher** (v4.2+ is recommended)
|
* [Node.js](https://nodejs.org/) version **v0.12.2 or higher** (v4.2+ is recommended)
|
||||||
* [io.js](https://iojs.org/) should also work, though I have not yet tested this.
|
* [io.js](https://iojs.org/) should also work, though I have not yet tested this.
|
||||||
* :information_source: It is suggested to use [nvm](https://github.com/creationix/nvm) to manage your Node/io.js installs
|
* :information_source: It is suggested to use [nvm](https://github.com/creationix/nvm) to manage your Node/io.js installs
|
||||||
* Windows users will need additional dependencies installed for the `npm install` step in order to compile native binaries:
|
* **Windows users will need additional dependencies installed** for the `npm install` step in order to compile native binaries:
|
||||||
* A recent copy of Visual Studio (Express editions OK)
|
* A recent copy of Visual Studio ([Visual Studio Express](https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx) editions OK)
|
||||||
* Python 2.7.x
|
* [Python](https://www.python.org/downloads/) 2.7.x
|
||||||
|
|
||||||
|
## New to Node
|
||||||
|
If you're new to Node.js and/or do not care about Node itself and just want to get ENiGMA½ running these steps should get you going on most \*nix type enviornments:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
|
||||||
|
nvm install 4.2.4
|
||||||
|
nvm use 4.2.4
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
If the above completed without errors, you should now have `nvm`, `node`, and `npm` installed and in your environment.
|
||||||
|
|
||||||
## Clone
|
## Clone
|
||||||
```bash
|
```bash
|
||||||
|
@ -19,6 +31,7 @@ git clone https://github.com/NuSkooler/enigma-bbs.git
|
||||||
|
|
||||||
## Install Node Modules
|
## Install Node Modules
|
||||||
```bash
|
```bash
|
||||||
|
cd enigma-bbs
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -53,12 +66,15 @@ messages: {
|
||||||
./main.js
|
./main.js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
ENiGMA½ does not produce much to standard out. See below for tailing the log file to see what's going on.
|
||||||
|
|
||||||
|
### Points of Interest
|
||||||
|
* Default ports are 8888 (Telnet) and 8889 (SSH)
|
||||||
|
* Note that on *nix systems port such as telnet/23 are privileged (e.g. require root). See [this SO article](http://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode) for some tips on using these ports on your system if desired.
|
||||||
|
* The first user you create via applying is the SysOp (aka root)
|
||||||
|
* You may want to tail the logfile with Bunyan: `tail -F ./logs/enigma-bbs.log | ./node_modules/bunyan/bin/bunyan`
|
||||||
|
|
||||||
# Advanced Installation
|
# Advanced Installation
|
||||||
If you've become convinced you would like a "production" BBS running ENiGMA½ a more advanced installation may be in order.
|
If you've become convinced you would like a "production" BBS running ENiGMA½ a more advanced installation may be in order.
|
||||||
|
|
||||||
[PM2](https://github.com/Unitech/pm2) is an excellent choice for managing your running ENiGMA½ instances. Additionally, it is suggested that you run as a specific more locked down user (e.g. 'enigma').
|
[PM2](https://github.com/Unitech/pm2) is an excellent choice for managing your running ENiGMA½ instances. Additionally, it is suggested that you run as a specific more locked down user (e.g. 'enigma').
|
||||||
|
|
||||||
Some points of interest:
|
|
||||||
* Default ports are 8888 (Telnet) and 8889 (SSH)
|
|
||||||
* The first user you create via applying is the SysOp (aka root)
|
|
||||||
* You may want to tail the logfile with Bunyan: `tail -F ./logs/enigma-bbs.log | ./node_modules/bunyan/bin/bunyan`
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
var MenuModule = require('../core/menu_module.js').MenuModule;
|
var MenuModule = require('../core/menu_module.js').MenuModule;
|
||||||
var ViewController = require('../core/view_controller.js').ViewController;
|
var ViewController = require('../core/view_controller.js').ViewController;
|
||||||
var getActiveConnections = require('../core/client_connections.js').getActiveConnections;
|
var getActiveNodeList = require('../core/client_connections.js').getActiveNodeList;
|
||||||
|
|
||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
@ -67,60 +67,21 @@ WhosOnlineModule.prototype.mciReady = function(mciData, cb) {
|
||||||
function populateList(callback) {
|
function populateList(callback) {
|
||||||
var onlineListView = vc.getView(MciCodeIds.OnlineList);
|
var onlineListView = vc.getView(MciCodeIds.OnlineList);
|
||||||
|
|
||||||
var onlineList = getActiveConnections().slice(0, onlineListView.height);
|
const listFormat = self.menuConfig.config.listFormat || '{node} - {userName} - {action} - {timeOn}';
|
||||||
|
const nonAuthUser = self.menuConfig.config.nonAuthUser || 'Logging In';
|
||||||
|
const otherUnknown = self.menuConfig.config.otherUnknown || 'N/A';
|
||||||
|
const onlineList = getActiveNodeList().slice(0, onlineListView.height);
|
||||||
|
|
||||||
var listFormat = self.menuConfig.config.listFormat || '{node} - {username} - {action} - {timeOn}';
|
onlineListView.setItems(_.map(onlineList, oe => {
|
||||||
|
if(oe.authenticated) {
|
||||||
var now = moment();
|
oe.timeOn = _.capitalize(oe.timeOn.humanize());
|
||||||
|
} else {
|
||||||
onlineListView.setItems(_.map(onlineList, function formatOnlineEntry(oe) {
|
[ 'realName', 'location', 'affils', 'timeOn' ].forEach(m => {
|
||||||
var fmtObj = {
|
oe[m] = otherUnknown;
|
||||||
node : oe.node,
|
});
|
||||||
userId : oe.user.userId,
|
oe.userName = nonAuthUser;
|
||||||
userName : oe.user.username,
|
|
||||||
realName : oe.user.properties.real_name,
|
|
||||||
timeOn : function getTimeOn() {
|
|
||||||
var diff = now.diff(moment(oe.user.properties.last_login_timestamp), 'minutes');
|
|
||||||
return _.capitalize(moment.duration(diff, 'minutes').humanize());
|
|
||||||
},
|
|
||||||
action : function getCurrentAction() {
|
|
||||||
var cmm = oe.currentMenuModule;
|
|
||||||
if(cmm) {
|
|
||||||
return cmm.menuConfig.desc || 'Unknown';
|
|
||||||
}
|
|
||||||
return 'Unknown';
|
|
||||||
//oe.currentMenuModule.menuConfig.desc || 'Unknown',
|
|
||||||
},
|
|
||||||
location : oe.user.properties.location,
|
|
||||||
affils : oe.user.properties.affiliation,
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
return listFormat.format(fmtObj);
|
|
||||||
} catch(e) {
|
|
||||||
console.log('Exception caught formatting: ' + e.toString() + ':\n' + JSON.stringify(fmtObj));
|
|
||||||
}
|
}
|
||||||
/*
|
return listFormat.format(oe);
|
||||||
return listFormat.format({
|
|
||||||
node : oe.node,
|
|
||||||
userId : oe.user.userId,
|
|
||||||
userName : oe.user.username,
|
|
||||||
realName : oe.user.properties.real_name,
|
|
||||||
timeOn : function getTimeOn() {
|
|
||||||
var diff = now.diff(moment(oe.user.properties.last_login_timestamp), 'minutes');
|
|
||||||
return _.capitalize(moment.duration(diff, 'minutes').humanize());
|
|
||||||
},
|
|
||||||
action : function getCurrentAction() {
|
|
||||||
var cmm = oe.currentMenuModule;
|
|
||||||
if(cmm) {
|
|
||||||
return cmm.menuConfig.desc || 'Unknown';
|
|
||||||
}
|
|
||||||
return 'Unknown';
|
|
||||||
//oe.currentMenuModule.menuConfig.desc || 'Unknown',
|
|
||||||
},
|
|
||||||
location : oe.user.properties.location,
|
|
||||||
affils : oe.user.properties.affiliation,
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// :TODO: This is a hack until pipe codes are better implemented
|
// :TODO: This is a hack until pipe codes are better implemented
|
||||||
|
|
Loading…
Reference in New Issue