+ else {
+ // Two parameters received, pick the second
+ // :localhost PONG localhost :02:43:49.565
+ timestamp = e->params().at(1);
+ }
+
+ // The server is supposed to send back what we passed as parameter, and we send a timestamp.
+ // However, using quote and whatnot, one can send arbitrary pings, and IRC servers may decide to
+ // ignore our requests entirely and send whatever they want, so we have to do some sanity
+ // checks.
+ //
+ // 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();