From 57fe412a35e66bf0824a09b77ceb87c54d35519d Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 18 Feb 2010 12:13:22 +0000 Subject: [PATCH] Don't let a ZNC user connect to itself If you let your ZNC user to itself, you generate a loop. ZNC will send the "Welcome to ZNC message" to the connected client, which is itself. So it receives that messages and sends it to its client again, which... We detect this situation because we see raw 001 two times, which should never happen on a normal IRC server. To get even less than zero ;) false positive, we only disconnect if the second raw 001 is from a server called "irc.znc.in". git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1760 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/IRCSock.cpp b/IRCSock.cpp index 89b23d84..5fcb99c6 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -106,6 +106,13 @@ void CIRCSock::ReadLine(const CString& sData) { switch (uRaw) { case 1: {// :irc.server.com 001 nick :Welcome to the Internet Relay Network nick + if (m_bAuthed && sServer == "irc.znc.in") { + // m_bAuthed == true => we already received another 001 => we might be in a traffic loop + m_pUser->PutStatus("ZNC seems to be connected to itself, disconnecting..."); + Quit(); + return; + } + m_pUser->SetIRCServer(sServer); SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course PutIRC("WHO " + sNick);