bouncer: do not keep unauthorized session.

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle
2024-01-27 22:57:41 +07:00
parent 67e44ffb84
commit a0ec8bd2bc

View File

@@ -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.
@@ -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);