/** If you make a change which breaks the protocol, increment this.
* If you completely change the protocol, completely change the number.
*/
-const long ProtocolVersion = 1100;
+const long ProtocolVersion = 1101;
/*
* The server list in InspIRCd is maintained as two structures
{
if (x->Name == this->myhost)
{
- this->Instance->SNO->WriteToSnoMask('l',"Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
+ this->Instance->SNO->WriteToSnoMask('l',"Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] started.");
this->SendCapabilities();
if (x->EncryptionKey != "")
{
ourTS = us->age;
}
- Instance->Log(DEBUG,"FJOIN detected, our TS=%lu, their TS=%lu",ourTS,TS);
+ /* XXX: PAY ATTENTION:
+ * In 1.1, if they have the newer channel, we immediately clear
+ * all status modes from our users. We then accept their modes.
+ * If WE have the newer channel its the other side's job to do this.
+ * Note that this causes the losing server to send out confirming
+ * FMODE lines.
+ */
+ if ((ourTS > TS) || (this->Instance->ULine(source.c_str())))
+ {
+ Instance->Log(DEBUG,"FJOIN detected, our TS=%lu, their TS=%lu",ourTS,TS);
+ std::deque<std::string> param_list;
+ us->age = TS;
+ ourTS = TS;
+ param_list.push_back(chan->name);
+ Instance->Log(DEBUG,"REMOVE ALL STATUS MODES FROM OUR USERS *NOW*");
+ this->RemoveStatus(Instance->Config->ServerName, param_list);
+ }
irc::tokenstream users(params[2]);
std::string item = "*";
ourTS = TS;
}
}
- else
- {
- Instance->Log(DEBUG,"Their channel newer than ours, bouncing their modes");
- /* bouncy bouncy! */
- std::deque<std::string> params;
- /* modes are now being UNSET... */
- *mode_users[1] = '-';
- for (unsigned int x = 0; x < modectr; x++)
- {
- if (x == 1)
- {
- params.push_back(ConvToStr(us->age));
- }
- params.push_back(mode_users[x]);
-
- }
- // tell everyone to bounce the modes. bad modes, bad!
- DoOneToMany(this->Instance->Config->ServerName,"FMODE",params);
- }
strcpy(mode_users[1],"+");
for (unsigned int f = 2; f < modectr; f++)
free(mode_users[f]);
}
else
{
- Instance->Log(SPARSE,"Warning! Invalid user %s in FJOIN to channel %s IGNORED", who->nick, channel.c_str());
+ Instance->Log(SPARSE,"Warning! Invalid user in FJOIN to channel %s IGNORED", channel.c_str());
continue;
}
}
ourTS = TS;
}
}
- else
- {
- Instance->Log(DEBUG,"Their channel newer than ours, bouncing their modes");
- std::deque<std::string> params;
- *mode_users[1] = '-';
- for (unsigned int x = 0; x < modectr; x++)
- {
- if (x == 1)
- {
- params.push_back(ConvToStr(us->age));
- }
- params.push_back(mode_users[x]);
- }
- DoOneToMany(this->Instance->Config->ServerName,"FMODE",params);
- }
for (unsigned int f = 2; f < modectr; f++)
free(mode_users[f]);
}
}
+ bool RemoveStatus(std::string prefix, std::deque<std::string> ¶ms)
+ {
+ if (params.size() < 1)
+ return true;
+
+ chanrec* c = Instance->FindChan(params[0]);
+
+ if (c)
+ {
+ CUList *ulist = c->GetUsers();
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ std::string modesequence = Instance->Modes->ModeString(i->second, c);
+ if (modesequence.length())
+ {
+ modesequence = "-" + modesequence;
+
+ std::deque<std::string> items;
+ const char* y[127];
+ unsigned int z = 0;
+ std::string x = "*";
+ irc::spacesepstream sep(modesequence);
+
+ while ((x = sep.GetToken()) != "")
+ {
+ if (!z)
+ {
+ y[z++] = c->name;
+ items.push_back(c->name);
+ items.push_back(ConvToStr(c->age));
+ }
+ items.push_back(x);
+ y[z++] = (items.end() - 1)->c_str();
+ }
+
+ DoOneToMany(Instance->Config->ServerName, "FMODE", items);
+ userrec* n = new userrec(Instance);
+ n->SetFd(FD_MAGIC_NUMBER);
+ Instance->SendMode(y,z,n);
+ delete n;
+ }
+ }
+ }
+ return true;
+ }
+
bool RemoteServer(std::string prefix, std::deque<std::string> ¶ms)
{
if (params.size() < 4)
{
return this->MetaData(prefix,params);
}
+ else if (command == "REMSTATUS")
+ {
+ return this->RemoveStatus(prefix,params);
+ }
else if (command == "PING")
{
/*
// Only do this for local users
if (IS_LOCAL(user))
{
- char ts[24];
- snprintf(ts,24,"%lu",(unsigned long)channel->age);
-
std::deque<std::string> params;
params.clear();
params.push_back(channel->name);
-
- /** XXX: The client protocol will IGNORE this parameter.
- * We could make use of it if we wanted to keep the TS
- * in step if somehow we lose it.
- */
- params.push_back(ts);
-
- if (channel->GetUserCounter() > 1)
- {
- // not the first in the channel
- DoOneToMany(user->nick,"JOIN",params);
- }
- else
- {
- // first in the channel, set up their permissions
- // and the channel TS with FJOIN.
- params.clear();
- params.push_back(channel->name);
- params.push_back(ts);
- params.push_back("@,"+std::string(user->nick));
- DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
- }
+ // set up their permissions and the channel TS with FJOIN.
+ // All users are FJOINed now, because a module may specify
+ // new joining permissions for the user.
+ params.clear();
+ params.push_back(channel->name);
+ params.push_back(ConvToStr(channel->age));
+ params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->nick));
+ DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
}
}
virtual void OnEvent(Event* event)
{
+ std::deque<std::string>* params = (std::deque<std::string>*)event->GetData();
+
if (event->GetEventID() == "send_metadata")
{
- std::deque<std::string>* params = (std::deque<std::string>*)event->GetData();
if (params->size() < 3)
return;
(*params)[2] = ":" + (*params)[2];
DoOneToMany(ServerInstance->Config->ServerName,"METADATA",*params);
}
+ else if (event->GetEventID() == "send_topic")
+ {
+ if (params->size() < 2)
+ return;
+ (*params)[1] = ":" + (*params)[1];
+ params->insert(params->begin() + 1,ServerInstance->Config->ServerName);
+ params->insert(params->begin() + 1,ConvToStr(ServerInstance->Time()));
+ DoOneToMany(ServerInstance->Config->ServerName,"FTOPIC",*params);
+ }
else if (event->GetEventID() == "send_mode")
{
- std::deque<std::string>* params = (std::deque<std::string>*)event->GetData();
if (params->size() < 2)
return;
// Insert the TS value of the object, either userrec or chanrec