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
This commit is contained in:
psychon
2010-02-18 12:13:22 +00:00
parent b5bd0f1c9b
commit 57fe412a35
+7
View File
@@ -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);