mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-10 14:44:40 +02:00
* User idle timeout
* Only allow one session per user at a time * user 'timestamp' property -> 'account_created' * Better User.getLegacySecurityLevel() using group membership * Client connection management -> client_connections.js * Minor changes & cleanup
This commit is contained in:
parent
36a8d771e8
commit
8d1fac41a9
11 changed files with 164 additions and 52 deletions
57
core/client_connections.js
Normal file
57
core/client_connections.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var logger = require('./logger.js');
|
||||
|
||||
exports.addNewClient = addNewClient;
|
||||
exports.removeClient = removeClient;
|
||||
|
||||
var clientConnections = [];
|
||||
exports.clientConnections = clientConnections;
|
||||
|
||||
function addNewClient(client) {
|
||||
var id = client.runtime.id = clientConnections.push(client) - 1;
|
||||
|
||||
// Create a client specific logger
|
||||
client.log = logger.log.child( { clientId : id } );
|
||||
|
||||
var connInfo = { ip : client.input.remoteAddress };
|
||||
|
||||
if(client.log.debug()) {
|
||||
connInfo.port = client.input.localPort;
|
||||
connInfo.family = client.input.localFamily;
|
||||
}
|
||||
|
||||
client.log.info(connInfo, 'Client connected');
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
function removeClient(client) {
|
||||
client.end();
|
||||
|
||||
var i = clientConnections.indexOf(client);
|
||||
if(i > -1) {
|
||||
clientConnections.splice(i, 1);
|
||||
|
||||
logger.log.info(
|
||||
{
|
||||
connectionCount : clientConnections.length,
|
||||
clientId : client.runtime.id
|
||||
},
|
||||
'Client disconnected'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* :TODO: make a public API elsewhere
|
||||
function getActiveClientInformation() {
|
||||
var info = {};
|
||||
|
||||
clientConnections.forEach(function connEntry(cc) {
|
||||
|
||||
});
|
||||
|
||||
return info;
|
||||
}
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue