_autoReconnectInterval(60),
_autoReconnectRetries(10),
_unlimitedReconnectRetries(false),
+ _useCustomMessageRate(false),
+ _messageRateBurstSize(5),
+ _messageRateDelay(2200),
+ _unlimitedMessageRate(false),
_codecForServer(0),
_codecForEncoding(0),
_codecForDecoding(0),
info.autoReconnectRetries = autoReconnectRetries();
info.unlimitedReconnectRetries = unlimitedReconnectRetries();
info.rejoinChannels = rejoinChannels();
+ info.useCustomMessageRate = useCustomMessageRate();
+ info.messageRateBurstSize = messageRateBurstSize();
+ info.messageRateDelay = messageRateDelay();
+ info.unlimitedMessageRate = unlimitedMessageRate();
return info;
}
if (info.autoReconnectRetries != autoReconnectRetries()) setAutoReconnectRetries(info.autoReconnectRetries);
if (info.unlimitedReconnectRetries != unlimitedReconnectRetries()) setUnlimitedReconnectRetries(info.unlimitedReconnectRetries);
if (info.rejoinChannels != rejoinChannels()) setRejoinChannels(info.rejoinChannels);
+ // Custom rate limiting
+ if (info.useCustomMessageRate != useCustomMessageRate())
+ setUseCustomMessageRate(info.useCustomMessageRate);
+ if (info.messageRateBurstSize != messageRateBurstSize())
+ setMessageRateBurstSize(info.messageRateBurstSize);
+ if (info.messageRateDelay != messageRateDelay())
+ setMessageRateDelay(info.messageRateDelay);
+ if (info.unlimitedMessageRate != unlimitedMessageRate())
+ setUnlimitedMessageRate(info.unlimitedMessageRate);
}
}
+void Network::setUseCustomMessageRate(bool useCustomRate)
+{
+ if (_useCustomMessageRate != useCustomRate) {
+ _useCustomMessageRate = useCustomRate;
+ SYNC(ARG(useCustomRate))
+ emit configChanged();
+ emit useCustomMessageRateSet(_useCustomMessageRate);
+ }
+}
+
+
+void Network::setMessageRateBurstSize(quint32 burstSize)
+{
+ if (burstSize < 1) {
+ // Can't go slower than one message at a time. Also blocks old clients from trying to set
+ // this to 0.
+ qWarning() << "Received invalid setMessageRateBurstSize data - message burst size must be "
+ "non-zero positive, given" << burstSize;
+ return;
+ }
+ if (_messageRateBurstSize != burstSize) {
+ _messageRateBurstSize = burstSize;
+ SYNC(ARG(burstSize))
+ emit configChanged();
+ emit messageRateBurstSizeSet(_messageRateBurstSize);
+ }
+}
+
+
+void Network::setMessageRateDelay(quint32 messageDelay)
+{
+ if (messageDelay == 0) {
+ // Nonsensical to have no delay - just check the Unlimited box instead. Also blocks old
+ // clients from trying to set this to 0.
+ qWarning() << "Received invalid setMessageRateDelay data - message delay must be non-zero "
+ "positive, given" << messageDelay;
+ return;
+ }
+ if (_messageRateDelay != messageDelay) {
+ _messageRateDelay = messageDelay;
+ SYNC(ARG(messageDelay))
+ emit configChanged();
+ emit messageRateDelaySet(_messageRateDelay);
+ }
+}
+
+
+void Network::setUnlimitedMessageRate(bool unlimitedRate)
+{
+ if (_unlimitedMessageRate != unlimitedRate) {
+ _unlimitedMessageRate = unlimitedRate;
+ SYNC(ARG(unlimitedRate))
+ emit configChanged();
+ emit unlimitedMessageRateSet(_unlimitedMessageRate);
+ }
+}
+
+
void Network::addSupport(const QString ¶m, const QString &value)
{
if (!_supports.contains(param)) {
void Network::clearCaps()
{
// IRCv3 specs all use lowercase capability names
+ if (_caps.empty() && _capsEnabled.empty()) {
+ // Avoid the sync call if there's nothing to clear (e.g. failed reconnects)
+ return;
+ }
// To ease core-side configuration, loop through the list and emit capRemoved for each entry.
// If performance issues arise, this can be converted to a more-efficient setup without breaking
// protocol (in theory).
autoReconnectInterval(60),
autoReconnectRetries(20),
unlimitedReconnectRetries(false),
- rejoinChannels(true)
+ rejoinChannels(true),
+ useCustomMessageRate(false),
+ messageRateBurstSize(5),
+ messageRateDelay(2200),
+ unlimitedMessageRate(false)
{
}
if (autoReconnectRetries != other.autoReconnectRetries) return false;
if (unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
if (rejoinChannels != other.rejoinChannels) return false;
+ // Custom rate limiting
+ if (useCustomMessageRate != other.useCustomMessageRate) return false;
+ if (messageRateBurstSize != other.messageRateBurstSize) return false;
+ if (messageRateDelay != other.messageRateDelay) return false;
+ if (unlimitedMessageRate != other.unlimitedMessageRate) return false;
return true;
}
i["AutoReconnectRetries"] = info.autoReconnectRetries;
i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
i["RejoinChannels"] = info.rejoinChannels;
+ // Custom rate limiting
+ i["UseCustomMessageRate"] = info.useCustomMessageRate;
+ i["MessageRateBurstSize"] = info.messageRateBurstSize;
+ i["MessageRateDelay"] = info.messageRateDelay;
+ i["UnlimitedMessageRate"] = info.unlimitedMessageRate;
out << i;
return out;
}
info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
info.rejoinChannels = i["RejoinChannels"].toBool();
+ // Custom rate limiting
+ info.useCustomMessageRate = i["UseCustomMessageRate"].toBool();
+ info.messageRateBurstSize = i["MessageRateBurstSize"].toUInt();
+ info.messageRateDelay = i["MessageRateDelay"].toUInt();
+ info.unlimitedMessageRate = i["UnlimitedMessageRate"].toBool();
return in;
}
<< " useSasl = " << i.useSasl << " saslAccount = " << i.saslAccount << " saslPassword = " << i.saslPassword
<< " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
<< " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
- << " rejoinChannels = " << i.rejoinChannels << ")";
+ << " rejoinChannels = " << i.rejoinChannels
+ << " useCustomMessageRate = " << i.useCustomMessageRate
+ << " messageRateBurstSize = " << i.messageRateBurstSize
+ << " messageRateDelay = " << i.messageRateDelay
+ << " unlimitedMessageRate = " << i.unlimitedMessageRate
+ << ")";
return dbg.space();
}
serverMap["Port"] = server.port;
serverMap["Password"] = server.password;
serverMap["UseSSL"] = server.useSsl;
+ serverMap["sslVerify"] = server.sslVerify;
serverMap["sslVersion"] = server.sslVersion;
serverMap["UseProxy"] = server.useProxy;
serverMap["ProxyType"] = server.proxyType;
server.port = serverMap["Port"].toUInt();
server.password = serverMap["Password"].toString();
server.useSsl = serverMap["UseSSL"].toBool();
+ server.sslVerify = serverMap["sslVerify"].toBool();
server.sslVersion = serverMap["sslVersion"].toInt();
server.useProxy = serverMap["UseProxy"].toBool();
server.proxyType = serverMap["ProxyType"].toInt();
if (port != other.port) return false;
if (password != other.password) return false;
if (useSsl != other.useSsl) return false;
+ if (sslVerify != other.sslVerify) return false;
if (sslVersion != other.sslVersion) return false;
if (useProxy != other.useProxy) return false;
if (proxyType != other.proxyType) return false;
QDebug operator<<(QDebug dbg, const Network::Server &server)
{
- dbg.nospace() << "Server(host = " << server.host << ":" << server.port << ", useSsl = " << server.useSsl << ")";
+ dbg.nospace() << "Server(host = " << server.host << ":" << server.port << ", useSsl = " <<
+ server.useSsl << ", sslVerify = " << server.sslVerify << ")";
return dbg.space();
}