logs
This commit is contained in:
parent
1a932964c7
commit
cb0d792223
1 changed files with 18 additions and 5 deletions
|
|
@ -68,40 +68,53 @@ module.exports = (
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
io.on("connection", socket => {
|
io.on("connection", socket => {
|
||||||
|
|
||||||
|
logger.info(`io.onconnection`)
|
||||||
|
|
||||||
// this is where we create the websocket connection
|
// this is where we create the websocket connection
|
||||||
// with the GunDB service.
|
// with the GunDB service.
|
||||||
Mediator.createMediator(socket);
|
Mediator.createMediator(socket);
|
||||||
|
|
||||||
logger.debug("socket.handshake", socket.handshake);
|
logger.info(`socket after createmediator`)
|
||||||
|
|
||||||
|
logger.info("socket.handshake", socket.handshake);
|
||||||
|
|
||||||
if (authEnabled) {
|
if (authEnabled) {
|
||||||
|
logger.info('io.onconnection -> authEnabled')
|
||||||
try {
|
try {
|
||||||
const authorizationHeaderToken = getSocketAuthToken(socket);
|
const authorizationHeaderToken = getSocketAuthToken(socket);
|
||||||
|
logger.info('io.onconnection -> authHEaderTOken: ' + JSON.stringify(authorizationHeaderToken))
|
||||||
|
|
||||||
if (authorizationHeaderToken === userToken) {
|
if (authorizationHeaderToken === userToken) {
|
||||||
|
logger.info('io.onconnection -> setting socket._limitUser to false')
|
||||||
socket._limituser = false;
|
socket._limituser = false;
|
||||||
} else if (authorizationHeaderToken === limitUserToken) {
|
} else if (authorizationHeaderToken === limitUserToken) {
|
||||||
|
logger.info('io.onconnection -> setting socket._limitUser to true')
|
||||||
socket._limituser = true;
|
socket._limituser = true;
|
||||||
} else {
|
} else {
|
||||||
|
logger.info('io.onconnection -> disconnecting socket as unauth')
|
||||||
socket.disconnect("unauthorized");
|
socket.disconnect("unauthorized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
logger.info('io.onconnection -> error caught:')
|
||||||
// probably because of missing authorization header
|
// probably because of missing authorization header
|
||||||
logger.debug(err);
|
logger.info(JSON.stringify(err));
|
||||||
|
logger.info('WILL DISCONNECT SOCKET')
|
||||||
socket.disconnect("unauthorized");
|
socket.disconnect("unauthorized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logger.info('io.onconnection -> no auth enabled so setting socket._limituser to false')
|
||||||
socket._limituser = false;
|
socket._limituser = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** printing out the client who joined */
|
/** printing out the client who joined */
|
||||||
logger.debug("New socket client connected (id=" + socket.id + ").");
|
logger.info("New socket client connected (id=" + socket.id + ").");
|
||||||
|
|
||||||
socket.emit("hello", { limitUser: socket._limituser });
|
socket.emit("hello", { limitUser: socket._limituser });
|
||||||
|
|
||||||
socket.broadcast.emit("hello", { remoteAddress: socket.handshake.address });
|
socket.broadcast.emit("hello", { remoteAddress: socket.handshake.address });
|
||||||
|
|
||||||
/** pushing new client to client array*/
|
/** pushing new client to client array*/
|
||||||
|
|
@ -113,7 +126,7 @@ module.exports = (
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
clients.splice(clients.indexOf(socket), 1);
|
clients.splice(clients.indexOf(socket), 1);
|
||||||
unregisterSocketListeners(socket);
|
unregisterSocketListeners(socket);
|
||||||
logger.debug("client disconnected (id=" + socket.id + ").");
|
logger.info("client disconnected (id=" + socket.id + ").");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue