]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Amend OnPostCommand to specify whether the command is loopcalled.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index 2fd578698e2151f722117c43080d7a65b5a59858..0ff180a8338abfcf9ef6c6831471146fa885348f 100644 (file)
@@ -37,7 +37,8 @@
 #include "translate.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
-       : Stats::EventListener(this)
+       : Away::EventListener(this)
+       , Stats::EventListener(this)
        , rconnect(this)
        , rsquit(this)
        , map(this)
@@ -136,7 +137,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
                        InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str()));
 }
 
-void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user)
+void ModuleSpanningTree::HandleLinks(const CommandBase::Params& parameters, User* user)
 {
        ShowLinks(Utils->TreeRoot,user,0);
        user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
@@ -203,7 +204,15 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                return;
        }
 
-       if (strchr(x->IPAddr.c_str(),':'))
+#ifndef _WIN32
+       if (x->IPAddr.find('/') != std::string::npos)
+       {
+               struct stat sb;
+               if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode))
+                       ipvalid = false;
+       }
+#endif
+       if (x->IPAddr.find(':') != std::string::npos)
        {
                in6_addr n;
                if (inet_pton(AF_INET6, x->IPAddr.c_str(), &n) < 1)
@@ -243,7 +252,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                irc::sockets::sockaddrs bind;
                if ((!x->Bind.empty()) && (irc::sockets::aptosa(x->Bind, 0, bind)))
                {
-                       if (bind.sa.sa_family == AF_INET)
+                       if (bind.family() == AF_INET)
                                start_type = DNS::QUERY_A;
                }
 
@@ -297,7 +306,7 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
        }
 }
 
-ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
+ModResult ModuleSpanningTree::HandleVersion(const CommandBase::Params& parameters, User* user)
 {
        // We've already confirmed that !parameters.empty(), so this is safe
        TreeServer* found = Utils->FindServerMask(parameters[0]);
@@ -324,7 +333,7 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
        return MOD_RES_DENY;
 }
 
-ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
+ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameters, User* user)
 {
        for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
        {
@@ -485,12 +494,12 @@ void ModuleSpanningTree::OnChangeHost(User* user, const std::string &newhost)
        CmdBuilder(user, "FHOST").push(newhost).Broadcast();
 }
 
-void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
+void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real)
 {
        if (user->registered != REG_ALL || !IS_LOCAL(user))
                return;
 
-       CmdBuilder(user, "FNAME").push_last(gecos).Broadcast();
+       CmdBuilder(user, "FNAME").push_last(real).Broadcast();
 }
 
 void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident)
@@ -710,15 +719,19 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine *x)
        params.Broadcast();
 }
 
-ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
+void ModuleSpanningTree::OnUserAway(User* user)
 {
        if (IS_LOCAL(user))
-               CommandAway::Builder(user, awaymsg).Broadcast();
+               CommandAway::Builder(user).Broadcast();
+}
 
-       return MOD_RES_PASSTHRU;
+void ModuleSpanningTree::OnUserBack(User* user)
+{
+       if (IS_LOCAL(user))
+               CommandAway::Builder(user).Broadcast();
 }
 
-void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags, const std::string& output_mode)
+void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags)
 {
        if (processflags & ModeParser::MODE_LOCALONLY)
                return;
@@ -730,7 +743,7 @@ void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::
 
                CmdBuilder params(source, "MODE");
                params.push(u->uuid);
-               params.push(output_mode);
+               params.push(ClientProtocol::Messages::Mode::ToModeLetters(modes));
                params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
                params.Broadcast();
        }
@@ -739,7 +752,7 @@ void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::
                CmdBuilder params(source, "FMODE");
                params.push(c->name);
                params.push_int(c->age);
-               params.push(output_mode);
+               params.push(ClientProtocol::Messages::Mode::ToModeLetters(modes));
                params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
                params.Broadcast();
        }