mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
@@ -148,9 +148,6 @@ AC_ARG_ENABLE( [poll],
|
||||
AS_HELP_STRING([--disable-poll], [use select() instead of poll()]),
|
||||
[POLL="$enableval"],
|
||||
[POLL="yes"])
|
||||
AC_ARG_ENABLE([add-networks],
|
||||
AS_HELP_STRING([--enable-add-networks], [allow non-admins to add networks]),
|
||||
[ if test x"$enableval" = "xyes" ; then appendCXX "-DENABLE_ADD_NETWORK" ; fi ])
|
||||
|
||||
AC_ARG_WITH([systemdsystemunitdir],
|
||||
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
void RemoveNetwork(CIRCNetwork *pNetwork);
|
||||
CIRCNetwork* FindNetwork(const CString& sNetwork) const;
|
||||
const std::vector<CIRCNetwork*>& GetNetworks() const;
|
||||
bool HasSpaceForNewNetwork() const;
|
||||
// !Networks
|
||||
|
||||
bool PutUser(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
|
||||
@@ -124,6 +125,7 @@ public:
|
||||
void SetTimezone(const CString& s) { m_sTimezone = s; }
|
||||
void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; }
|
||||
void SetSkinName(const CString& s) { m_sSkinName = s; }
|
||||
void SetMaxNetworks(unsigned int i) { m_uMaxNetworks = i; }
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
@@ -164,6 +166,7 @@ public:
|
||||
unsigned long long BytesWritten() const { return m_uBytesWritten; }
|
||||
unsigned int JoinTries() const { return m_uMaxJoinTries; }
|
||||
CString GetSkinName() const;
|
||||
unsigned int MaxNetworks() const { return m_uMaxNetworks; }
|
||||
// !Getters
|
||||
|
||||
protected:
|
||||
@@ -208,6 +211,7 @@ protected:
|
||||
unsigned long long m_uBytesRead;
|
||||
unsigned long long m_uBytesWritten;
|
||||
unsigned int m_uMaxJoinTries;
|
||||
unsigned int m_uMaxNetworks;
|
||||
CString m_sSkinName;
|
||||
|
||||
CModules* m_pModules;
|
||||
|
||||
@@ -698,13 +698,6 @@ class CAdminMod : public CModule {
|
||||
}
|
||||
|
||||
void AddNetwork(const CString& sLine) {
|
||||
#ifndef ENABLE_ADD_NETWORK
|
||||
if (!m_pUser->IsAdmin()) {
|
||||
PutModule("Permission denied");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
CString sUser = sLine.Token(1);
|
||||
CString sNetwork = sLine.Token(2);
|
||||
CUser *pUser = m_pUser;
|
||||
@@ -714,6 +707,7 @@ class CAdminMod : public CModule {
|
||||
} else {
|
||||
pUser = GetUser(sUser);
|
||||
if (!pUser) {
|
||||
PutModule("User not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -723,6 +717,11 @@ class CAdminMod : public CModule {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_pUser->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
|
||||
PutStatus("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones using /znc DelNetwork <name>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pUser->FindNetwork(sNetwork)) {
|
||||
PutModule(pUser->GetUserName() + " already has a network named [" + sNetwork + "]");
|
||||
return;
|
||||
|
||||
@@ -260,6 +260,11 @@
|
||||
<input type="number" name="jointries" value="<? VAR JoinTries ?>" class="third" min="0"
|
||||
title="This defines how often ZNC tries to join, if the first join failed, e.g. due to channel mode +i/+k or if you're banned." />
|
||||
</div>
|
||||
<div class="subsection">
|
||||
<div class="inputlabel">Max IRC Networks Number:</div>
|
||||
<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 half">
|
||||
<div class="inputlabel">CTCP Replies:</div>
|
||||
<div><textarea name="ctcpreplies" cols="70" rows="3"><? LOOP CTCPLoop ?><? VAR CTCP ?>
|
||||
|
||||
+11
-4
@@ -266,9 +266,11 @@ public:
|
||||
if (spSession->IsAdmin()) {
|
||||
pNewUser->SetDenyLoadMod(WebSock.GetParam("denyloadmod").ToBool());
|
||||
pNewUser->SetDenySetBindHost(WebSock.GetParam("denysetbindhost").ToBool());
|
||||
sArg = WebSock.GetParam("maxnetworks"); if (!sArg.empty()) pNewUser->SetMaxNetworks(sArg.ToUInt());
|
||||
} else if (pUser) {
|
||||
pNewUser->SetDenyLoadMod(pUser->DenyLoadMod());
|
||||
pNewUser->SetDenySetBindHost(pUser->DenySetBindHost());
|
||||
pNewUser->SetMaxNetworks(pUser->MaxNetworks());
|
||||
}
|
||||
|
||||
// If pUser is not NULL, we are editing an existing user.
|
||||
@@ -788,12 +790,10 @@ public:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifndef ENABLE_ADD_NETWORK
|
||||
if (!spSession->IsAdmin()) {
|
||||
WebSock.PrintErrorPage("Permission denied");
|
||||
if (!spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
|
||||
WebSock.PrintErrorPage("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones from Your Settings");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Tmpl["Action"] = "addnetwork";
|
||||
Tmpl["Title"] = "Add Network for User [" + pUser->GetUserName() + "]";
|
||||
@@ -813,6 +813,10 @@ public:
|
||||
}
|
||||
|
||||
if (!pNetwork) {
|
||||
if (!spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
|
||||
WebSock.PrintErrorPage("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones from Your Settings");
|
||||
return true;
|
||||
}
|
||||
pNetwork = pUser->AddNetwork(sName);
|
||||
if (!pNetwork) {
|
||||
WebSock.PrintErrorPage("Network [" + sName.Token(0) + "] already exists");
|
||||
@@ -1009,6 +1013,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
Tmpl["ImAdmin"] = CString(spSession->IsAdmin());
|
||||
|
||||
if (pUser) {
|
||||
Tmpl["Username"] = pUser->GetUserName();
|
||||
Tmpl["Nick"] = pUser->GetNick();
|
||||
@@ -1022,6 +1028,7 @@ public:
|
||||
Tmpl["TimestampFormat"] = pUser->GetTimestampFormat();
|
||||
Tmpl["Timezone"] = pUser->GetTimezone();
|
||||
Tmpl["JoinTries"] = CString(pUser->JoinTries());
|
||||
Tmpl["MaxNetworks"] = CString(pUser->MaxNetworks());
|
||||
|
||||
const set<CString>& ssAllowedHosts = pUser->GetAllowedHosts();
|
||||
for (set<CString>::const_iterator it = ssAllowedHosts.begin(); it != ssAllowedHosts.end(); ++it) {
|
||||
|
||||
@@ -677,19 +677,7 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
PutStatusNotice("If you want to choose another network, use /znc JumpNetwork <network>, or connect to ZNC with username " + m_pUser->GetUserName() + "/<network> (instead of just " + m_pUser->GetUserName() + ")");
|
||||
}
|
||||
} else {
|
||||
#ifndef ENABLE_ADD_NETWORK
|
||||
if (!m_pUser->IsAdmin()) {
|
||||
/* Since this user cannot add his own network,
|
||||
* lets make them a default network */
|
||||
m_pNetwork = m_pUser->AddNetwork("default");
|
||||
} else {
|
||||
#endif
|
||||
|
||||
PutStatusNotice("You have no networks configured. Use /znc AddNetwork <network> to add one.");
|
||||
|
||||
#ifndef ENABLE_ADD_NETWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SetNetwork(m_pNetwork, false);
|
||||
|
||||
@@ -417,12 +417,10 @@ void CClient::UserCommand(CString& sLine) {
|
||||
PutStatus("Total: " + CString(vChans.size()) + " - Joined: " + CString(uNumJoined) +
|
||||
" - Detached: " + CString(uNumDetached) + " - Disabled: " + CString(uNumDisabled));
|
||||
} else if (sCommand.Equals("ADDNETWORK")) {
|
||||
#ifndef ENABLE_ADD_NETWORK
|
||||
if (!m_pUser->IsAdmin()) {
|
||||
PutStatus("Permission denied");
|
||||
if (!m_pUser->IsAdmin() && !m_pUser->HasSpaceForNewNetwork()) {
|
||||
PutStatus("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones using /znc DelNetwork <name>");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
CString sNetwork = sLine.Token(1);
|
||||
|
||||
|
||||
+5
-1
@@ -86,6 +86,7 @@ CUser::CUser(const CString& sUserName)
|
||||
m_sTimestampFormat = "[%H:%M:%S]";
|
||||
m_bAppendTimestamp = false;
|
||||
m_bPrependTimestamp = true;
|
||||
m_uMaxNetworks = 1;
|
||||
m_pUserTimer = new CUserTimer(this);
|
||||
CZNC::Get().GetManager().AddCron(m_pUserTimer);
|
||||
}
|
||||
@@ -137,6 +138,7 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
|
||||
size_t numStringOptions = sizeof(StringOptions) / sizeof(StringOptions[0]);
|
||||
TOption<unsigned int> UIntOptions[] = {
|
||||
{ "jointries", &CUser::SetJoinTries },
|
||||
{ "maxnetworks", &CUser::SetMaxNetworks },
|
||||
};
|
||||
size_t numUIntOptions = sizeof(UIntOptions) / sizeof(UIntOptions[0]);
|
||||
TOption<bool> BoolOptions[] = {
|
||||
@@ -653,6 +655,7 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
|
||||
SetDefaultChanModes(User.GetDefaultChanModes());
|
||||
SetBufferCount(User.GetBufferCount(), true);
|
||||
SetJoinTries(User.JoinTries());
|
||||
SetMaxNetworks(User.MaxNetworks());
|
||||
|
||||
// Allowed Hosts
|
||||
m_ssAllowedHosts.clear();
|
||||
@@ -847,6 +850,7 @@ CConfig CUser::ToConfig() {
|
||||
config.AddKeyValuePair("PrependTimestamp", CString(GetTimestampPrepend()));
|
||||
config.AddKeyValuePair("Timezone", m_sTimezone);
|
||||
config.AddKeyValuePair("JoinTries", CString(m_uMaxJoinTries));
|
||||
config.AddKeyValuePair("MaxNetworks", CString(m_uMaxNetworks));
|
||||
|
||||
// Allow Hosts
|
||||
if (!m_ssAllowedHosts.empty()) {
|
||||
@@ -1126,7 +1130,7 @@ bool CUser::DenySetBindHost() const { return m_bDenySetBindHost; }
|
||||
bool CUser::MultiClients() const { return m_bMultiClients; }
|
||||
const CString& CUser::GetStatusPrefix() const { return m_sStatusPrefix; }
|
||||
const CString& CUser::GetDefaultChanModes() const { return m_sDefaultChanModes; }
|
||||
|
||||
bool CUser::HasSpaceForNewNetwork() const { return GetNetworks().size() < MaxNetworks(); }
|
||||
|
||||
CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.Trim_n().empty()) ? m_sQuitMsg : CZNC::GetTag(false); }
|
||||
const MCString& CUser::GetCTCPReplies() const { return m_mssCTCPReplies; }
|
||||
|
||||
Reference in New Issue
Block a user