mirror of
https://github.com/znc/znc.git
synced 2026-07-05 17:31:06 +02:00
Resolve #967: separate chan & query buffer size settings
This commit is contained in:
+8
-1
@@ -127,7 +127,10 @@ public:
|
||||
void SetQuitMsg(const CString& s);
|
||||
bool AddCTCPReply(const CString& sCTCP, const CString& sReply);
|
||||
bool DelCTCPReply(const CString& sCTCP);
|
||||
/** @deprecated Use SetChanBufferSize() or SetQueryBufferSize() instead. */
|
||||
bool SetBufferCount(unsigned int u, bool bForce = false);
|
||||
bool SetChanBufferSize(unsigned int u, bool bForce = false);
|
||||
bool SetQueryBufferSize(unsigned int u, bool bForce = false);
|
||||
void SetAutoClearChanBuffer(bool b);
|
||||
void SetAutoClearQueryBuffer(bool b);
|
||||
|
||||
@@ -174,7 +177,10 @@ public:
|
||||
|
||||
CString GetQuitMsg() const;
|
||||
const MCString& GetCTCPReplies() const;
|
||||
/** @deprecated Use GetChanBufferSize() or GetQueryBufferSize() instead. */
|
||||
unsigned int GetBufferCount() const;
|
||||
unsigned int GetChanBufferSize() const;
|
||||
unsigned int GetQueryBufferSize() const;
|
||||
bool AutoClearChanBuffer() const;
|
||||
bool AutoClearQueryBuffer() const;
|
||||
bool IsBeingDeleted() const { return m_bBeingDeleted; }
|
||||
@@ -228,7 +234,8 @@ protected:
|
||||
std::vector<CIRCNetwork*> m_vIRCNetworks;
|
||||
std::vector<CClient*> m_vClients;
|
||||
std::set<CString> m_ssAllowedHosts;
|
||||
unsigned int m_uBufferCount;
|
||||
unsigned int m_uChanBufferSize;
|
||||
unsigned int m_uQueryBufferSize;
|
||||
unsigned long long m_uBytesRead;
|
||||
unsigned long long m_uBytesWritten;
|
||||
unsigned int m_uMaxJoinTries;
|
||||
|
||||
@@ -85,7 +85,8 @@ class CAdminMod : public CModule {
|
||||
{"DenySetBindHost", boolean},
|
||||
{"DefaultChanModes", str},
|
||||
{"QuitMsg", str},
|
||||
{"BufferCount", integer},
|
||||
{"ChanBufferSize", integer},
|
||||
{"QueryBufferSize", integer},
|
||||
{"AutoClearChanBuffer", boolean},
|
||||
{"AutoClearQueryBuffer",boolean},
|
||||
{"Password", str},
|
||||
@@ -212,6 +213,10 @@ class CAdminMod : public CModule {
|
||||
PutModule("QuitMsg = " + pUser->GetQuitMsg());
|
||||
else if (sVar == "buffercount")
|
||||
PutModule("BufferCount = " + CString(pUser->GetBufferCount()));
|
||||
else if (sVar == "chanbuffersize")
|
||||
PutModule("ChanBufferSize = " + CString(pUser->GetChanBufferSize()));
|
||||
else if (sVar == "querybuffersize")
|
||||
PutModule("QueryBufferSize = " + CString(pUser->GetQueryBufferSize()));
|
||||
else if (sVar == "keepbuffer")
|
||||
PutModule("KeepBuffer = " + CString(!pUser->AutoClearChanBuffer())); // XXX compatibility crap, added in 0.207
|
||||
else if (sVar == "autoclearchanbuffer")
|
||||
@@ -340,11 +345,21 @@ class CAdminMod : public CModule {
|
||||
pUser->SetQuitMsg(sValue);
|
||||
PutModule("QuitMsg = " + sValue);
|
||||
}
|
||||
else if (sVar == "buffercount") {
|
||||
else if (sVar == "chanbuffersize" || sVar == "buffercount") {
|
||||
unsigned int i = sValue.ToUInt();
|
||||
// Admins don't have to honour the buffer limit
|
||||
if (pUser->SetBufferCount(i, GetUser()->IsAdmin())) {
|
||||
PutModule("BufferCount = " + sValue);
|
||||
if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) {
|
||||
PutModule("ChanBufferSize = " + sValue);
|
||||
} else {
|
||||
PutModule("Setting failed, limit is " +
|
||||
CString(CZNC::Get().GetMaxBufferSize()));
|
||||
}
|
||||
}
|
||||
else if (sVar == "querybuffersize") {
|
||||
unsigned int i = sValue.ToUInt();
|
||||
// Admins don't have to honour the buffer limit
|
||||
if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) {
|
||||
PutModule("QueryBufferSize = " + sValue);
|
||||
} else {
|
||||
PutModule("Setting failed, limit is " +
|
||||
CString(CZNC::Get().GetMaxBufferSize()));
|
||||
|
||||
@@ -228,19 +228,38 @@
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h3>Default Settings</h3>
|
||||
<h3>Channels</h3>
|
||||
<div class="sectionbg">
|
||||
<div class="sectionbody">
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">Channel Modes:</div>
|
||||
<div class="inputlabel">Default Modes:</div>
|
||||
<input type="text" name="chanmodes" value="<? VAR DefaultChanModes ?>" maxlength="32"
|
||||
title="These are the default modes ZNC will set when you join an empty channel." />
|
||||
<br /><span class="info">Empty = use standard value</span>
|
||||
</div>
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">Buffer Size:</div>
|
||||
<input type="number" name="bufsize" value="<? VAR BufferCount ?>" min="0"
|
||||
title="This is the amount of lines that the playback buffer will store before dropping off the oldest line. The buffers are stored in the memory by default." />
|
||||
<input type="number" name="chanbufsize" value="<? VAR ChanBufferSize ?>" min="0"
|
||||
title="This is the amount of lines that the playback buffer will store for channels before dropping off the oldest line. The buffers are stored in the memory by default." />
|
||||
<br /><span class="info">Empty = use standard value</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h3>Queries</h3>
|
||||
<div class="sectionbg">
|
||||
<div class="sectionbody">
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">Max Buffers:</div>
|
||||
<input type="number" name="maxquerybuffers" value="<? VAR MaxQueryBuffers ?>" class="third" min="0"
|
||||
title="Maximum number of query buffers. 0 is unlimited."/>
|
||||
</div>
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">Buffer Size:</div>
|
||||
<input type="number" name="querybufsize" value="<? VAR QueryBufferSize ?>" min="0"
|
||||
title="This is the amount of lines that the playback buffer will store for queries before dropping off the oldest line. The buffers are stored in the memory by default." />
|
||||
<br /><span class="info">Empty = use standard value</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -304,11 +323,6 @@
|
||||
<input type="number" name="maxnetworks" value="<? VAR MaxNetworks ?>" class="third" min="0"
|
||||
title="Maximum number of IRC networks allowed for this user." <? IF !ImAdmin ?>disabled="disabled"<? ENDIF ?> />
|
||||
</div>
|
||||
<div class="subsection">
|
||||
<div class="inputlabel">Max Query Buffers:</div>
|
||||
<input type="number" name="maxquerybuffers" value="<? VAR MaxQueryBuffers ?>" class="third" min="0"
|
||||
title="Maximum number of query buffers. 0 is unlimited."/>
|
||||
</div>
|
||||
|
||||
<div class="subsection half" id="ctcpreplies_plain">
|
||||
<div class="inputlabel">CTCP Replies:</div>
|
||||
|
||||
+13
-4
@@ -261,12 +261,20 @@ public:
|
||||
pNewUser->SetDCCBindHost(pUser->GetDCCBindHost());
|
||||
}
|
||||
|
||||
sArg = WebSock.GetParam("bufsize"); if (!sArg.empty()) pNewUser->SetBufferCount(sArg.ToUInt(), spSession->IsAdmin());
|
||||
sArg = WebSock.GetParam("chanbufsize");
|
||||
if (!sArg.empty()) {
|
||||
// First apply the old limit in case the new one is too high
|
||||
if (pUser)
|
||||
pNewUser->SetBufferCount(pUser->GetBufferCount(), true);
|
||||
pNewUser->SetBufferCount(sArg.ToUInt(), spSession->IsAdmin());
|
||||
pNewUser->SetChanBufferSize(pUser->GetChanBufferSize(), true);
|
||||
pNewUser->SetChanBufferSize(sArg.ToUInt(), spSession->IsAdmin());
|
||||
}
|
||||
|
||||
sArg = WebSock.GetParam("querybufsize");
|
||||
if (!sArg.empty()) {
|
||||
// First apply the old limit in case the new one is too high
|
||||
if (pUser)
|
||||
pNewUser->SetQueryBufferSize(pUser->GetQueryBufferSize(), true);
|
||||
pNewUser->SetQueryBufferSize(sArg.ToUInt(), spSession->IsAdmin());
|
||||
}
|
||||
|
||||
pNewUser->SetSkinName(WebSock.GetParam("skin"));
|
||||
@@ -1211,7 +1219,8 @@ public:
|
||||
Tmpl["RealName"] = pUser->GetRealName();
|
||||
Tmpl["QuitMsg"] = pUser->GetQuitMsg();
|
||||
Tmpl["DefaultChanModes"] = pUser->GetDefaultChanModes();
|
||||
Tmpl["BufferCount"] = CString(pUser->GetBufferCount());
|
||||
Tmpl["ChanBufferSize"] = CString(pUser->GetChanBufferSize());
|
||||
Tmpl["QueryBufferSize"] = CString(pUser->GetQueryBufferSize());
|
||||
Tmpl["TimestampFormat"] = pUser->GetTimestampFormat();
|
||||
Tmpl["Timezone"] = pUser->GetTimezone();
|
||||
Tmpl["JoinTries"] = CString(pUser->JoinTries());
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ CChan::CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfi
|
||||
}
|
||||
|
||||
m_Nick.SetNetwork(m_pNetwork);
|
||||
m_Buffer.SetLineCount(m_pNetwork->GetUser()->GetBufferCount(), true);
|
||||
m_Buffer.SetLineCount(m_pNetwork->GetUser()->GetChanBufferSize(), true);
|
||||
|
||||
if (pConfig) {
|
||||
CString sValue;
|
||||
|
||||
+1
-2
@@ -21,8 +21,7 @@
|
||||
using std::vector;
|
||||
|
||||
CQuery::CQuery(const CString& sName, CIRCNetwork* pNetwork) : m_sName(sName), m_pNetwork(pNetwork), m_Buffer() {
|
||||
// Bandaid for users who upgrade from <=1.4 and have 0 in "default channel buffer size" setting.
|
||||
SetBufferCount(std::max(100u, m_pNetwork->GetUser()->GetBufferCount()), true);
|
||||
SetBufferCount(m_pNetwork->GetUser()->GetQueryBufferSize(), true);
|
||||
}
|
||||
|
||||
CQuery::~CQuery() {
|
||||
|
||||
+31
-5
@@ -20,6 +20,7 @@
|
||||
#include <znc/IRCNetwork.h>
|
||||
#include <znc/IRCSock.h>
|
||||
#include <znc/Chan.h>
|
||||
#include <znc/Query.h>
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -85,7 +86,8 @@ CUser::CUser(const CString& sUserName)
|
||||
m_vIRCNetworks(),
|
||||
m_vClients(),
|
||||
m_ssAllowedHosts(),
|
||||
m_uBufferCount(50),
|
||||
m_uChanBufferSize(50),
|
||||
m_uQueryBufferSize(50),
|
||||
m_uBytesRead(0),
|
||||
m_uBytesWritten(0),
|
||||
m_uMaxJoinTries(10),
|
||||
@@ -211,6 +213,10 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
|
||||
}
|
||||
if (pConfig->FindStringEntry("buffer", sValue))
|
||||
SetBufferCount(sValue.ToUInt(), true);
|
||||
if (pConfig->FindStringEntry("chanbuffersize", sValue))
|
||||
SetChanBufferSize(sValue.ToUInt(), true);
|
||||
if (pConfig->FindStringEntry("querybuffersize", sValue))
|
||||
SetQueryBufferSize(sValue.ToUInt(), true);
|
||||
if (pConfig->FindStringEntry("awaysuffix", sValue)) {
|
||||
CUtils::PrintMessage("WARNING: AwaySuffix has been deprecated, instead try -> LoadModule = awaynick %nick%_" + sValue);
|
||||
}
|
||||
@@ -693,7 +699,8 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
|
||||
SetQuitMsg(User.GetQuitMsg());
|
||||
SetSkinName(User.GetSkinName());
|
||||
SetDefaultChanModes(User.GetDefaultChanModes());
|
||||
SetBufferCount(User.GetBufferCount(), true);
|
||||
SetChanBufferSize(User.GetChanBufferSize(), true);
|
||||
SetQueryBufferSize(User.GetQueryBufferSize(), true);
|
||||
SetJoinTries(User.JoinTries());
|
||||
SetMaxNetworks(User.MaxNetworks());
|
||||
SetMaxQueryBuffers(User.MaxQueryBuffers());
|
||||
@@ -879,7 +886,8 @@ CConfig CUser::ToConfig() const {
|
||||
config.AddKeyValuePair("StatusPrefix", GetStatusPrefix());
|
||||
config.AddKeyValuePair("Skin", GetSkinName());
|
||||
config.AddKeyValuePair("ChanModes", GetDefaultChanModes());
|
||||
config.AddKeyValuePair("Buffer", CString(GetBufferCount()));
|
||||
config.AddKeyValuePair("ChanBufferSize", CString(GetChanBufferSize()));
|
||||
config.AddKeyValuePair("QueryBufferSize", CString(GetQueryBufferSize()));
|
||||
config.AddKeyValuePair("AutoClearChanBuffer", CString(AutoClearChanBuffer()));
|
||||
config.AddKeyValuePair("AutoClearQueryBuffer", CString(AutoClearQueryBuffer()));
|
||||
config.AddKeyValuePair("MultiClients", CString(MultiClients()));
|
||||
@@ -1162,6 +1170,10 @@ void CUser::SetAutoClearChanBuffer(bool b) {
|
||||
void CUser::SetAutoClearQueryBuffer(bool b) { m_bAutoClearQueryBuffer = b; }
|
||||
|
||||
bool CUser::SetBufferCount(unsigned int u, bool bForce) {
|
||||
return SetChanBufferSize(u, bForce);
|
||||
}
|
||||
|
||||
bool CUser::SetChanBufferSize(unsigned int u, bool bForce) {
|
||||
if (!bForce && u > CZNC::Get().GetMaxBufferSize())
|
||||
return false;
|
||||
for (CIRCNetwork* pNetwork : m_vIRCNetworks) {
|
||||
@@ -1169,7 +1181,19 @@ bool CUser::SetBufferCount(unsigned int u, bool bForce) {
|
||||
pChan->InheritBufferCount(u, bForce);
|
||||
}
|
||||
}
|
||||
m_uBufferCount = u;
|
||||
m_uChanBufferSize = u;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUser::SetQueryBufferSize(unsigned int u, bool bForce) {
|
||||
if (!bForce && u > CZNC::Get().GetMaxBufferSize())
|
||||
return false;
|
||||
for (CIRCNetwork* pNetwork : m_vIRCNetworks) {
|
||||
for (CQuery* pQuery : pNetwork->GetQueries()) {
|
||||
pQuery->SetBufferCount(u, bForce);
|
||||
}
|
||||
}
|
||||
m_uQueryBufferSize = u;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1239,7 +1263,9 @@ bool CUser::HasSpaceForNewNetwork() const { return GetNetworks().size() < MaxNet
|
||||
|
||||
CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.Trim_n().empty()) ? m_sQuitMsg : CZNC::GetTag(false); }
|
||||
const MCString& CUser::GetCTCPReplies() const { return m_mssCTCPReplies; }
|
||||
unsigned int CUser::GetBufferCount() const { return m_uBufferCount; }
|
||||
unsigned int CUser::GetBufferCount() const { return GetChanBufferSize(); }
|
||||
unsigned int CUser::GetChanBufferSize() const { return m_uChanBufferSize; }
|
||||
unsigned int CUser::GetQueryBufferSize() const { return m_uQueryBufferSize; }
|
||||
bool CUser::AutoClearChanBuffer() const { return m_bAutoClearChanBuffer; }
|
||||
bool CUser::AutoClearQueryBuffer() const { return m_bAutoClearQueryBuffer; }
|
||||
//CString CUser::GetSkinName() const { return (!m_sSkinName.empty()) ? m_sSkinName : CZNC::Get().GetSkinName(); }
|
||||
|
||||
Reference in New Issue
Block a user