- reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
- reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
- reply["CoreDate"] = Quassel::buildInfo().buildDate;
- reply["CoreStartTime"] = startTime(); // v10 clients don't necessarily parse this, see below
-
- // FIXME: newer clients no longer use the hardcoded CoreInfo (for now), since it gets the
- // time zone wrong. With the next protocol bump (10 -> 11), we should remove this
- // or make it properly configurable.
-
- int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
- int updays = uptime / 86400; uptime %= 86400;
- int uphours = uptime / 3600; uptime %= 3600;
- int upmins = uptime / 60;
- reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
- "Built: %2<br>"
- "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
- .arg(Quassel::buildInfo().buildDate)
- .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
+ QVariantMap msg = data.toMap();
+ if (!msg.contains("MsgType")) {
+ // Client is way too old, does not even use the current init format
+ qWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
+ connection->close();
+ return;
+ }
+
+ // OK, so we have at least an init message format we can understand
+ if (msg["MsgType"] == "ClientInit") {
+ QVariantMap reply;
+
+ // Just version information -- check it!
+ uint ver = msg["ProtocolVersion"].toUInt();
+ if (ver < Quassel::buildInfo().coreNeedsProtocol) {
+ reply["MsgType"] = "ClientInitReject";
+ reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
+ "This core needs at least client/core protocol version %1.<br>"
+ "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
+ connection->writeSocketData(reply);
+ qWarning() << qPrintable(tr("Client")) << connection->description() << qPrintable(tr("too old, rejecting."));
+ connection->close();
+ return;
+ }
+
+ reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
+ reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
+ reply["CoreDate"] = Quassel::buildInfo().buildDate;
+ reply["CoreStartTime"] = startTime(); // v10 clients don't necessarily parse this, see below
+
+ // FIXME: newer clients no longer use the hardcoded CoreInfo (for now), since it gets the
+ // time zone wrong. With the next protocol bump (10 -> 11), we should remove this
+ // or make it properly configurable.
+
+ int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
+ int updays = uptime / 86400; uptime %= 86400;
+ int uphours = uptime / 3600; uptime %= 3600;
+ int upmins = uptime / 60;
+ reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
+ "Built: %2<br>"
+ "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
+ .arg(Quassel::buildInfo().buildDate)
+ .arg(updays).arg(uphours, 2, 10, QChar('0')).arg(upmins, 2, 10, QChar('0')).arg(startTime().toString(Qt::TextDate));
+
+ reply["CoreFeatures"] = (int)Quassel::features();