X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fmain.cpp;h=5ed66b80541f299cbf3d3f630a7149b2cc003fed;hb=a5cb6b99fb781d4b8e63f98d0644e02f75e54608;hp=2651e1a4ac4fc9ac5bfb4572bcb18045e1496981;hpb=875aa2d98d1eb25f4932fbd2ac5c2086d16ff6ea;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2651e1a4a..5ed66b805 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -1,11 +1,15 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 linuxdaemon + * Copyright (C) 2013, 2017-2020 Sadie Powell + * Copyright (C) 2013, 2016 Adam + * Copyright (C) 2012-2016, 2018 Attila Molnar + * Copyright (C) 2012 Robby * Copyright (C) 2009-2010 Daniel De Graaf - * Copyright (C) 2007-2009 Craig Edwards - * Copyright (C) 2007-2008 Robin Burchell - * Copyright (C) 2008 Thomas Stagner - * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2007-2009 Robin Burchell + * Copyright (C) 2007-2009 Dennis Friis + * Copyright (C) 2005, 2007-2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -25,7 +29,6 @@ #include "socket.h" #include "xline.h" #include "iohook.h" -#include "modules/server.h" #include "resolvers.h" #include "main.h" @@ -47,10 +50,12 @@ ModuleSpanningTree::ModuleSpanningTree() , currmembid(0) , broadcasteventprov(this, "event/server-broadcast") , linkeventprov(this, "event/server-link") + , messageeventprov(this, "event/server-message") , synceventprov(this, "event/server-sync") , sslapi(this) + , servicetag(this) , DNS(this, "DNS") - , tagevprov(this, "event/messagetag") + , tagevprov(this) , loopCall(false) { } @@ -210,17 +215,13 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) // If this fails then the IP sa will be AF_UNSPEC. irc::sockets::aptosa(x->IPAddr, x->Port, sa); } - + /* Do we already have an IP? If so, no need to resolve it. */ if (sa.family() != AF_UNSPEC) { // Create a TreeServer object that will start connecting immediately in the background TreeSocket* newsocket = new TreeSocket(x, y, sa); - if (newsocket->GetFd() > -1) - { - /* Handled automatically on success */ - } - else + if (!newsocket->HasFd()) { ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.", x->Name.c_str(), newsocket->getError().c_str()); @@ -359,10 +360,10 @@ void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel if (IS_LOCAL(source)) { CmdBuilder params(source, "INVITE"); - params.push_back(dest->uuid); - params.push_back(channel->name); + params.push(dest->uuid); + params.push(channel->name); params.push_int(channel->age); - params.push_back(ConvToStr(expiry)); + params.push(ConvToStr(expiry)); params.Broadcast(); } } @@ -403,7 +404,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ { CmdBuilder params(user, message_type); params.push_tags(details.tags_out); - params.push_back(d->uuid); + params.push(d->uuid); params.push_last(details.text); params.Unicast(d); } @@ -419,7 +420,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ const std::string* serverglob = target.Get(); CmdBuilder par(user, message_type); par.push_tags(details.tags_out); - par.push_back(*serverglob); + par.push(std::string("$") + *serverglob); par.push_last(details.text); par.Broadcast(); break; @@ -441,7 +442,7 @@ void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& t { CmdBuilder params(user, "TAGMSG"); params.push_tags(details.tags_out); - params.push_back(d->uuid); + params.push(d->uuid); params.Unicast(d); } break; @@ -456,7 +457,7 @@ void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& t const std::string* serverglob = target.Get(); CmdBuilder par(user, "TAGMSG"); par.push_tags(details.tags_out); - par.push_back(*serverglob); + par.push(std::string("$") + *serverglob); par.Broadcast(); break; } @@ -486,7 +487,7 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) 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); + std::string value = item->ToNetwork(user, i->second); if (!value.empty()) ServerInstance->PI->SendMetaData(user, item->name, value); } @@ -513,12 +514,12 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by else { CmdBuilder params(memb->user, "IJOIN"); - params.push_back(memb->chan->name); + params.push(memb->chan->name); params.push_int(memb->id); if (!memb->modes.empty()) { - params.push_back(ConvToStr(memb->chan->age)); - params.push_back(memb->modes); + params.push(ConvToStr(memb->chan->age)); + params.push(memb->modes); } params.Broadcast(); } @@ -553,7 +554,7 @@ void ModuleSpanningTree::OnUserPart(Membership* memb, std::string &partmessage, if (IS_LOCAL(memb->user)) { CmdBuilder params(memb->user, "PART"); - params.push_back(memb->chan->name); + params.push(memb->chan->name); if (!partmessage.empty()) params.push_last(partmessage); params.Broadcast(); @@ -593,8 +594,8 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick) { // The nick TS is updated by the core, we don't do it CmdBuilder params(user, "NICK"); - params.push_back(user->nick); - params.push_back(ConvToStr(user->age)); + params.push(user->nick); + params.push(ConvToStr(user->age)); params.Broadcast(); } else if (!loopCall) @@ -609,8 +610,8 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s return; CmdBuilder params(source, "KICK"); - params.push_back(memb->chan->name); - params.push_back(memb->user->uuid); + params.push(memb->chan->name); + params.push(memb->user->uuid); // If a remote user is being kicked by us then send the membership id in the kick too if (!IS_LOCAL(memb->user)) params.push_int(memb->id); @@ -626,7 +627,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter) if (!parameter.empty() && parameter[0] != '-') { CmdBuilder params(user ? user : ServerInstance->FakeClient, "REHASH"); - params.push_back(parameter); + params.push(parameter); params.Forward(user ? TreeServer::Get(user)->GetRoute() : NULL); } } @@ -689,7 +690,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) { TreeServer* server = i->second; if (!server->IsRoot()) - FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server)); + FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server, false)); } return; } @@ -749,8 +750,8 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine *x) user = ServerInstance->FakeClient; CmdBuilder params(user, "DELLINE"); - params.push_back(x->type); - params.push_back(x->Displayable()); + params.push(x->type); + params.push(x->Displayable()); params.Broadcast(); } @@ -793,6 +794,13 @@ void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes:: } } +void ModuleSpanningTree::OnShutdown(const std::string& reason) +{ + const TreeServer::ChildServers& children = Utils->TreeRoot->GetChildren(); + while (!children.empty()) + children.front()->SQuit(reason, true); +} + CullResult ModuleSpanningTree::cull() { if (Utils) @@ -804,7 +812,7 @@ ModuleSpanningTree::~ModuleSpanningTree() { ServerInstance->PI = &ServerInstance->DefaultProtocolInterface; - Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); + Server* newsrv = new Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); SetLocalUsersServer(newsrv); delete Utils;