X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=8fa70157a100649a210d21a37a235b9bab3bc637;hb=4cf9c160f318a71400b032ea6d3031b9e6628a56;hp=c4c01e5a2531eb1d83b021b682429408fb1b42d6;hpb=425364f5f68a37582ddfa0494f4305f98f761e23;p=quassel.git diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index c4c01e5a..8fa70157 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -28,7 +28,7 @@ #include "ctcpevent.h" #include "ircevent.h" #include "ircuser.h" -#include "logger.h" +#include "logmessage.h" #include "messageevent.h" #include "netsplit.h" #include "quassel.h" @@ -661,12 +661,46 @@ void CoreSessionEventProcessor::processIrcEventPong(IrcEvent *e) // Attempt to parse the timestamp QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz"); if (sendTime.isValid()) { + // Mark IRC server as sending valid ping replies + if (!coreNetwork(e)->isPongTimestampValid()) { + coreNetwork(e)->setPongTimestampValid(true); + // Add a message the first time it happens + qDebug().nospace() << "Received PONG with valid timestamp, marking pong replies on " + "network " + << "\"" << qPrintable(e->network()->networkName()) << "\" (ID: " + << qPrintable(QString::number(e->network()->networkId().toInt())) + << ") as usable for latency measurement"; + } + // Remove pending flag + coreNetwork(e)->resetPongReplyPending(); + + // Don't show this in the UI + e->setFlag(EventManager::Silent); + // TODO: To allow for a user-sent /ping (without arguments, so default timestamp is used), + // this could track how many automated PINGs have been sent by the core and subtract one + // each time, only marking the PING as silent if there's pending automated pong replies. + // However, that's a behavior change which warrants further testing. For now, take the + // simpler, previous approach that errs on the side of silencing too much. + // Calculate latency from time difference, divided by 2 to account for round-trip time e->network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2); - } else { - // Just in case it's a wonky server, log a debug message to make this easier to track down - qDebug() << "Received valid PONG with invalid timestamp, parameters are" << e->params(); + } else if (coreNetwork(e)->isPongReplyPending() && !coreNetwork(e)->isPongTimestampValid()) { + // There's an auto-PING reply pending and we've not yet received a PONG reply with a valid + // timestamp. It's possible this server will never respond with a valid timestamp, and thus + // any automated PINGs will result in unwanted spamming of the server buffer. + + // Don't show this in the UI + e->setFlag(EventManager::Silent); + // Remove pending flag + coreNetwork(e)->resetPongReplyPending(); + + // Log a message + qDebug().nospace() << "Received PONG with invalid timestamp from network " + << "\"" << qPrintable(e->network()->networkName()) << "\" (ID: " + << qPrintable(QString::number(e->network()->networkId().toInt())) + << "), silencing, parameters are " << e->params(); } + // else: We're not expecting a PONG reply and timestamp is not valid, assume it's from the user } @@ -1600,6 +1634,9 @@ void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e) void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e) { - e->setReply(QString("Quassel IRC %1 (built on %2) -- https://www.quassel-irc.org") - .arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().commitDate)); + // Deliberately do not translate project name + e->setReply(QString("Quassel IRC %1 (version date %2) -- https://www.quassel-irc.org") + .arg(Quassel::buildInfo().plainVersionString) + .arg(Quassel::buildInfo().commitDate.isEmpty() ? + "unknown" : tryFormatUnixEpoch(Quassel::buildInfo().commitDate))); }