mirror of
https://github.com/znc/znc.git
synced 2026-07-06 01:41:12 +02:00
Add traffic tracking support to CSocket
Now every module that uses CSocket automatically gets its generated traffic counted. Those which use Csock directly should be shot and burried anyway ;) This adds CModule::IsGlobal(). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1283 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+12
@@ -114,7 +114,17 @@ CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPor
|
||||
}
|
||||
|
||||
CSocket::~CSocket() {
|
||||
CUser *pUser = m_pModule->GetUser();
|
||||
|
||||
m_pModule->UnlinkSocket(this);
|
||||
|
||||
if (!m_pModule->IsGlobal() && pUser) {
|
||||
pUser->AddBytesWritten(GetBytesWritten());
|
||||
pUser->AddBytesRead(GetBytesRead());
|
||||
} else {
|
||||
CZNC::Get().AddBytesWritten(GetBytesWritten());
|
||||
CZNC::Get().AddBytesRead(GetBytesRead());
|
||||
}
|
||||
}
|
||||
|
||||
void CSocket::ReachedMaxBuffer() {
|
||||
@@ -181,6 +191,7 @@ CModule* CSocket::GetModule() const { return m_pModule; }
|
||||
|
||||
CModule::CModule(void* pDLL, CUser* pUser, const CString& sModName, const CString& sDataDir) {
|
||||
m_bFake = false;
|
||||
m_bGlobal = false;
|
||||
m_pDLL = pDLL;
|
||||
m_pManager = &(CZNC::Get().GetManager());;
|
||||
m_pUser = pUser;
|
||||
@@ -779,6 +790,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
|
||||
}
|
||||
|
||||
pModule->SetDescription(GetDesc());
|
||||
pModule->SetGlobal(bIsGlobal);
|
||||
push_back(pModule);
|
||||
|
||||
bool bLoaded;
|
||||
|
||||
@@ -329,12 +329,14 @@ public:
|
||||
|
||||
// Setters
|
||||
void SetFake(bool b) { m_bFake = b; }
|
||||
void SetGlobal(bool b) { m_bGlobal = b; }
|
||||
void SetDescription(const CString& s) { m_sDescription = s; }
|
||||
void SetArgs(const CString& s) { m_sArgs = s; }
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
bool IsFake() const { return m_bFake; }
|
||||
bool IsGlobal() const { return m_bGlobal; }
|
||||
const CString& GetDescription() const { return m_sDescription; }
|
||||
const CString& GetArgs() const { return m_sArgs; }
|
||||
CUser* GetUser() { return m_pUser; }
|
||||
@@ -344,6 +346,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool m_bFake;
|
||||
bool m_bGlobal;
|
||||
CString m_sDescription;
|
||||
vector<CTimer*> m_vTimers;
|
||||
vector<CSocket*> m_vSockets;
|
||||
|
||||
@@ -58,8 +58,6 @@ public:
|
||||
EnableReadLine();
|
||||
}
|
||||
|
||||
~CSChatSock();
|
||||
|
||||
virtual Csock *GetSockObj(const CS_STRING & sHostname, u_short iPort)
|
||||
{
|
||||
CSChatSock *p = new CSChatSock(sHostname, iPort);
|
||||
@@ -442,12 +440,6 @@ private:
|
||||
|
||||
//////////////////// methods ////////////////
|
||||
|
||||
CSChatSock::~CSChatSock()
|
||||
{
|
||||
m_pModule->GetUser()->AddBytesRead(GetBytesRead());
|
||||
m_pModule->GetUser()->AddBytesWritten(GetBytesWritten());
|
||||
}
|
||||
|
||||
void CSChatSock::ReadLine(const CS_STRING & sLine)
|
||||
{
|
||||
if (m_pModule) {
|
||||
|
||||
@@ -322,9 +322,6 @@ CWebAdminSock::~CWebAdminSock() {
|
||||
CWebAdminAuth* pAuth = (CWebAdminAuth*) &(*m_spAuth);
|
||||
pAuth->SetWebAdminSock(NULL);
|
||||
}
|
||||
|
||||
CZNC::Get().AddBytesRead(GetBytesRead());
|
||||
CZNC::Get().AddBytesWritten(GetBytesWritten());
|
||||
}
|
||||
|
||||
bool CWebAdminSock::OnPageRequest(const CString& sURI, CString& sPageRet) {
|
||||
|
||||
Reference in New Issue
Block a user