X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fmain.cpp;h=8c5439fbb239314f480a7b7c40121e067fd491fd;hb=3624c137a6db85eaab0372550c9dca79d6d21e55;hp=1fa7ef76b8b4ca08bcccc1f6208e7caff983ddbb;hpb=8790551dc182cd8804ee7d8ef89ccb31067cc2a4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 1fa7ef76b..8c5439fbb 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -26,6 +26,7 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" +#include "iohook.h" #include "resolvers.h" #include "main.h" @@ -73,10 +74,10 @@ void ModuleSpanningTree::init() Implementation eventlist[] = { I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostTopicChange, - I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, + I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, I_OnChangeHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule, - I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash, - I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, + I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRehash, I_OnPreRehash, + I_OnOper, I_OnAddLine, I_OnDelLine, I_OnLoadModule, I_OnStats, I_OnSetAway, I_OnPostCommand, I_OnUserConnect, I_OnAcceptConnection }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); @@ -380,15 +381,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector& para */ void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...) { - char text[MAXBUF]; - va_list argsPtr; - - va_start(argsPtr, format); - vsnprintf(text, MAXBUF, format, argsPtr); - va_end(argsPtr); + std::string text; + VAFORMAT(text, format, format); if (IS_LOCAL(user)) - user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text); + user->WriteNotice(text); else ServerInstance->PI->SendUserNotice(user, text); } @@ -458,16 +455,6 @@ void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std: Utils->DoOneToMany(user->uuid,"TOPIC",params); } -void ModuleSpanningTree::OnWallops(User* user, const std::string &text) -{ - if (IS_LOCAL(user)) - { - parameterlist params; - params.push_back(":"+text); - Utils->DoOneToMany(user->uuid,"WALLOPS",params); - } -} - void ModuleSpanningTree::LocalMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list, const char* message_type) { /* Server or remote origin, dest should always be non-null */ @@ -499,14 +486,9 @@ void ModuleSpanningTree::LocalMessage(User* user, void* dest, int target_type, c } } -void ModuleSpanningTree::OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) +void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) { - LocalMessage(user, dest, target_type, text, status, exempt_list, "NOTICE"); -} - -void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) -{ - LocalMessage(user, dest, target_type, text, status, exempt_list, "PRIVMSG"); + LocalMessage(user, dest, target_type, text, status, exempt_list, (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE")); } void ModuleSpanningTree::OnBackgroundTimer(time_t curtime) @@ -537,7 +519,8 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) if (user->IsOper()) { params.clear(); - params.push_back(user->oper->name); + params.push_back(":"); + params[0].append(user->oper->name); Utils->DoOneToMany(user->uuid,"OPERTYPE",params); } @@ -600,8 +583,7 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos) void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident) { - // only occurs for local clients - if (user->registered != REG_ALL) + if ((user->registered != REG_ALL) || (!IS_LOCAL(user))) return; parameterlist params; @@ -685,21 +667,6 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s } } -void ModuleSpanningTree::OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason) -{ - if (!IS_LOCAL(source)) - return; // Only start routing if we're origin. - - ServerInstance->OperQuit.set(dest, operreason); - parameterlist params; - params.push_back(":"+operreason); - Utils->DoOneToMany(dest->uuid,"OPERQUIT",params); - params.clear(); - params.push_back(dest->uuid); - params.push_back(":"+reason); - Utils->DoOneToMany(source->uuid,"KILL",params); -} - void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter) { if (loopCall) @@ -759,7 +726,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) { TreeServer* srv = Utils->TreeRoot->GetChild(x); TreeSocket* sock = srv->GetSocket(); - if (sock && sock->GetIOHook() == mod) + if (sock && sock->GetIOHook() && sock->GetIOHook()->creator == mod) { sock->SendError("SSL module unloaded"); sock->Close(); @@ -775,7 +742,8 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype) if (user->registered != REG_ALL || !IS_LOCAL(user)) return; parameterlist params; - params.push_back(opertype); + params.push_back(":"); + params[0].append(opertype); Utils->DoOneToMany(user->uuid,"OPERTYPE",params); } @@ -825,33 +793,6 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine *x) } } -void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const parameterlist &text, const std::vector &translate) -{ - if ((IS_LOCAL(user)) && (user->registered == REG_ALL)) - { - parameterlist params; - std::string output_text; - - ServerInstance->Parser->TranslateUIDs(translate, text, output_text); - - if (target_type == TYPE_USER) - { - User* u = (User*)dest; - params.push_back(u->uuid); - params.push_back(output_text); - Utils->DoOneToMany(user->uuid, "MODE", params); - } - else - { - Channel* c = (Channel*)dest; - params.push_back(c->name); - params.push_back(ConvToStr(c->age)); - params.push_back(output_text); - Utils->DoOneToMany(user->uuid, "FMODE", params); - } - } -} - ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg) { if (IS_LOCAL(user))