X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fm_spanningtree%2Ffjoin.cpp;h=4367186b9e5ccf2fba4cd776cf3e63380c10385a;hb=192fa7d3138ccb5929dc9af8de3395d6ea25619c;hp=ee6c6c02a16443304c38b08874daadb6f13d5dbe;hpb=1ccbfbd4136762519f8316809b5e049453654457;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index ee6c6c02a..4367186b9 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -2,8 +2,8 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -14,9 +14,9 @@ #include "inspircd.h" #include "xline.h" -#include "m_spanningtree/treesocket.h" -#include "m_spanningtree/treeserver.h" -#include "m_spanningtree/utils.h" +#include "treesocket.h" +#include "treeserver.h" +#include "utils.h" /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ @@ -60,7 +60,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p irc::tokenstream users((params.size() > 3) ? params[params.size() - 1] : ""); /* users from the user list */ bool apply_other_sides_modes = true; /* True if we are accepting the other side's modes */ Channel* chan = this->ServerInstance->FindChan(channel); /* The channel we're sending joins to */ - time_t ourTS = chan ? chan->age : ServerInstance->Time()+600; /* The TS of our side of the link */ bool created = !chan; /* True if the channel doesnt exist here yet */ std::string item; /* One item in the list of nicks */ @@ -77,25 +76,36 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p } if (created) - chan = new Channel(ServerInstance, channel, ourTS); - - /* If our TS is less than theirs, we dont accept their modes */ - if (ourTS < TS) - apply_other_sides_modes = false; - - /* Our TS greater than theirs, clear all our modes from the channel, accept theirs. */ - if (ourTS > TS) { - std::deque param_list; - if (Utils->AnnounceTSChange && chan) - chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :TS for %s changed from %lu to %lu", chan->name.c_str(), chan->name.c_str(), (unsigned long) ourTS, (unsigned long) TS); - ourTS = TS; - if (!created) + chan = new Channel(ServerInstance, channel, TS); + ServerInstance->SNO->WriteToSnoMask('d', "Creation FJOIN recieved for %s, timestamp: %lu", chan->name.c_str(), (unsigned long)TS); + } + else + { + time_t ourTS = chan->age; + + if (TS != ourTS) + ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN recieved for %s, ourTS: %lu, TS: %lu, difference: %lu", + chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS)); + /* If our TS is less than theirs, we dont accept their modes */ + if (ourTS < TS) { + ServerInstance->SNO->WriteToSnoMask('d', "NOT Applying modes from other side"); + apply_other_sides_modes = false; + } + else if (ourTS > TS) + { + /* Our TS greater than theirs, clear all our modes from the channel, accept theirs. */ + ServerInstance->SNO->WriteToSnoMask('d', "Removing our modes, accepting remote"); + std::deque param_list; + if (Utils->AnnounceTSChange && chan) + chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :TS for %s changed from %lu to %lu", chan->name.c_str(), chan->name.c_str(), (unsigned long) ourTS, (unsigned long) TS); + ourTS = TS; chan->age = TS; param_list.push_back(channel); this->RemoveStatus(ServerInstance->Config->GetSID(), param_list); } + // The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on. } /* First up, apply their modes if they won the TS war */ @@ -113,7 +123,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p modelist.push_back(params[idx]); } - this->ServerInstance->SendMode(modelist, this->ServerInstance->FakeClient); + this->ServerInstance->SendMode(modelist, Utils->ServerUser); } /* Now, process every 'modes,nick' pair */ @@ -158,7 +168,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p for (std::string::iterator x = modes.begin(); x != modes.end(); ++x) modestack.Push(*x, who->nick); - Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", true, TS); + Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", route_back_again->bursting, TS); } else { @@ -177,19 +187,15 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p while (modestack.GetStackedLine(stackresult)) { - for (size_t j = 0; j < stackresult.size(); j++) - { - mode_junk.push_back(stackresult[j]); - } - ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient); + mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end()); + ServerInstance->SendMode(mode_junk, Utils->ServerUser); + mode_junk.erase(mode_junk.begin() + 1, mode_junk.end()); } } return true; } -/** TODO: This creates a total mess of output and needs to really use irc::modestacker. - */ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque ¶ms) { if (params.size() < 1) @@ -218,10 +224,9 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque while (stack.GetStackedLine(stackresult)) { - for (size_t j = 0; j < stackresult.size(); j++) - mode_junk.push_back(stackresult[j]); - - ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient); + mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end()); + ServerInstance->SendMode(mode_junk, Utils->ServerUser); + mode_junk.erase(mode_junk.begin() + 1, mode_junk.end()); } } return true;