Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2020-01-04 13:28:35 +0300
committerRobert Adam <dev@robert-adam.de>2020-02-28 20:41:00 +0300
commit69fe7c6909b72c2299dbb34cb60cd6d3b50c8837 (patch)
tree3b6aff035f5490bdf52a6bb696fc4ccd8b180fd9 /src/murmur/Messages.cpp
parent7f7cc6c5538c0854305a15a3789bbe466f93c9a6 (diff)
Protocol: Added fields 'is_enter_restricted' and 'can_enter' to the ChannelState message in order for the protocol to be able to tell clients about which channels they will be able to enter
Diffstat (limited to 'src/murmur/Messages.cpp')
-rw-r--r--src/murmur/Messages.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp
index 4ab9d22f1..ed137ce76 100644
--- a/src/murmur/Messages.cpp
+++ b/src/murmur/Messages.cpp
@@ -136,6 +136,21 @@ class TemporaryAccessTokenHelper {
}
};
+/// Checks whether the given channel has restrictions affecting the ENTER privilege
+///
+/// @param c A pointer to the Channel that should be checked
+/// @return Whether the provided channel has an ACL denying ENTER
+bool isChannelEnterRestricted(Channel *c) {
+ // A channel is enter restricted if there's an ACL denying enter privileges
+ foreach(ChanACL *acl, c->qlACL) {
+ if (acl->pDeny & ChanACL::Enter) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg) {
if ((msg.tokens_size() > 0) || (uSource->sState == ServerUser::Authenticated)) {
QStringList qsl;
@@ -146,6 +161,16 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg
uSource->qslAccessTokens = qsl;
}
clearACLCache(uSource);
+
+ // Send back updated enter states of all channels
+ MumbleProto::ChannelState mpcs;
+ foreach(Channel *chan, qhChannels) {
+ mpcs.set_channel_id(chan->iId);
+ mpcs.set_can_enter(ChanACL::hasPermission(uSource, chan, ChanACL::Enter, &acCache));
+ // As no ACLs have changed, we don't need to update the is_access_restricted message field
+
+ sendMessage(uSource, mpcs);
+ }
}
MSG_SETUP(ServerUser::Connected);
@@ -322,6 +347,10 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg
mpcs.set_max_users(c->uiMaxUsers);
+ // Include info about enter restrictions of this channel
+ mpcs.set_is_enter_restricted(isChannelEnterRestricted(c));
+ mpcs.set_can_enter(ChanACL::hasPermission(uSource, c, ChanACL::Enter, &acCache));
+
sendMessage(uSource, mpcs);
foreach(c, c->qlChannels)
@@ -1490,6 +1519,16 @@ void Server::msgACL(ServerUser *uSource, MumbleProto::ACL &msg) {
updateChannel(c);
log(uSource, QString("Updated ACL in channel %1").arg(*c));
+
+ // Send refreshed enter states of this channel to all clients
+ MumbleProto::ChannelState mpcs;
+ mpcs.set_channel_id(c->iId);
+ foreach(ServerUser *user, qhUsers) {
+ mpcs.set_is_enter_restricted(isChannelEnterRestricted(c));
+ mpcs.set_can_enter(ChanACL::hasPermission(user, c, ChanACL::Enter, &acCache));
+
+ sendMessage(uSource, mpcs);
+ }
}
}