diff --git a/include/znc/ZNCDebug.h b/include/znc/ZNCDebug.h index 8a82027b..d81fe93c 100644 --- a/include/znc/ZNCDebug.h +++ b/include/znc/ZNCDebug.h @@ -47,6 +47,8 @@ class CDebug { static void SetDebug(bool b) { debug = b; } static bool Debug() { return debug; } + static CString Filter(const CString& sUnfilteredLine); + protected: static bool stdoutIsTTY; static bool debug; diff --git a/src/Client.cpp b/src/Client.cpp index 11626bf9..745a4173 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using std::set; using std::map; @@ -105,7 +106,8 @@ void CClient::ReadLine(const CString& sData) { sLine.TrimRight("\n\r"); - DEBUG("(" << GetFullName() << ") CLI -> ZNC [" << sLine << "]"); + DEBUG("(" << GetFullName() << ") CLI -> ZNC [" + << CDebug::Filter(sLine) << "]"); MCString mssTags; if (sLine.StartsWith("@")) { @@ -586,7 +588,8 @@ bool CClient::PutClient(const CMessage& Message) { &bReturn); if (bReturn) return false; - DEBUG("(" << GetFullName() << ") ZNC -> CLI [" << sCopy << "]"); + DEBUG("(" << GetFullName() << ") ZNC -> CLI [" + << CDebug::Filter(sCopy) << "]"); Write(sCopy + "\r\n"); return true; } diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index a0c5a07f..09cfbb9f 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include using std::set; @@ -1128,8 +1129,8 @@ void CIRCSock::PutIRC(const CString& sLine) { // TrySend()!) if (m_bFloodProtection && m_iSendsAllowed <= 0) { DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" - << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine - << "] (queued)"); + << m_pNetwork->GetName() << ") ZNC -> IRC [" + << CDebug::Filter(sLine) << "] (queued)"); } m_vsSendQueue.push_back(sLine); TrySend(); @@ -1140,8 +1141,8 @@ void CIRCSock::PutIRCQuick(const CString& sLine) { // TrySend()!) if (m_bFloodProtection && m_iSendsAllowed <= 0) { DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" - << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine - << "] (queued to front)"); + << m_pNetwork->GetName() << ") ZNC -> IRC [" + << CDebug::Filter(sLine) << "] (queued to front)"); } m_vsSendQueue.push_front(sLine); TrySend(); @@ -1164,8 +1165,8 @@ void CIRCSock::TrySend() { IRCSOCKMODULECALL(OnSendToIRC(sCopy), &bSkip); if (!bSkip) { DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" - << m_pNetwork->GetName() << ") ZNC -> IRC [" << sCopy - << "]"); + << m_pNetwork->GetName() << ") ZNC -> IRC [" + << CDebug::Filter(sCopy) << "]"); Write(sCopy + "\r\n"); } } diff --git a/src/ZNCDebug.cpp b/src/ZNCDebug.cpp index 2b883eff..775c1f31 100644 --- a/src/ZNCDebug.cpp +++ b/src/ZNCDebug.cpp @@ -29,6 +29,22 @@ bool CDebug::debug = false; #endif +CString CDebug::Filter(const CString& sUnfilteredLine) { + CString sFilteredLine = sUnfilteredLine; + + // If the line is a PASS command to authenticate to a server / znc + if (sUnfilteredLine.StartsWith("PASS ")) { + VCString vsSafeCopy; + sUnfilteredLine.Split(":", vsSafeCopy); + + if (vsSafeCopy.size() > 1) { + sFilteredLine = vsSafeCopy[0] + ":"; + } + } + + return sFilteredLine; +} + CDebugStream::~CDebugStream() { timeval tTime = CUtils::GetTime(); time_t tSec = (time_t)tTime.tv_sec; // some systems (e.g. openbsd) define