mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-10 14:44:40 +02:00
+ Add unique session ID to client sessions
* Aliased to user for convienence * Added to logs for easy tracing * Can be used from events/etc. for grouping
This commit is contained in:
parent
fbe87640c5
commit
1cb811576b
2 changed files with 15 additions and 3 deletions
|
@ -8,6 +8,7 @@ const Events = require('./events.js');
|
|||
// deps
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
const hashids = require('hashids');
|
||||
|
||||
exports.getActiveConnections = getActiveConnections;
|
||||
exports.getActiveNodeList = getActiveNodeList;
|
||||
|
@ -60,9 +61,12 @@ function addNewClient(client, clientSock) {
|
|||
const id = client.session.id = clientConnections.push(client) - 1;
|
||||
const remoteAddress = client.remoteAddress = clientSock.remoteAddress;
|
||||
|
||||
// create a uniqe identifier one-time ID for this session
|
||||
client.session.uniqueId = new hashids('ENiGMA½ClientSession').encode([ id, moment().valueOf() ]);
|
||||
|
||||
// Create a client specific logger
|
||||
// Note that this will be updated @ login with additional information
|
||||
client.log = logger.log.child( { clientId : id } );
|
||||
client.log = logger.log.child( { clientId : id, sessionId : client.session.uniqueId } );
|
||||
|
||||
const connInfo = {
|
||||
remoteAddress : remoteAddress,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue