mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Address sources of update leaks in websocket event daemon
This commit is contained in:
parent
952041e5e7
commit
11544751bd
@ -56,13 +56,14 @@ wss_receiver.on('connection', function (socket) {
|
||||
},
|
||||
set_filter: function (request) {
|
||||
var filter = {};
|
||||
if (Array.isArray(request.filter) && request.filter.every(function (channel, index, array) {
|
||||
if (Array.isArray(request.filter) && request.filter.length > 0 &&
|
||||
request.filter.every(function (channel, index, array) {
|
||||
if (typeof channel != 'string')
|
||||
return false;
|
||||
filter[channel] = true;
|
||||
return true;
|
||||
})) {
|
||||
socket.filter = request.filter.length == 0 ? true : filter;
|
||||
socket.filter = filter;
|
||||
followers.add(socket);
|
||||
messages.catch_up(socket);
|
||||
} else {
|
||||
@ -76,7 +77,7 @@ wss_receiver.on('connection', function (socket) {
|
||||
};
|
||||
|
||||
socket.got_message = function (message) {
|
||||
if (socket.filter === true || message.channel in socket.filter)
|
||||
if (message.channel in socket.filter)
|
||||
socket.send(JSON.stringify(message));
|
||||
socket.last_msg = message.id;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user