From 6ed3b27af4a686a5dbad5a9a2b49b5a1f700dbca Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Fri, 4 Nov 2011 00:35:35 -0200 Subject: [PATCH 1/5] Clear text colors before appending timestamps to buffer lines --- src/User.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/User.cpp b/src/User.cpp index aaea3e27..c196aaf0 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -524,7 +524,11 @@ CString CUser::AddTimestamp(time_t tm, const CString& sStr) const { sRet += " " + sStr; } if (m_bAppendTimestamp) { - sRet += " "; + // From http://www.mirc.com/colors.html + // The Control+O key combination in mIRC inserts ascii character 15, + // which turns off all previous attributes, including color, bold, underline, and italics. + sRet += "\x0F "; + sRet += szTimestamp; } } From e607b1a559fe588810e62a2b279eb0d98545ad32 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 5 Nov 2011 12:17:31 +0100 Subject: [PATCH 2/5] route_replies: Handle raw 482 lahwran reported the following message from *route_replies and also figured out which message we failed to handle, thanks! <*route_replies> This module hit a timeout which is possibly a bug. <*route_replies> To disable this message, do "/msg *route_replies silent yes" <*route_replies> Last request: MODE #somesecretchannel I Signed-off-by: Uli Schlachter --- modules/route_replies.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/route_replies.cpp b/modules/route_replies.cpp index 0b3fd40f..05f18181 100644 --- a/modules/route_replies.cpp +++ b/modules/route_replies.cpp @@ -117,6 +117,8 @@ static const struct { // Since there should never be more than one of these going on, this // should work fine and makes the code simpler. {"MODE", { + // "You're not a channel operator" + {"482", true}, // MODE I {"346", false}, {"347", true}, From aa085ef38daea9be78998ea5105ada0a902888be Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Sat, 5 Nov 2011 16:57:13 +0000 Subject: [PATCH 3/5] Add {Add,Del,List}Network to *admin module --- modules/admin.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/modules/admin.cpp b/modules/admin.cpp index c1954cb4..2514d6bd 100644 --- a/modules/admin.cpp +++ b/modules/admin.cpp @@ -571,6 +571,107 @@ class CAdminMod : public CModule { return; } + void AddNetwork(const CString& sLine) { + CString sUser = sLine.Token(1); + CString sNetwork = sLine.Token(2); + CUser *pUser = m_pUser; + + if (sNetwork.empty()) { + sNetwork = sUser; + } else { + pUser = GetUser(sUser); + if (!pUser) { + return; + } + } + + if (sNetwork.empty()) { + PutModule("Usage: " + sLine.Token(0) + " [user] network"); + return; + } + + if (pUser->FindNetwork(sNetwork)) { + PutModule(pUser->GetUserName() + " already has a network named [" + sNetwork + "]"); + return; + } + + if (pUser->AddNetwork(sNetwork)) { + PutModule("Network added [" + sNetwork + "]"); + } else { + PutModule("Network could not be added."); + } + } + + void DelNetwork(const CString& sLine) { + CString sUser = sLine.Token(1); + CString sNetwork = sLine.Token(2); + CUser *pUser = m_pUser; + + if (sNetwork.empty()) { + sNetwork = sUser; + } else { + pUser = GetUser(sUser); + if (!pUser) { + return; + } + } + + if (sNetwork.empty()) { + PutModule("Usage: " + sLine.Token(0) + " [user] network"); + return; + } + + if (!(pUser->FindNetwork(sNetwork))) { + PutModule(pUser->GetUserName() + " does not have a network named [" + sNetwork + "]"); + return; + } + + if (pUser->DeleteNetwork(sNetwork)) { + PutModule("Network deleted [" + sNetwork + "]"); + } else { + PutModule("Network could not be deleted."); + } + } + + void ListNetworks(const CString& sLine) { + CString sUser = sLine.Token(1); + CUser *pUser = m_pUser; + + if (!sUser.empty()) { + pUser = GetUser(sUser); + if (!pUser) { + return; + } + } + + const vector& vNetworks = pUser->GetNetworks(); + + CTable Table; + Table.AddColumn("Network"); + Table.AddColumn("OnIRC"); + Table.AddColumn("IRC Server"); + Table.AddColumn("IRC User"); + Table.AddColumn("Channels"); + + for (unsigned int a = 0; a < vNetworks.size(); a++) { + CIRCNetwork* pNetwork = vNetworks[a]; + Table.AddRow(); + Table.SetCell("Network", pNetwork->GetName()); + if (pNetwork->IsIRCConnected()) { + Table.SetCell("OnIRC", "Yes"); + Table.SetCell("IRC Server", pNetwork->GetIRCServer()); + Table.SetCell("IRC User", pNetwork->GetIRCNick().GetNickMask()); + Table.SetCell("Channels", CString(pNetwork->GetChans().size())); + } else { + Table.SetCell("OnIRC", "No"); + } + } + + if (PutModule(Table) == 0) { + PutModule("No networks"); + } + } + void AddServer(const CString& sLine) { CString sUsername = sLine.Token(1); CString sNetwork = sLine.Token(2); @@ -878,6 +979,14 @@ public: "username ctcp [reply]", "Configure a new CTCP reply"); AddCommand("DelCTCP", static_cast(&CAdminMod::DelCTCP), "username ctcp", "Remove a CTCP reply"); + + // Network commands + AddCommand("AddNetwork", static_cast(&CAdminMod::AddNetwork), + "[username] network", "Add a network for a user"); + AddCommand("DelNetwork", static_cast(&CAdminMod::DelNetwork), + "[username] network", "Delete a network for a user"); + AddCommand("ListNetworks", static_cast(&CAdminMod::ListNetworks), + "[username]", "List all networks for a user"); } virtual ~CAdminMod() {} From 94ffcbed591be8aa128a8ea0612211ed6bef9118 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Mon, 7 Nov 2011 16:28:12 +0000 Subject: [PATCH 4/5] Don't forward a 670 to a client This might result in the client switching to SSL if it supports it. Breaking the current connection --- src/IRCSock.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 93cdbacd..e8db0976 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -375,13 +375,14 @@ void CIRCSock::ReadLine(const CString& sData) { } case 670: // :hydra.sector5d.org 670 kylef :STARTTLS successful, go ahead with TLS handshake - // 670 is a responce to `STARTTLS` telling the client to switch to TLS + // 670 is a response to `STARTTLS` telling the client to switch to TLS if (!GetSSL()) { StartTLS(); + m_pNetwork->PutStatus("Switched to SSL (STARTTLS)"); } - break; + return; } } else { CNick Nick(sLine.Token(0).TrimPrefix_n()); From 74738a20b7b99682711b4b3207af086cadcc4f40 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Mon, 7 Nov 2011 16:37:53 +0000 Subject: [PATCH 5/5] Fix a NULL pointer issue on CChan::SaveBuff I also cleaned up a little and loop over vClients once instead of twice --- src/Chan.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Chan.cpp b/src/Chan.cpp index edd2cd1d..e2754e80 100644 --- a/src/Chan.cpp +++ b/src/Chan.cpp @@ -527,8 +527,8 @@ void CChan::SendBuffer(CClient* pClient) { if (!m_Buffer.IsEmpty()) { const vector & vClients = m_pNetwork->GetClients(); for (size_t uClient = 0; uClient < vClients.size(); ++uClient) { + CClient * pUseClient = (pClient ? pClient : vClients[uClient]); - CClient * pUseClient = ( pClient ? pClient : vClients[uClient] ); bool bSkipStatusMsg = false; NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); @@ -538,26 +538,13 @@ void CChan::SendBuffer(CClient* pClient) { unsigned int uSize = m_Buffer.Size(); for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) { - CString sLine = m_Buffer.GetLine(uIdx, *pClient); + CString sLine = m_Buffer.GetLine(uIdx, *pUseClient); NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, continue); m_pNetwork->PutUser(sLine, pUseClient); } - if (pClient) - break; - - } - - if (!KeepBuffer()) { - ClearBuffer(); - } - - for ( size_t uClient = 0; uClient < vClients.size(); ++uClient) { - - CClient * pUseClient = ( pClient ? pClient : vClients[uClient] ); - bool bSkipStatusMsg = false; + bSkipStatusMsg = false; NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); - if (!bSkipStatusMsg) { m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pUseClient); } @@ -566,6 +553,9 @@ void CChan::SendBuffer(CClient* pClient) { break; } + if (!KeepBuffer()) { + ClearBuffer(); + } } } }