mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Merge pull request #1020 from jpnurmi/traffic
Calculate per-network traffic (#963)
This commit is contained in:
+32
@@ -1767,6 +1767,38 @@ CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair &Users,
|
||||
return ret;
|
||||
}
|
||||
|
||||
CZNC::TrafficStatsMap CZNC::GetNetworkTrafficStats(const CString& sUsername, TrafficStatsPair& Total) {
|
||||
TrafficStatsMap Networks;
|
||||
|
||||
CUser* pUser = FindUser(sUsername);
|
||||
if (pUser) {
|
||||
for (const CIRCNetwork* pNetwork : pUser->GetNetworks()) {
|
||||
Networks[pNetwork->GetName()].first = pNetwork->BytesRead();
|
||||
Networks[pNetwork->GetName()].second = pNetwork->BytesWritten();
|
||||
Total.first += pNetwork->BytesRead();
|
||||
Total.second += pNetwork->BytesWritten();
|
||||
}
|
||||
|
||||
for (Csock* pSock : m_Manager) {
|
||||
CIRCNetwork *pNetwork = nullptr;
|
||||
if (pSock->GetSockName().StartsWith("IRC::")) {
|
||||
pNetwork = ((CIRCSock *) pSock)->GetNetwork();
|
||||
} else if (pSock->GetSockName().StartsWith("USR::")) {
|
||||
pNetwork = ((CClient *) pSock)->GetNetwork();
|
||||
}
|
||||
|
||||
if (pNetwork && pNetwork->GetUser() == pUser) {
|
||||
Networks[pNetwork->GetName()].first = pSock->GetBytesRead();
|
||||
Networks[pNetwork->GetName()].second = pSock->GetBytesWritten();
|
||||
Total.first += pSock->GetBytesRead();
|
||||
Total.second += pSock->GetBytesWritten();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Networks;
|
||||
}
|
||||
|
||||
void CZNC::AuthUser(std::shared_ptr<CAuthBase> AuthClass) {
|
||||
// TODO unless the auth module calls it, CUser::IsHostAllowed() is not honoured
|
||||
bool bReturn = false;
|
||||
|
||||
Reference in New Issue
Block a user