mirror of
https://github.com/Yonle/bostr.git
synced 2025-10-10 00:22:33 +02:00
bouncer: do not keep unauthorized session.
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
@@ -136,6 +136,7 @@ module.exports = (ws, req, onClose) => {
|
|||||||
ws.on('error', console.error);
|
ws.on('error', console.error);
|
||||||
ws.on('close', _ => {
|
ws.on('close', _ => {
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
console.log(process.pid, "---", `${ip} (${ws.id}) disconnected (${howManyOrphanSess()+1} orphans)`);
|
console.log(process.pid, "---", `${ip} (${ws.id}) disconnected (${howManyOrphanSess()+1} orphans)`);
|
||||||
if (csess.has(ws.id)) {
|
if (csess.has(ws.id)) {
|
||||||
csess.set(ws.id, null); // set as orphan.
|
csess.set(ws.id, null); // set as orphan.
|
||||||
@@ -145,7 +146,8 @@ module.exports = (ws, req, onClose) => {
|
|||||||
clearTimeout(i[1]);
|
clearTimeout(i[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!authorized) return;
|
// unauthorized session must be destroyed.
|
||||||
|
if (!authorized) terminate_sess(ws.id);
|
||||||
|
|
||||||
for (const i of ws.reconnectTimeout) {
|
for (const i of ws.reconnectTimeout) {
|
||||||
clearTimeout(i);
|
clearTimeout(i);
|
||||||
|
Reference in New Issue
Block a user