Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce channelcountlimit to limit max channels per server #3420

Merged
merged 3 commits into from Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/murmur.ini
Expand Up @@ -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\\#\\[\\]\\{\\}\\(\\)\\@\\|]+
Expand Down
3 changes: 3 additions & 0 deletions src/Mumble.proto
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/mumble.pri
Expand Up @@ -8,7 +8,7 @@ include(../qmake/qt.pri)
include(../qmake/rcc.pri)
include(../qmake/pkgconfig.pri)

VERSION = 1.3.0
VERSION = 1.3.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave the version as it is.

DIST = mumble.pri Message.h PacketDataStream.h CryptState.h Timer.h Version.h OSInfo.h SSL.h
CONFIG += qt thread debug_and_release warn_on
DEFINES *= MUMBLE_VERSION_STRING=$$VERSION
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/Messages.cpp
Expand Up @@ -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()))));
Expand Down
5 changes: 5 additions & 0 deletions src/murmur/Messages.cpp
Expand Up @@ -896,6 +896,11 @@ void Server::msgChannelState(ServerUser *uSource, MumbleProto::ChannelState &msg
if (! p || qsName.isNull())
return;

if (iChannelCountLimit == 0 || qhChannels.count() >= iChannelCountLimit) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

if (iChannelCountLimit != 0 && qhChannels.count() >= iChannelCountLimit) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right. Fixed.

PERM_DENIED_FALLBACK(ChannelCountLimit, 0x010301, 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);
Expand Down
3 changes: 3 additions & 0 deletions src/murmur/Meta.cpp
Expand Up @@ -69,6 +69,7 @@ MetaParams::MetaParams() {
iOpusThreshold = 100;

iChannelNestingLimit = 10;
iChannelCountLimit = 1000;

qrUserName = QRegExp(QLatin1String("[-=\\w\\[\\]\\{\\}\\(\\)\\@\\|\\.]+"));
qrChannelName = QRegExp(QLatin1String("[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+"));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()));
}
Expand Down
1 change: 1 addition & 0 deletions src/murmur/Meta.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/murmur/Server.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/murmur/Server.h
Expand Up @@ -171,6 +171,7 @@ class Server : public QThread {

private:
int iChannelNestingLimit;
int iChannelCountLimit;

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