making rate limiter work 3
This commit is contained in:
parent
6e9edca86d
commit
5465f32111
@ -10,13 +10,18 @@ module.exports.init = function(io_ext) {
|
||||
if (ios) {
|
||||
// when a new socket connects
|
||||
ios.sockets.on('connection', function(socket) {
|
||||
logger.debug('New connection from ' + socket.id);
|
||||
logger.verbose('New connection from ' + socket.id);
|
||||
// when it subscribes, make it join the according room
|
||||
socket.on('subscribe', function(topic) {
|
||||
logger.debug('subscribe to ' + topic);
|
||||
socket.join(topic);
|
||||
});
|
||||
|
||||
// disconnect handler
|
||||
socket.on('disconnect', function() {
|
||||
logger.verbose('disconnected ' + socket.id);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
return ios;
|
||||
@ -65,4 +70,3 @@ module.exports.broadcastSyncInfo = function(historicSync) {
|
||||
if (ios)
|
||||
ios.sockets.in('sync').emit('status', historicSync);
|
||||
};
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ module.exports.init = function(ext_io, config) {
|
||||
io.sockets.on('connection', function(socket) {
|
||||
// when it requests sync, send him all pending messages
|
||||
socket.on('sync', function(ts) {
|
||||
logger.debug('Sync requested by ' + socket.id);
|
||||
logger.verbose('Sync requested by ' + socket.id);
|
||||
logger.debug(' from timestamp ' + ts);
|
||||
var rooms = socket.rooms;
|
||||
if (rooms.length !== 2) {
|
||||
@ -25,7 +25,7 @@ module.exports.init = function(ext_io, config) {
|
||||
if (err) {
|
||||
throw new Error('Couldn\'t get messages on sync request: ' + err);
|
||||
}
|
||||
logger.debug('\tFound ' + messages.length + ' message' + (messages.length !== 1 ? 's' : ''));
|
||||
logger.verbose('\tFound ' + messages.length + ' message' + (messages.length !== 1 ? 's' : ''));
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
broadcastMessage(messages[i], socket);
|
||||
}
|
||||
@ -42,10 +42,6 @@ module.exports.init = function(ext_io, config) {
|
||||
});
|
||||
});
|
||||
|
||||
// disconnect handler
|
||||
socket.on('disconnect', function() {
|
||||
logger.debug('disconnected ' + socket.id);
|
||||
});
|
||||
});
|
||||
|
||||
mdb.on('message', broadcastMessage);
|
||||
|
||||
@ -10,9 +10,8 @@ module.exports.init = function(app, config) {
|
||||
|
||||
config = config || {};
|
||||
config.whitelistRPH = config.whitelistRPH || 5000;
|
||||
config.normalRPH = config.normalRPH || 2;
|
||||
config.normalRPH = config.normalRPH || 500;
|
||||
config.blacklistRPH = config.blacklistRPH || 0;
|
||||
console.log(config);
|
||||
|
||||
app.use(limiter({
|
||||
whitelist: [],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user