summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cull_list.h14
-rw-r--r--include/modules.h2
-rw-r--r--include/users.h7
-rw-r--r--src/cull_list.cpp32
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp2
-rw-r--r--src/users.cpp78
-rw-r--r--src/xline.cpp18
7 files changed, 78 insertions, 75 deletions
diff --git a/include/cull_list.h b/include/cull_list.h
index 64e6b3bdb..beafc1e80 100644
--- a/include/cull_list.h
+++ b/include/cull_list.h
@@ -39,6 +39,9 @@ class CullItem : public classbase
/** Holds the quit reason to use for this user.
*/
std::string reason;
+ /** Holds the quit reason opers see, if different from users
+ */
+ std::string oper_reason;
public:
/** Constrcutor.
* Initializes the CullItem with a user pointer
@@ -46,8 +49,8 @@ class CullItem : public classbase
* @param u The user to add
* @param r The quit reason of the added user
*/
- CullItem(userrec* u, std::string &r);
- CullItem(userrec* u, const char* r);
+ CullItem(userrec* u, std::string &r, const char* ro = "");
+ CullItem(userrec* u, const char* r, const char* ro = "");
~CullItem();
@@ -57,6 +60,9 @@ class CullItem : public classbase
/** Returns the user's quit reason
*/
std::string& GetReason();
+ /** Returns oper reason
+ */
+ std::string& GetOperReason();
};
/** The CullList class can be used by modules, and is used
@@ -102,8 +108,8 @@ class CullList : public classbase
* @param user The user to add
* @param reason The quit reason of the user being added
*/
- void AddItem(userrec* user, std::string &reason);
- void AddItem(userrec* user, const char* reason);
+ void AddItem(userrec* user, std::string &reason, const char* o_reason = "");
+ void AddItem(userrec* user, const char* reason, const char* o_reason = "");
/** Applies the cull list, quitting all the users
* on the list with their quit reasons all at once.
diff --git a/include/modules.h b/include/modules.h
index 473f84547..59d777b71 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -75,7 +75,7 @@ enum MessageType {
* ipv4 servers, so this value will be ten times as
* high on ipv6 servers.
*/
-#define NATIVE_API_VERSION 11014
+#define NATIVE_API_VERSION 11015
#ifdef IPV6
#define API_VERSION (NATIVE_API_VERSION * 10)
#else
diff --git a/include/users.h b/include/users.h
index d6d6fe0ab..8da80d62f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -669,10 +669,11 @@ class userrec : public connection
/** Disconnect a user gracefully
* @param user The user to remove
- * @param r The quit reason
+ * @param r The quit reason to show to normal users
+ * @param oreason The quit reason to show to opers
* @return Although this function has no return type, on exit the user provided will no longer exist.
*/
- static void QuitUser(InspIRCd* Instance, userrec *user, const std::string &r);
+ static void QuitUser(InspIRCd* Instance, userrec *user, const std::string &r, const char* oreason = "");
/** Add the user to WHOWAS system
*/
@@ -803,6 +804,8 @@ class userrec : public connection
*/
void WriteCommonExcept(const std::string &text);
+ void WriteCommonQuit(const std::string &normal_text, const std::string &oper_text);
+
/** Write a WALLOPS message from this user to all local opers.
* If this user is not opered, the function will return without doing anything.
* @param text The format string to send in the WALLOPS message
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index 2a022449f..c1a9de1a0 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -15,16 +15,26 @@
#include "users.h"
#include "cull_list.h"
-CullItem::CullItem(userrec* u, std::string &r)
+CullItem::CullItem(userrec* u, std::string &r, const char* o_reason)
{
this->user = u;
this->reason = r;
+ /* Seperate oper reason not set, use the user reason */
+ if (*o_reason)
+ this->oper_reason = o_reason;
+ else
+ this->oper_reason = r;
}
-CullItem::CullItem(userrec* u, const char* r)
+CullItem::CullItem(userrec* u, const char* r, const char* o_reason)
{
this->user = u;
this->reason = r;
+ /* Seperate oper reason not set, use the user reason */
+ if (*o_reason)
+ this->oper_reason = o_reason;
+ else
+ this->oper_reason = r;
}
CullItem::~CullItem()
@@ -41,23 +51,28 @@ std::string& CullItem::GetReason()
return this->reason;
}
+std::string& CullItem::GetOperReason()
+{
+ return this->oper_reason;
+}
+
CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
{
list.clear();
exempt.clear();
}
-void CullList::AddItem(userrec* user, std::string &reason)
+void CullList::AddItem(userrec* user, std::string &reason, const char* o_reason)
{
- AddItem(user, reason.c_str());
+ AddItem(user, reason.c_str(), o_reason);
}
-void CullList::AddItem(userrec* user, const char* reason)
+void CullList::AddItem(userrec* user, const char* reason, const char* o_reason)
{
if (exempt.find(user) == exempt.end())
{
- CullItem item(user,reason);
+ CullItem item(user, reason, o_reason);
list.push_back(item);
exempt[user] = user;
}
@@ -73,9 +88,12 @@ int CullList::Apply()
user_hash::iterator iter = ServerInstance->clientlist->find(a->GetUser()->nick);
std::map<userrec*, userrec*>::iterator exemptiter = exempt.find(a->GetUser());
std::string reason = a->GetReason();
+ std::string oper_reason = a->GetOperReason();
if (reason.length() > MAXQUIT - 1)
reason.resize(MAXQUIT - 1);
+ if (oper_reason.length() > MAXQUIT - 1)
+ oper_reason.resize(MAXQUIT - 1);
if (a->GetUser()->registered != REG_ALL)
if (ServerInstance->unregistered_count)
@@ -91,7 +109,7 @@ int CullList::Apply()
if (a->GetUser()->registered == REG_ALL)
{
a->GetUser()->PurgeEmptyChannels();
- a->GetUser()->WriteCommonExcept("QUIT :%s",reason.c_str());
+ a->GetUser()->WriteCommonQuit(reason, oper_reason);
FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(),reason));
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 8b7877117..c9e65b214 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -121,7 +121,7 @@ int TreeServer::QuitUsers(const std::string &reason)
{
userrec* a = (userrec*)*n;
if (!IS_LOCAL(a))
- userrec::QuitUser(ServerInstance,a,reason_s);
+ userrec::QuitUser(ServerInstance, a, "*.net *.split", reason_s);
}
return time_to_die.size();
}
diff --git a/src/users.cpp b/src/users.cpp
index 6398603d9..b10753b8b 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -800,13 +800,12 @@ void userrec::UnOper()
}
}
-void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &quitreason)
+void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &quitreason, const char* operreason)
{
user->muted = true;
- Instance->GlobalCulls.AddItem(user, quitreason.c_str());
+ Instance->GlobalCulls.AddItem(user, quitreason.c_str(), operreason);
}
-
/* adds or updates an entry in the whowas list */
void userrec::AddToWhoWas()
{
@@ -1490,67 +1489,47 @@ void userrec::WriteCommonExcept(const char* text, ...)
this->WriteCommonExcept(std::string(textbuffer));
}
-void userrec::WriteCommonExcept(const std::string &text)
+void userrec::WriteCommonQuit(const std::string &normal_text, const std::string &oper_text)
{
- bool quit_munge = false;
- char oper_quit[MAXBUF];
- char textbuffer[MAXBUF];
char tb1[MAXBUF];
char tb2[MAXBUF];
- std::string out1;
- std::string out2;
-
- strlcpy(textbuffer, text.c_str(), MAXBUF);
if (this->registered != REG_ALL)
return;
uniq_id++;
+ snprintf(tb1,MAXBUF,":%s QUIT :%s",this->GetFullHost(),normal_text.c_str());
+ snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost(),oper_text.c_str());
+ std::string out1 = tb1;
+ std::string out2 = tb2;
- snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),textbuffer);
-
- /* TODO: We need some form of WriteCommonExcept that will send two lines, one line to
- * opers and the other line to non-opers, then all this hidebans and hidesplits gunk
- * can go byebye.
- */
- if (ServerInstance->Config->HideSplits)
+ for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
{
- char* check = textbuffer + 6;
-
- if (!strncasecmp(textbuffer, "QUIT :",6))
+ CUList *ulist = v->first->GetUsers();
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- std::stringstream split(check);
- std::string server_one;
- std::string server_two;
-
- split >> server_one;
- split >> server_two;
-
- if ((ServerInstance->FindServerName(server_one)) && (ServerInstance->FindServerName(server_two)))
+ if (this != i->second)
{
- strlcpy(oper_quit,textbuffer,MAXQUIT);
- strlcpy(check,"*.net *.split",MAXQUIT);
- quit_munge = true;
- snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
- out2 = tb2;
+ if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
+ {
+ already_sent[i->second->fd] = uniq_id;
+ i->second->Write(*i->second->oper ? out2 : out1);
+ }
}
}
}
+}
- if ((ServerInstance->Config->HideBans) && (!quit_munge))
- {
- if ((!strncasecmp(textbuffer, "QUIT :G-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :K-Lined:",14))
- || (!strncasecmp(textbuffer, "QUIT :Q-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :Z-Lined:",14)))
- {
- char* check = textbuffer + 13;
- strlcpy(oper_quit,textbuffer,MAXQUIT);
- *check = 0; // We don't need to strlcpy, we just chop it from the :
- quit_munge = true;
- snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
- out2 = tb2;
- }
- }
+void userrec::WriteCommonExcept(const std::string &text)
+{
+ char tb1[MAXBUF];
+ std::string out1;
+ if (this->registered != REG_ALL)
+ return;
+
+ uniq_id++;
+ snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
out1 = tb1;
for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
@@ -1563,10 +1542,7 @@ void userrec::WriteCommonExcept(const std::string &text)
if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
{
already_sent[i->second->fd] = uniq_id;
- if (quit_munge)
- i->second->Write(*i->second->oper ? out2 : out1);
- else
- i->second->Write(out1);
+ i->second->Write(out1);
}
}
}
diff --git a/src/xline.cpp b/src/xline.cpp
index 1996925de..343f4d504 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -684,7 +684,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_gline(u,true)))
{
snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "G-Lined", reason);
}
}
@@ -693,7 +693,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_kline(u,true)))
{
snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "K-Lined", reason);
}
}
@@ -702,7 +702,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_qline(u->nick,true)))
{
snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "Q-Lined", reason);
}
}
@@ -711,7 +711,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_zline(u->GetIPString(),true)))
{
snprintf(reason,MAXBUF,"Z-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u,"Z-Lined", reason);
}
}
}
@@ -740,7 +740,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_gline(u)))
{
snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "G-Lined", reason);
}
}
if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
@@ -748,7 +748,7 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_kline(u)))
{
snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "K-Lined", reason);
}
}
if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
@@ -756,15 +756,15 @@ void XLineManager::apply_lines(const int What)
if ((check = matches_qline(u->nick)))
{
snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ ServerInstance->GlobalCulls.AddItem(u, "Q-Lined", reason);
}
}
if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
{
if ((check = matches_zline(u->GetIPString())))
{
- snprintf(reason,MAXBUF,"Z-Lined: %s",check->reason);
- ServerInstance->GlobalCulls.AddItem(u,reason);
+ snprintf(reason,MAXBUF,"Z-Lined: %s", check->reason);
+ ServerInstance->GlobalCulls.AddItem(u, "Z-Lined", reason);
}
}
}