X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fusermanager.cpp;h=a70a00085029bda15ef96e8850b6fe2025b1765b;hb=f2e3fd5952b23209b084bde4f464e6643c8a00ff;hp=02c030a42434b1c1414deebe2705e8e05532e432;hpb=124c17e14134a4999afc1a5e981ab7c75b3694b9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 02c030a42..a70a00085 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -28,21 +28,23 @@ namespace { class WriteCommonQuit : public User::ForEachNeighborHandler { - std::string line; - std::string operline; + ClientProtocol::Messages::Quit quitmsg; + ClientProtocol::Event quitevent; + ClientProtocol::Messages::Quit operquitmsg; + ClientProtocol::Event operquitevent; void Execute(LocalUser* user) CXX11_OVERRIDE { - user->Write(user->IsOper() ? operline : line); + user->Send(user->IsOper() ? operquitevent : quitevent); } public: WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg) - : line(":" + user->GetFullHost() + " QUIT :") - , operline(line) + : quitmsg(user, msg) + , quitevent(ServerInstance->GetRFCEvents().quit, quitmsg) + , operquitmsg(user, opermsg) + , operquitevent(ServerInstance->GetRFCEvents().quit, operquitmsg) { - line += msg; - operline += opermsg; user->ForEachNeighbor(*this, false); } }; @@ -128,7 +130,11 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString()); if (!ServerInstance->Config->XLineMessage.empty()) New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage); - this->QuitUser(New, b->Reason); + + if (ServerInstance->Config->HideBans) + this->QuitUser(New, b->Type + "-lined", &b->Reason); + else + this->QuitUser(New, b->Reason); return; } else @@ -177,7 +183,12 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: user->quitting = true; ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str()); - user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str()); + LocalUser* const localuser = IS_LOCAL(user); + if (localuser) + { + ClientProtocol::Messages::Error errormsg(InspIRCd::Format("Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str())); + localuser->Send(ServerInstance->GetRFCEvents().error, errormsg); + } std::string reason; reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit); @@ -210,6 +221,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: uuidlist.erase(user->uuid); user->PurgeEmptyChannels(); + user->UnOper(); } void UserManager::AddClone(User* user) @@ -264,12 +276,13 @@ void UserManager::ServerNoticeAll(const char* text, ...) { std::string message; VAFORMAT(message, text, text); - message = "NOTICE $" + ServerInstance->Config->ServerName + " :" + message; + ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, ServerInstance->Config->ServerName, message, MSG_NOTICE); + ClientProtocol::Event msgevent(ServerInstance->GetRFCEvents().privmsg, msg); for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) { - User* t = *i; - t->WriteServ(message); + LocalUser* user = *i; + user->Send(msgevent); } } @@ -320,8 +333,8 @@ void UserManager::DoBackgroundUserStuff() this->QuitUser(curr, message); continue; } - - curr->Write("PING :" + ServerInstance->Config->ServerName); + ClientProtocol::Messages::Ping ping; + curr->Send(ServerInstance->GetRFCEvents().ping, ping); curr->lastping = 0; curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime(); }