Skip to content
Permalink
Browse files

Fix auto-reconnect behavior when kicked or banned.

This commit fixes a regression in Mumble's auto-reconnect
functionality which made clients auto-reconnect to a server
even after being kicked or banned. Historically, Mumble has
not worked this way.

The new auto-reconnect behavior showed itself due to a bug fix in Qt
(Qt 4 commit: 488cb66, Qt 5 commit: e145b67).

The Qt change fixes QSslSocket such that a remote close (at the TLS
level) properly emits a QAbstractSocket::RemoteHostClosedError error.

Prior to this change, Mumble would simply treat a TLS-level remote
close as a client-initiated disconnect, and therefore not attempt to
auto-reconnect.

With this new and correct QSslSocket behavior in place, Mumble's
previous handling of auto-reconnect is insufficient. Since a kick/ban
now results in a TLS-level remote close, the client has no way to
determine whether a given remote close error is due to a kick/ban,
or due to the server shutting down. Note that a server shutdown has
always, even before this change, emitted a
QAbstractSocket::RemoteHostClosedError error. This is seemingly because
a server shutdown closes the underlying TCP socket instead of sending
a TLS-level close notification.

To fix the situation, this commit adds a flag to MainWindow that
signals whether the client should try to attempt an automatic
reconnect if it gets disconnected. When the client is kicked or banned,
this flag unset. This restores Mumble's previous auto-reconnect behavior
when kicked or banned from a server.

Fixes #1189
  • Loading branch information...
bontibon authored and mkrautz committed Mar 30, 2014
1 parent 2d2509f commit 125638665d4ccb02df40f743e3d6b5ad11a711f8
Showing with 7 additions and 1 deletion.
  1. +5 −1 src/mumble/MainWindow.cpp
  2. +1 −0 src/mumble/MainWindow.h
  3. +1 −0 src/mumble/Messages.cpp
@@ -718,6 +718,7 @@ void MainWindow::openUrl(const QUrl &url) {

g.s.qsLastServer = name;
rtLast = MumbleProto::Reject_RejectType_None;
bRetryServer = true;
qaServerDisconnect->setEnabled(true);
g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(host, Log::Server)));
g.sh->setConnectionInfo(host, port, user, pw);
@@ -915,6 +916,7 @@ void MainWindow::on_qaServerConnect_triggered(bool autoconnect) {
recreateServerHandler();
qsDesiredChannel = QString();
rtLast = MumbleProto::Reject_RejectType_None;
bRetryServer = true;
qaServerDisconnect->setEnabled(true);
g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(cd->qsServer, Log::Server)));
g.sh->setConnectionInfo(cd->qsServer, cd->usPort, cd->qsUsername, cd->qsPassword);
@@ -2611,7 +2613,9 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
on_Reconnect_timeout();
} else if (!matched && g.s.bReconnect && ! reason.isEmpty()) {
qaServerDisconnect->setEnabled(true);
qtReconnect->start();
if (bRetryServer) {
qtReconnect->start();
}
}
}
qstiIcon->setToolTip(tr("Mumble -- %1").arg(QLatin1String(MUMBLE_RELEASE)));
@@ -110,6 +110,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
VoiceRecorderDialog *voiceRecorderDialog;

MumbleProto::Reject_RejectType rtLast;
bool bRetryServer;
QString qsDesiredChannel;

bool bSuppressAskOnQuit;
@@ -510,6 +510,7 @@ void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) {
QString reason = Qt::escape(u8(msg.reason()));

if (pDst == pSelf) {
bRetryServer = false;
if (msg.ban())
g.l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason));
else

0 comments on commit 1256386

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