mirror of
https://github.com/znc/znc.git
synced 2026-07-06 01:41:12 +02:00
@@ -45,6 +45,7 @@ public:
|
||||
~CIRCNetwork();
|
||||
|
||||
enum {
|
||||
JOIN_FREQUENCY = 30,
|
||||
/** How long must an IRC connection be idle before ZNC sends a ping */
|
||||
PING_FREQUENCY = 270,
|
||||
/** Time between checks if PINGs need to be sent */
|
||||
@@ -136,6 +137,7 @@ public:
|
||||
*/
|
||||
bool IsIRCConnected() const;
|
||||
void SetIRCSocket(CIRCSock* pIRCSock);
|
||||
void IRCConnected();
|
||||
void IRCDisconnected();
|
||||
void CheckIRCConnect();
|
||||
|
||||
@@ -178,6 +180,9 @@ public:
|
||||
void SetFloodRate(double fFloodRate) { m_fFloodRate = fFloodRate; }
|
||||
void SetFloodBurst(unsigned short int uFloodBurst) { m_uFloodBurst = uFloodBurst; }
|
||||
|
||||
unsigned short int GetJoinDelay() const { return m_uJoinDelay; }
|
||||
void SetJoinDelay(unsigned short int uJoinDelay) { m_uJoinDelay = uJoinDelay; }
|
||||
|
||||
CString ExpandString(const CString& sStr) const;
|
||||
CString& ExpandString(const CString& sStr, CString& sRet) const;
|
||||
private:
|
||||
@@ -224,6 +229,8 @@ protected:
|
||||
|
||||
CIRCNetworkPingTimer* m_pPingTimer;
|
||||
CIRCNetworkJoinTimer* m_pJoinTimer;
|
||||
|
||||
unsigned short int m_uJoinDelay;
|
||||
};
|
||||
|
||||
#endif // !_IRCNETWORK_H
|
||||
|
||||
@@ -114,6 +114,7 @@ class CAdminMod : public CModule {
|
||||
{"BindHost", str},
|
||||
{"FloodRate", doublenum},
|
||||
{"FloodBurst", integer},
|
||||
{"JoinDelay", integer},
|
||||
#ifdef HAVE_ICU
|
||||
{"Encoding", str},
|
||||
#endif
|
||||
@@ -498,6 +499,8 @@ class CAdminMod : public CModule {
|
||||
PutModule("FloodRate = " + CString(pNetwork->GetFloodRate()));
|
||||
} else if (sVar.Equals("floodburst")) {
|
||||
PutModule("FloodBurst = " + CString(pNetwork->GetFloodBurst()));
|
||||
} else if (sVar.Equals("joindelay")) {
|
||||
PutModule("JoinDelay = " + CString(pNetwork->GetJoinDelay()));
|
||||
#ifdef HAVE_ICU
|
||||
} else if (sVar.Equals("encoding")) {
|
||||
PutModule("Encoding = " + pNetwork->GetEncoding());
|
||||
@@ -587,6 +590,9 @@ class CAdminMod : public CModule {
|
||||
} else if (sVar.Equals("floodburst")) {
|
||||
pNetwork->SetFloodBurst(sValue.ToUShort());
|
||||
PutModule("FloodBurst = " + CString(pNetwork->GetFloodBurst()));
|
||||
} else if (sVar.Equals("joindelay")) {
|
||||
pNetwork->SetJoinDelay(sValue.ToUShort());
|
||||
PutModule("JoinDelay = " + CString(pNetwork->GetJoinDelay()));
|
||||
#ifdef HAVE_ICU
|
||||
} else if (sVar.Equals("encoding")) {
|
||||
pNetwork->SetEncoding(sValue);
|
||||
|
||||
@@ -104,6 +104,14 @@
|
||||
<? IF FloodProtection ?> value="<? VAR FloodBurst ?>" <? ELSE ?> value="4" disabled="disabled" <? ENDIF ?>
|
||||
/> lines can be sent immediately
|
||||
</div>
|
||||
|
||||
<div class="subsection">
|
||||
<div class="inputlabel">Channel join delay:</div>
|
||||
<input type="number" name="joindelay" min="0" id="joindelay"
|
||||
title="Defines the delay in seconds, until channels are joined after getting connected."
|
||||
value="<? VAR JoinDelay ?>"
|
||||
/> seconds
|
||||
</div>
|
||||
<script type="text/javascript">floodprotection_change();</script>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
||||
@@ -821,6 +821,8 @@ public:
|
||||
Tmpl["FloodRate"] = CString(pNetwork->GetFloodRate());
|
||||
Tmpl["FloodBurst"] = CString(pNetwork->GetFloodBurst());
|
||||
|
||||
Tmpl["JoinDelay"] = CString(pNetwork->GetJoinDelay());
|
||||
|
||||
Tmpl["IRCConnectEnabled"] = CString(pNetwork->GetIRCConnectEnabled());
|
||||
|
||||
const vector<CServer*>& vServers = pNetwork->GetServers();
|
||||
@@ -863,6 +865,7 @@ public:
|
||||
Tmpl["FloodProtection"] = "true";
|
||||
Tmpl["FloodRate"] = "1.0";
|
||||
Tmpl["FloodBurst"] = "4";
|
||||
Tmpl["JoinDelay"] = "0";
|
||||
}
|
||||
|
||||
FOR_EACH_MODULE(i, make_pair(pUser, pNetwork)) {
|
||||
@@ -946,6 +949,8 @@ public:
|
||||
pNetwork->SetFloodRate(-1);
|
||||
}
|
||||
|
||||
pNetwork->SetJoinDelay(WebSock.GetParam("joindelay").ToUShort());
|
||||
|
||||
VCString vsArgs;
|
||||
|
||||
pNetwork->DelServers();
|
||||
|
||||
+25
-3
@@ -61,22 +61,31 @@ private:
|
||||
|
||||
class CIRCNetworkJoinTimer : public CCron {
|
||||
public:
|
||||
CIRCNetworkJoinTimer(CIRCNetwork *pNetwork) : CCron() {
|
||||
m_pNetwork = pNetwork;
|
||||
CIRCNetworkJoinTimer(CIRCNetwork *pNetwork) : CCron(), m_bDelayed(false), m_pNetwork(pNetwork) {
|
||||
SetName("CIRCNetworkJoinTimer::" + m_pNetwork->GetUser()->GetUserName() + "::" + m_pNetwork->GetName());
|
||||
Start(30);
|
||||
Start(CIRCNetwork::JOIN_FREQUENCY);
|
||||
}
|
||||
|
||||
virtual ~CIRCNetworkJoinTimer() {}
|
||||
|
||||
void Delay(unsigned short int uDelay) {
|
||||
m_bDelayed = true;
|
||||
Start(uDelay);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void RunJob() {
|
||||
if (m_bDelayed) {
|
||||
m_bDelayed = false;
|
||||
Start(CIRCNetwork::JOIN_FREQUENCY);
|
||||
}
|
||||
if (m_pNetwork->IsIRCConnected()) {
|
||||
m_pNetwork->JoinChans();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_bDelayed;
|
||||
CIRCNetwork* m_pNetwork;
|
||||
};
|
||||
|
||||
@@ -116,6 +125,8 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
|
||||
m_fFloodRate = 1;
|
||||
m_uFloodBurst = 4;
|
||||
|
||||
m_uJoinDelay = 0;
|
||||
|
||||
m_RawBuffer.SetLineCount(100, true); // This should be more than enough raws, especially since we are buffering the MOTD separately
|
||||
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
|
||||
m_NoticeBuffer.SetLineCount(250, true);
|
||||
@@ -156,6 +167,7 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneName) {
|
||||
|
||||
m_fFloodRate = Network.GetFloodRate();
|
||||
m_uFloodBurst = Network.GetFloodBurst();
|
||||
m_uJoinDelay = Network.GetJoinDelay();
|
||||
|
||||
SetNick(Network.GetNick());
|
||||
SetAltNick(Network.GetAltNick());
|
||||
@@ -347,6 +359,7 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
|
||||
size_t numDoubleOptions = sizeof(DoubleOptions) / sizeof(DoubleOptions[0]);
|
||||
TOption<short unsigned int> SUIntOptions[] = {
|
||||
{ "floodburst", &CIRCNetwork::SetFloodBurst },
|
||||
{ "joindelay", &CIRCNetwork::SetJoinDelay },
|
||||
};
|
||||
size_t numSUIntOptions = sizeof(SUIntOptions) / sizeof(SUIntOptions[0]);
|
||||
|
||||
@@ -489,6 +502,7 @@ CConfig CIRCNetwork::ToConfig() const {
|
||||
config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled()));
|
||||
config.AddKeyValuePair("FloodRate", CString(GetFloodRate()));
|
||||
config.AddKeyValuePair("FloodBurst", CString(GetFloodBurst()));
|
||||
config.AddKeyValuePair("JoinDelay", CString(GetJoinDelay()));
|
||||
config.AddKeyValuePair("Encoding", m_sEncoding);
|
||||
|
||||
if (!m_sQuitMsg.empty()) {
|
||||
@@ -1199,6 +1213,14 @@ void CIRCNetwork::SetIRCSocket(CIRCSock* pIRCSock) {
|
||||
m_pIRCSock = pIRCSock;
|
||||
}
|
||||
|
||||
void CIRCNetwork::IRCConnected() {
|
||||
if (m_uJoinDelay > 0) {
|
||||
m_pJoinTimer->Delay(m_uJoinDelay);
|
||||
} else {
|
||||
JoinChans();
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCNetwork::IRCDisconnected() {
|
||||
m_pIRCSock = NULL;
|
||||
|
||||
|
||||
+1
-3
@@ -200,9 +200,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
m_pNetwork->ClearRawBuffer();
|
||||
m_pNetwork->AddRawBuffer(":" + _NAMEDFMT(sServer) + " " + sCmd + " {target} " + _NAMEDFMT(sRest));
|
||||
|
||||
// Join the first set of channels as soon as we are connected
|
||||
// and let the CIRCNetworkJoinTimer join the rest.
|
||||
m_pNetwork->JoinChans();
|
||||
m_pNetwork->IRCConnected();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user