diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 33 | ||||
-rw-r--r-- | src/modules/m_spanningtree/fmode.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 7 |
4 files changed, 32 insertions, 20 deletions
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 3d119ee78..dfe2fe13c 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -21,7 +21,7 @@ /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ -/** FJOIN, similar to TS6 SJOIN, but not quite. */ +/** FJOIN, almost identical to TS6 SJOIN, except for nicklist handling. */ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> ¶ms) { /* 1.1 FJOIN works as follows: @@ -57,23 +57,22 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p * the losing side sends any modes for the channel which shouldnt win, * they wont as their timestamp will be too high :-) */ - - if (params.size() < 2) + if (params.size() < 3) return true; irc::modestacker modestack(true); /* Modes to apply from the users in the user list */ User* who = NULL; /* User we are currently checking */ std::string channel = params[0]; /* Channel name, as a string */ time_t TS = atoi(params[1].c_str()); /* Timestamp given to us for remote side */ - irc::tokenstream users((params.size() > 2) ? params[2] : ""); /* users from the user list */ + 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->Instance->FindChan(channel); /* The channel we're sending joins to */ time_t ourTS = chan ? chan->age : Instance->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 */ - if (params.size() > 2) - params[2] = ":" + params[2]; + if (params.size() > 3) + params[params.size() - 1] = ":" + params[params.size() - 1]; Utils->DoOneToAllButSender(source,"FJOIN",params,source); @@ -106,7 +105,27 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p } } - /* Now, process every 'prefixes,nick' pair */ + /* First up, apply their modes if they won the TS war */ + if (apply_other_sides_modes) + { + unsigned int idx = 2; + int numpara = 1; + const char* modelist[64]; + memset(&modelist,0,sizeof(modelist)); + + // Mode parser needs to know what channel to act on. + modelist[0] = params[0].c_str(); + + /* Remember, params[params.size() - 1] is nicklist, and we don't want to apply *that* */ + for (idx = 2; idx != (params.size() - 1); idx++) + { + modelist[numpara++] = params[idx].c_str(); + } + + this->Instance->SendMode(modelist, numpara, this->Instance->FakeClient); + } + + /* Now, process every 'modes,nick' pair */ while (users.GetToken(item)) { const char* usr = item.c_str(); diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp index 94a5c1dce..6fa269584 100644 --- a/src/modules/m_spanningtree/fmode.cpp +++ b/src/modules/m_spanningtree/fmode.cpp @@ -33,6 +33,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p bool smode = false; std::string sourceserv; + /* Are we dealing with an FMODE from a user, or from a server? */ User* who = this->Instance->FindNick(source); if (who) @@ -44,7 +45,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p { /* FMODE from a server, use a fake user to receive mode feedback */ who = this->Instance->FakeClient; - smode = true; /* Setting this flag tells us we should free the User later */ + smode = true; /* Setting this flag tells us it is a server mode*/ sourceserv = source; /* Set sourceserv to the actual source string */ } const char* modelist[64]; @@ -72,6 +73,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p User* dst = this->Instance->FindNick(params[0]); Channel* chan = NULL; time_t ourTS = 0; + if (dst) { ourTS = dst->age; @@ -99,9 +101,6 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p */ if (TS <= ourTS) { - if ((TS < ourTS) && (!dst)) - Instance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG *** Channel TS sent in FMODE to %s is %lu which is not equal to %lu!", params[0].c_str(), (unsigned long) TS, (unsigned long) ourTS); - if (smode) { this->Instance->SendMode(modelist, n, who); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index afc05bdbc..de149e473 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -576,12 +576,9 @@ void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, boo // new joining permissions for the user. params.push_back(channel->name); params.push_back(ConvToStr(channel->age)); + params.push_back(std::string("+") + channel->ChanModes(true)); params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->uuid)); Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FJOIN",params); - /* First user in, sync the modes for the channel */ - params.pop_back(); - params.push_back(std::string("+") + channel->ChanModes(true)); - Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",params); } else { diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 978a798ff..75f9b8e5b 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -83,10 +83,9 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) { std::string buffer; char list[MAXBUF]; - std::string individual_halfops = std::string(":")+this->Instance->Config->GetSID()+" FMODE "+c->name+" "+ConvToStr(c->age); size_t dlen, curlen; - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age); + dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age, c->ChanModes(true)); int numusers = 1; char* ptr = list + dlen; @@ -107,7 +106,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) if (curlen > (480-NICKMAX)) { buffer.append(list).append("\r\n"); - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age); + dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age, c->ChanModes(true)); ptr = list + dlen; ptrlen = 0; numusers = 0; @@ -117,8 +116,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) if (numusers) buffer.append(list).append("\r\n"); - buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).append("\r\n"); - int linesize = 1; for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++) { |