diff --git a/auxiliary_files/mumble-server.ini b/auxiliary_files/mumble-server.ini index c7d0dbc0610..1c267a04cc4 100644 --- a/auxiliary_files/mumble-server.ini +++ b/auxiliary_files/mumble-server.ini @@ -396,6 +396,12 @@ allowping=true ; ; allowRecording=true +; The time frame in seconds the server will keep rolling packet stats for each client. +; The default is 5 minutes = 300 seconds. Set to 0 to disable rolling packet stats. +; This opetion has been introduced with 1.6.0 +; +; rollingStatsSeconds=300 + ; The amount of allowed listener proxies in a single channel. It defaults to -1 ; meaning that there is no limit. Set to 0 to disable Channel Listeners altogether. ; This option has been introduced with 1.4.0. diff --git a/src/crypto/CryptState.cpp b/src/crypto/CryptState.cpp index 50f87d9191a..9e26adb165d 100644 --- a/src/crypto/CryptState.cpp +++ b/src/crypto/CryptState.cpp @@ -6,6 +6,10 @@ #include "CryptState.h" void CryptState::handleRollingStats() { + if (!m_rollingStatsEnabled) { + return; + } + std::chrono::time_point< std::chrono::steady_clock > now = std::chrono::steady_clock::now(); // Update no more than every few seconds diff --git a/src/crypto/CryptState.h b/src/crypto/CryptState.h index b423a5631d0..7f1ad251c58 100644 --- a/src/crypto/CryptState.h +++ b/src/crypto/CryptState.h @@ -43,6 +43,7 @@ class CryptState { PacketStats m_statsLocalRolling = {}; PacketStats m_statsRemoteRolling = {}; + bool m_rollingStatsEnabled = false; /// This is the packet statistics sliding time window size in seconds std::chrono::duration< uint32_t, std::ratio< 1 > > m_rollingWindow = std::chrono::seconds(60 * 5); diff --git a/src/murmur/Meta.cpp b/src/murmur/Meta.cpp index ef750b54734..7f33c954caa 100644 --- a/src/murmur/Meta.cpp +++ b/src/murmur/Meta.cpp @@ -112,6 +112,8 @@ MetaParams::MetaParams() { allowRecording = true; + rollingStatsSeconds = 300; + qsSettings = nullptr; } @@ -329,6 +331,8 @@ void MetaParams::read(QString fname) { allowRecording = typeCheckedFromSettings("allowRecording", allowRecording); + rollingStatsSeconds = typeCheckedFromSettings("rollingStatsSeconds", rollingStatsSeconds); + iOpusThreshold = typeCheckedFromSettings("opusthreshold", iOpusThreshold); iChannelNestingLimit = typeCheckedFromSettings("channelnestinglimit", iChannelNestingLimit); diff --git a/src/murmur/Meta.h b/src/murmur/Meta.h index 4a151506e74..2e82219ad7a 100644 --- a/src/murmur/Meta.h +++ b/src/murmur/Meta.h @@ -151,6 +151,9 @@ class MetaParams { /// A flag indicating whether recording is allowed on this server bool allowRecording; + /// The number of seconds to keep rolling stats for per client + uint32_t rollingStatsSeconds; + /// qsAbsSettingsFilePath is the absolute path to /// the murmur.ini used by this Meta instance. QString qsAbsSettingsFilePath; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 17800b3c667..304eafd1d00 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #ifdef Q_OS_WIN @@ -346,6 +347,7 @@ void Server::readParams() { bBonjour = Meta::mp.bBonjour; bAllowPing = Meta::mp.bAllowPing; allowRecording = Meta::mp.allowRecording; + rollingStatsSeconds = Meta::mp.rollingStatsSeconds; bCertRequired = Meta::mp.bCertRequired; bForceExternalAuth = Meta::mp.bForceExternalAuth; qrUserName = Meta::mp.qrUserName; @@ -445,6 +447,7 @@ void Server::readParams() { iChannelNestingLimit = getConf("channelnestinglimit", iChannelNestingLimit).toInt(); iChannelCountLimit = getConf("channelcountlimit", iChannelCountLimit).toInt(); + rollingStatsSeconds = getConf("rollingStatsSeconds", rollingStatsSeconds).toUInt(); qrUserName = decltype(qrUserName)(QRegularExpression::anchoredPattern(getConf("username", qrUserName.pattern()).toString())); @@ -577,6 +580,8 @@ void Server::setLiveConf(const QString &key, const QString &value) { bAllowPing = !v.isNull() ? QVariant(v).toBool() : Meta::mp.bAllowPing; else if (key == "allowrecording") allowRecording = !v.isNull() ? QVariant(v).toBool() : Meta::mp.allowRecording; + else if (key == "rollingStatsSeconds") + rollingStatsSeconds = i ? static_cast< unsigned int >(i) : Meta::mp.rollingStatsSeconds; else if (key == "username") qrUserName = !v.isNull() ? QRegularExpression(v) : Meta::mp.qrUserName; else if (key == "channelname") @@ -1437,6 +1442,11 @@ void Server::newClient() { u->haAddress = ha; HostAddress(sock->localAddress()).toSockaddr(&u->saiTcpLocalAddress); + if (rollingStatsSeconds > 0) { + u->csCrypt->m_rollingStatsEnabled = true; + u->csCrypt->m_rollingWindow = std::chrono::seconds(std::max(10U, rollingStatsSeconds)); + } + connect(u, &ServerUser::connectionClosed, this, &Server::connectionClosed); connect(u, SIGNAL(message(Mumble::Protocol::TCPMessageType, const QByteArray &)), this, SLOT(message(Mumble::Protocol::TCPMessageType, const QByteArray &))); diff --git a/src/murmur/Server.h b/src/murmur/Server.h index e55e6a8d497..804ab2fd9e9 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -137,6 +137,7 @@ class Server : public QThread { bool bBonjour; bool bAllowPing; bool allowRecording; + uint32_t rollingStatsSeconds; QRegularExpression qrUserName; QRegularExpression qrChannelName;