From bc40713b61d00ba88fe910377f601c3fa356baad Mon Sep 17 00:00:00 2001 From: psychon Date: Fri, 25 Jun 2010 15:51:16 +0000 Subject: [PATCH] Rethink PING/PONG handling All PINGs are replied by ZNC, only PINGs from the client are forwarded. All PONGs are blocked. This should solve all issues with annoying PONGs showing up in clients. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2043 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 15 +++++---------- IRCSock.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Client.cpp b/Client.cpp index 02a0b096..4c27ed7b 100644 --- a/Client.cpp +++ b/Client.cpp @@ -180,17 +180,12 @@ void CClient::ReadLine(const CString& sData) { PutStatusNotice("Detached from [" + sChan + "]"); return; } else if (sCommand.Equals("PING")) { - CString sTarget = sLine.Token(1); - - // If the client meant to ping us or we can be sure the server - // won't answer the ping (=no server connected) -> PONG back. - // else: It's the server's job to send a PONG. - if (sTarget.Equals("irc.znc.in") || !GetIRCSock()) { - PutClient("PONG " + sLine.substr(5)); - return; - } + // All PONGs are generated by znc. We will still forward this to + // the ircd, but all PONGs from irc will be blocked. + PutClient(":irc.znc.in PONG irc.znc.in " + sLine.substr(5)); } else if (sCommand.Equals("PONG")) { - return; // Block pong replies, we already responded to the pings + // Block PONGs, we already responded to the pings + return; } else if (sCommand.Equals("JOIN")) { CString sChans = sLine.Token(1); CString sKey = sLine.Token(2); diff --git a/IRCSock.cpp b/IRCSock.cpp index a3421804..07892dcb 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -79,11 +79,12 @@ void CIRCSock::ReadLine(const CString& sData) { MODULECALL(OnRaw(sLine), m_pUser, NULL, return); if (sLine.Equals("PING ", false, 5)) { + // Generate a reply and don't forward this to any user, + // we don't want any PING forwarded PutIRC("PONG " + sLine.substr(5)); - m_pUser->PutUser(sLine); return; - } else if (sLine.Token(1).Equals("PONG") && sLine.Token(3).Equals(":ZNC")) { - // We asked for this so don't forward the reply to clients. + } else if (sLine.Token(1).Equals("PONG")) { + // Block PONGs, we already responded to the pings return; } else if (sLine.Equals("ERROR ", false, 6)) { //ERROR :Closing Link: nick[24.24.24.24] (Excess Flood)