]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Add Inspircd::AddServices
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index afd40e0c9dda48fee653bc0c0ae055239ff0d8fe..fe2cfe9b62f98a8e5a074d5acaa47d4de2d5ea25 100644 (file)
@@ -46,10 +46,10 @@ ModuleSpanningTree::ModuleSpanningTree()
        {
                I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostTopicChange,
                I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin,
-               I_OnChangeLocalUserHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule,
+               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_OnSetAway, I_OnPostCommand, I_OnUserConnect
+               I_OnSetAway, I_OnPostCommand, I_OnUserConnect, I_OnAcceptConnection
        };
        ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
@@ -317,7 +317,8 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                }
                else
                {
-                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",
+                               x->Name.c_str(), newsocket->getError().c_str());
                        ServerInstance->GlobalCulls.AddItem(newsocket);
                }
        }
@@ -489,7 +490,7 @@ void ModuleSpanningTree::OnUserNotice(User* user, void* dest, int target_type, c
        if (target_type == TYPE_USER)
        {
                User* d = (User*)dest;
-               if ((d->GetFd() < 0) && (IS_LOCAL(user)))
+               if (!IS_LOCAL(d) && IS_LOCAL(user))
                {
                        parameterlist params;
                        params.push_back(d->uuid);
@@ -542,7 +543,7 @@ void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type,
                // route private messages which are targetted at clients only to the server
                // which needs to receive them
                User* d = (User*)dest;
-               if ((d->GetFd() < 0) && (IS_LOCAL(user)))
+               if (!IS_LOCAL(d) && (IS_LOCAL(user)))
                {
                        parameterlist params;
                        params.push_back(d->uuid);
@@ -591,7 +592,7 @@ void ModuleSpanningTree::OnBackgroundTimer(time_t curtime)
        DoConnectTimeout(curtime);
 }
 
-void ModuleSpanningTree::OnUserConnect(User* user)
+void ModuleSpanningTree::OnUserConnect(LocalUser* user)
 {
        if (user->quitting)
                return;
@@ -609,6 +610,14 @@ void ModuleSpanningTree::OnUserConnect(User* user)
        params.push_back(":"+std::string(user->fullname));
        Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params);
 
+       for(Extensible::ExtensibleStore::const_iterator i = user->GetExtList().begin(); i != user->GetExtList().end(); i++)
+       {
+               ExtensionItem* item = i->first;
+               std::string value = item->serialize(FORMAT_NETWORK, user, i->second);
+               if (!value.empty())
+                       ServerInstance->PI->SendMetaData(user, item->name, value);
+       }
+
        Utils->TreeRoot->SetUserCount(1); // increment by 1
 }
 
@@ -629,21 +638,19 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created, C
        }
 }
 
-ModResult ModuleSpanningTree::OnChangeLocalUserHost(User* user, const std::string &newhost)
+void ModuleSpanningTree::OnChangeHost(User* user, const std::string &newhost)
 {
-       if (user->registered != REG_ALL)
-               return MOD_RES_PASSTHRU;
+       if (user->registered != REG_ALL || !IS_LOCAL(user))
+               return;
 
        parameterlist params;
        params.push_back(newhost);
        Utils->DoOneToMany(user->uuid,"FHOST",params);
-       return MOD_RES_PASSTHRU;
 }
 
 void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
 {
-       // only occurs for local clients
-       if (user->registered != REG_ALL)
+       if (user->registered != REG_ALL || !IS_LOCAL(user))
                return;
 
        parameterlist params;
@@ -732,7 +739,7 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s
        {
                Utils->DoOneToMany(source->uuid,"KICK",params);
        }
-       else if (IS_SERVER(source) && source != Utils->ServerUser)
+       else if (source == ServerInstance->FakeClient)
        {
                Utils->DoOneToMany(ServerInstance->Config->GetSID(),"KICK",params);
        }
@@ -769,7 +776,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string &parameter)
 void ModuleSpanningTree::OnRehash(User* user)
 {
        // Re-read config stuff
-       Utils->ReadConfiguration(true);
+       Utils->ReadConfiguration();
 }
 
 void ModuleSpanningTree::OnLoadModule(Module* mod)
@@ -796,7 +803,7 @@ void ModuleSpanningTree::RedoConfig(Module* mod)
 
        if (mod->ModuleSourceFile == "m_sha256.so" || IsBufferSocketModule)
        {
-               Utils->ReadConfiguration(true);
+               Utils->ReadConfiguration();
        }
 }
 
@@ -944,7 +951,7 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con
                s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
 }
 
-bool ModuleSpanningTree::cull()
+CullResult ModuleSpanningTree::cull()
 {
        Utils->cull();
        ServerInstance->Timers->DelTimer(RefreshTimer);