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:
-rw-r--r--src/Net.cpp17
-rw-r--r--src/Net.h3
-rw-r--r--src/murmur/Messages.cpp14
3 files changed, 33 insertions, 1 deletions
diff --git a/src/Net.cpp b/src/Net.cpp
index a3d737e91..b9a18819b 100644
--- a/src/Net.cpp
+++ b/src/Net.cpp
@@ -162,3 +162,20 @@ bool Ban::operator ==(const Ban &other) const {
bool Ban::isValid() const {
return haAddress.isValid() && (iMask >= 8) && (iMask <= 128);
}
+
+QString Ban::toString() const {
+ return QString(QLatin1String("Hash: \"%1\", Host: \"%2\", Mask: \"%3\", Username: \"%4\", Reason: \"%5\", BanStart: \"%6\", BanEnd: \"%7\" %8")).arg(
+ qsHash,
+ haAddress.toString(),
+ haAddress.isV6() ? QString::number(iMask) : QString::number(iMask-96),
+ qsUsername,
+ qsReason,
+ qdtStart.toLocalTime().toString("yyyy-MM-dd hh:mm:ss"),
+ qdtStart.toLocalTime().addSecs(iDuration).toString("yyyy-MM-dd hh:mm:ss"),
+ iDuration == 0 ? "(permanent)" : "(temporary)"
+ );
+}
+
+quint32 qHash(const Ban &b) {
+ return qHash(b.qsHash) ^ qHash(b.haAddress) ^ qHash(b.qsUsername) ^ qHash(b.iMask);
+}
diff --git a/src/Net.h b/src/Net.h
index 64232db99..b4d5aab0d 100644
--- a/src/Net.h
+++ b/src/Net.h
@@ -61,8 +61,11 @@ struct Ban {
bool isValid() const;
bool operator < (const Ban &) const;
bool operator == (const Ban &) const;
+ QString toString() const;
};
+quint32 qHash(const Ban &);
+
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
#define SWAP64(x) (x)
#else
diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp
index b3670bb09..e4beff64c 100644
--- a/src/murmur/Messages.cpp
+++ b/src/murmur/Messages.cpp
@@ -400,6 +400,7 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg
void Server::msgBanList(ServerUser *uSource, MumbleProto::BanList &msg) {
MSG_SETUP(ServerUser::Authenticated);
+ QSet<Ban> previousBans, newBans;
if (! hasPermission(uSource, qhChannels.value(0), ChanACL::Ban)) {
PERM_DENIED(uSource, qhChannels.value(0), ChanACL::Ban);
return;
@@ -419,6 +420,7 @@ void Server::msgBanList(ServerUser *uSource, MumbleProto::BanList &msg) {
}
sendMessage(uSource, msg);
} else {
+ previousBans = qlBans.toSet();
qlBans.clear();
for (int i=0;i < msg.bans_size(); ++i) {
const MumbleProto::BanList_BanEntry &be = msg.bans(i);
@@ -436,8 +438,18 @@ void Server::msgBanList(ServerUser *uSource, MumbleProto::BanList &msg) {
b.qdtStart = QDateTime::currentDateTime().toUTC();
}
b.iDuration = be.duration();
- if (b.isValid())
+ if (b.isValid()) {
qlBans << b;
+ }
+ }
+ newBans = qlBans.toSet();
+ QSet<Ban> removed = previousBans - newBans;
+ QSet<Ban> added = newBans - previousBans;
+ foreach(const Ban &b, removed) {
+ log(uSource, QString("Removed ban: %1").arg(b.toString()));
+ }
+ foreach(const Ban &b, added) {
+ log(uSource, QString("New ban: %1").arg(b.toString()));
}
saveBans();
log(uSource, "Updated banlist");