]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Improve UserManager::QuitUser() and related code
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index f92c09b888d678242fdebf9b64a95dbdaa9acfb4..8c04d6c909797cacebf09dbcbdb7c34d6ee7bd51 100644 (file)
@@ -63,6 +63,7 @@ void ModuleSpanningTree::init()
        delete ServerInstance->PI;
        ServerInstance->PI = new SpanningTreeProtocolInterface;
        loopCall = false;
+       SplitInProgress = false;
 
        // update our local user count
        Utils->TreeRoot->UserCount = ServerInstance->Users->local_users.size();
@@ -99,7 +100,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
        else if ((Current->Hidden) && (!user->IsOper()))
                return;
 
-       user->WriteNumeric(364, "%s %s %s :%d %s",      user->nick.c_str(), Current->GetName().c_str(),
+       user->WriteNumeric(RPL_LINKS, "%s %s :%d %s",   Current->GetName().c_str(),
                        (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(),
                        (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops,
                        Current->GetDesc().c_str());
@@ -108,7 +109,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
 void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user)
 {
        ShowLinks(Utils->TreeRoot,user,0);
-       user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick.c_str());
+       user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list.");
 }
 
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
@@ -280,7 +281,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                catch (DNS::Exception& e)
                {
                        delete snr;
-                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
+                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason().c_str());
                        ConnectServer(y, false);
                }
        }
@@ -334,11 +335,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
                        return MOD_RES_PASSTHRU;
                }
                std::string Version = found->GetVersion();
-               user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
+               user->WriteNumeric(RPL_VERSION, ":%s", Version.c_str());
        }
        else
        {
-               user->WriteNumeric(402, "%s %s :No such server",user->nick.c_str(),parameters[0].c_str());
+               user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str());
        }
        return MOD_RES_DENY;
 }
@@ -547,13 +548,25 @@ void ModuleSpanningTree::OnUserPart(Membership* memb, std::string &partmessage,
 
 void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
 {
-       if ((IS_LOCAL(user)) && (user->registered == REG_ALL))
+       if (IS_LOCAL(user))
        {
                if (oper_message != reason)
                        ServerInstance->PI->SendMetaData(user, "operquit", oper_message);
 
                CmdBuilder(user, "QUIT").push_last(reason).Broadcast();
        }
+       else
+       {
+               // Hide the message if one of the following is true:
+               // - User is being quit due to a netsplit and quietbursts is on
+               // - Server is a silent uline
+               bool hide = (((this->SplitInProgress) && (Utils->quiet_bursts)) || (ServerInstance->SilentULine(user->server)));
+               if (!hide)
+               {
+                       ServerInstance->SNO->WriteToSnoMask('Q', "Client exiting on server %s: %s (%s) [%s]",
+                               user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_message.c_str());
+               }
+       }
 
        // Regardless, We need to modify the user Counts..
        TreeServer* SourceServer = Utils->FindServer(user->server);
@@ -589,7 +602,7 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick)
 
 void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts)
 {
-       if ((!IS_LOCAL(source) || source != ServerInstance->FakeClient))
+       if ((!IS_LOCAL(source)) && (source != ServerInstance->FakeClient))
                return;
 
        CmdBuilder params(source, "KICK");
@@ -631,7 +644,7 @@ void ModuleSpanningTree::ReadConfig(ConfigStatus& status)
                msg.append(e.GetReason());
                ServerInstance->SNO->WriteToSnoMask('l', msg);
                if (status.srcuser && !IS_LOCAL(status.srcuser))
-                       ServerInstance->PI->SendSNONotice("L", msg);
+                       ServerInstance->PI->SendSNONotice('L', msg);
        }
 }
 
@@ -718,19 +731,6 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
        return MOD_RES_PASSTHRU;
 }
 
-void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata)
-{
-       TreeSocket* s = static_cast<TreeSocket*>(opaque);
-       User* u = dynamic_cast<User*>(target);
-       Channel* c = dynamic_cast<Channel*>(target);
-       if (u)
-               s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata);
-       else if (c)
-               s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+ConvToStr(c->age)+" "+extname+" :"+extdata);
-       else if (!target)
-               s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
-}
-
 CullResult ModuleSpanningTree::cull()
 {
        if (Utils)