Skip to content
Permalink
Browse files

Merge pull request #3420 from hacst/nochanlim

Introduce channelcountlimit to limit max channels per server
  • Loading branch information...
hacst committed Jun 14, 2018
2 parents e85191b + 5b034be commit 23eb3d171bbd22b721fb4a966a355c848730e914
Showing with 25 additions and 0 deletions.
  1. +4 −0 scripts/murmur.ini
  2. +3 −0 src/Mumble.proto
  3. +4 −0 src/mumble/Messages.cpp
  4. +5 −0 src/murmur/Messages.cpp
  5. +3 −0 src/murmur/Meta.cpp
  6. +1 −0 src/murmur/Meta.h
  7. +4 −0 src/murmur/Server.cpp
  8. +1 −0 src/murmur/Server.h
@@ -151,6 +151,10 @@ allowping=true
; InnoDB will fail when operating on deeply nested channels.
;channelnestinglimit=10

; Maximum number of channels per server. 0 for unlimited. Note that an
; excessive number of channels will impact server performance
;channelcountlimit=1000

; Regular expression used to validate channel names.
; (Note that you have to escape backslashes with \ )
;channelname=[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+
@@ -280,7 +280,10 @@ message PermissionDenied {
UserName = 8;
// Channel is full.
ChannelFull = 9;
// Channels are nested too deply.
NestingLimit = 10;
// Maximum channel count reached.
ChannelCountLimit = 11;
}
// The denied permission when type is Permission.
optional uint32 permission = 1;
@@ -242,6 +242,10 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) {
g.l->log(Log::PermissionDenied, tr("Channel nesting limit reached."));
}
break;
case MumbleProto::PermissionDenied_DenyType_ChannelCountLimit: {
g.l->log(Log::PermissionDenied, tr("Channel count limit reached. Need to delete channels before creating new ones."));
}
break;
default: {
if (msg.has_reason())
g.l->log(Log::PermissionDenied, tr("Denied: %1.").arg(Qt::escape(u8(msg.reason()))));
@@ -896,6 +896,11 @@ void Server::msgChannelState(ServerUser *uSource, MumbleProto::ChannelState &msg
if (! p || qsName.isNull())
return;

if (iChannelCountLimit != 0 && qhChannels.count() >= iChannelCountLimit) {
PERM_DENIED_FALLBACK(ChannelCountLimit, 0x010300, QLatin1String("Channel count limit reached"));
return;
}

ChanACL::Perm perm = msg.temporary() ? ChanACL::MakeTempChannel : ChanACL::MakeChannel;
if (! hasPermission(uSource, p, perm)) {
PERM_DENIED(uSource, p, perm);
@@ -69,6 +69,7 @@ MetaParams::MetaParams() {
iOpusThreshold = 100;

iChannelNestingLimit = 10;
iChannelCountLimit = 1000;

qrUserName = QRegExp(QLatin1String("[-=\\w\\[\\]\\{\\}\\(\\)\\@\\|\\.]+"));
qrChannelName = QRegExp(QLatin1String("[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+"));
@@ -341,6 +342,7 @@ void MetaParams::read(QString fname) {
iOpusThreshold = typeCheckedFromSettings("opusthreshold", iOpusThreshold);

iChannelNestingLimit = typeCheckedFromSettings("channelnestinglimit", iChannelNestingLimit);
iChannelCountLimit = typeCheckedFromSettings("channelcountlimit", iChannelCountLimit);

#ifdef Q_OS_UNIX
qsName = qsSettings->value("uname").toString();
@@ -414,6 +416,7 @@ void MetaParams::read(QString fname) {
qmConfig.insert(QLatin1String("suggestpushtotalk"), qvSuggestPushToTalk.isNull() ? QString() : qvSuggestPushToTalk.toString());
qmConfig.insert(QLatin1String("opusthreshold"), QString::number(iOpusThreshold));
qmConfig.insert(QLatin1String("channelnestinglimit"), QString::number(iChannelNestingLimit));
qmConfig.insert(QLatin1String("channelcountlimit"), QString::number(iChannelCountLimit));
qmConfig.insert(QLatin1String("sslCiphers"), qsCiphers);
qmConfig.insert(QLatin1String("sslDHParams"), QString::fromLatin1(qbaDHParams.constData()));
}
@@ -39,6 +39,7 @@ class MetaParams {
int iMaxImageMessageLength;
int iOpusThreshold;
int iChannelNestingLimit;
int iChannelCountLimit;
/// If true the old SHA1 password hashing is used instead of PBKDF2
bool legacyPasswordHash;
/// Contains the default number of PBKDF2 iterations to use
@@ -397,6 +397,7 @@ void Server::readParams() {
qvSuggestPushToTalk = Meta::mp.qvSuggestPushToTalk;
iOpusThreshold = Meta::mp.iOpusThreshold;
iChannelNestingLimit = Meta::mp.iChannelNestingLimit;
iChannelCountLimit = Meta::mp.iChannelCountLimit;

QString qsHost = getConf("host", QString()).toString();
if (! qsHost.isEmpty()) {
@@ -463,6 +464,7 @@ void Server::readParams() {
iOpusThreshold = getConf("opusthreshold", iOpusThreshold).toInt();

iChannelNestingLimit = getConf("channelnestinglimit", iChannelNestingLimit).toInt();
iChannelCountLimit = getConf("channelcountlimit", iChannelCountLimit).toInt();

qrUserName=QRegExp(getConf("username", qrUserName.pattern()).toString());
qrChannelName=QRegExp(getConf("channelname", qrChannelName.pattern()).toString());
@@ -582,6 +584,8 @@ void Server::setLiveConf(const QString &key, const QString &value) {
iOpusThreshold = (i >= 0 && !v.isNull()) ? qBound(0, i, 100) : Meta::mp.iOpusThreshold;
else if (key == "channelnestinglimit")
iChannelNestingLimit = (i >= 0 && !v.isNull()) ? i : Meta::mp.iChannelNestingLimit;
else if (key == "channelcountlimit")
iChannelCountLimit = (i >= 0 && !v.isNull()) ? i : Meta::mp.iChannelCountLimit;
}

#ifdef USE_BONJOUR
@@ -171,6 +171,7 @@ class Server : public QThread {

private:
int iChannelNestingLimit;
int iChannelCountLimit;

public slots:
void regSslError(const QList<QSslError> &);

0 comments on commit 23eb3d1

Please sign in to comment.
You can’t perform that action at this time.