From 701f741bf397c07dbcdf3e04c090c6b77b9b17e1 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 17 Mar 2009 22:46:18 +0100 Subject: [PATCH] Improve flood control a bit * Increase token refill rate to 2.2 seconds, should be safer * Empty send queue on disconnect so we don't get flooded off again This still needs some love; a bunch of very long lines still causes Excess Flood in Freenode. I suspect we'll have to introduce a byte rate limit in addition to the line rate limit :/ --- src/core/corenetwork.cpp | 8 +++++--- src/core/corenetwork.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 89afa2ca..b1278ca9 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -192,6 +192,7 @@ void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool _autoReconnectCount = 0; // prohibiting auto reconnect } disablePingTimeout(); + _msgQueue.clear(); IrcUser *me_ = me(); if(me_) { @@ -327,10 +328,10 @@ void CoreNetwork::socketInitialized() { } // TokenBucket to avoid sending too much at once - _messagesPerSecond = 1; + _messageDelay = 2200; // this seems to be a safe value (2.2 seconds delay) _burstSize = 5; - _tokenBucket = 5; // init with a full bucket - _tokenBucketTimer.start(_messagesPerSecond * 1000); + _tokenBucket = _burstSize; // init with a full bucket + _tokenBucketTimer.start(_messageDelay); if(!server.password.isEmpty()) { putRawLine(serverEncode(QString("PASS %1").arg(server.password))); @@ -348,6 +349,7 @@ void CoreNetwork::socketInitialized() { void CoreNetwork::socketDisconnected() { disablePingTimeout(); + _msgQueue.clear(); _autoWhoCycleTimer.stop(); _autoWhoTimer.stop(); diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index dbb8a5e2..d7ebd449 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -194,7 +194,7 @@ private: QTimer _autoWhoTimer, _autoWhoCycleTimer; QTimer _tokenBucketTimer; - int _messagesPerSecond; // token refill speed + int _messageDelay; // token refill speed in ms int _burstSize; // size of the token bucket int _tokenBucket; // the virtual bucket that holds the tokens QList _msgQueue; -- 2.20.1