diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cull_list.cpp | 32 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 78 | ||||
-rw-r--r-- | src/xline.cpp | 18 |
4 files changed, 62 insertions, 68 deletions
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); } } } |