Fix IP banning logic to ensure error handling is correctly scoped
This commit is contained in:
parent
2efd9bd36e
commit
57e87ac129
1 changed files with 5 additions and 3 deletions
8
ws/ws.js
8
ws/ws.js
|
|
@ -342,8 +342,9 @@ if (process.env.MAINTENANCE_SECRET) {
|
|||
bannedIps.add(ip);
|
||||
let cnt = 0;
|
||||
// kick all players with this ip
|
||||
try {
|
||||
for (const player of players.values()) {
|
||||
try {
|
||||
|
||||
if (player.ip.includes(ip)) {
|
||||
if (player.ws) player.ws.close();
|
||||
else {
|
||||
|
|
@ -351,10 +352,11 @@ if (process.env.MAINTENANCE_SECRET) {
|
|||
}
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
} catch(e) {
|
||||
console.error('Error banning IP', e, currentDate());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setCorsHeaders(res);
|
||||
res.writeHeader('Content-Type', 'text/htmk');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue