Skip to content

Commit

Permalink
bouncer: do not keep unauthorized session.
Browse files Browse the repository at this point in the history
Signed-off-by: Yonle <yonle@lecturify.net>
  • Loading branch information
Yonle committed Jan 27, 2024
1 parent 67e44ff commit a0ec8bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bouncer.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ module.exports = (ws, req, onClose) => {
ws.on('error', console.error);
ws.on('close', _ => {
onClose();

console.log(process.pid, "---", `${ip} (${ws.id}) disconnected (${howManyOrphanSess()+1} orphans)`);
if (csess.has(ws.id)) {
csess.set(ws.id, null); // set as orphan.
Expand All @@ -145,7 +146,8 @@ module.exports = (ws, req, onClose) => {
clearTimeout(i[1]);
}

if (!authorized) return;
// unauthorized session must be destroyed.
if (!authorized) terminate_sess(ws.id);

for (const i of ws.reconnectTimeout) {
clearTimeout(i);
Expand Down

0 comments on commit a0ec8bd

Please sign in to comment.