#define nspace __gnu_cxx
+
+/** 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;
+
/*
* The server list in InspIRCd is maintained as two structures
* which hold the data in different ways. Most of the time, we
syntax = "<remote-server-mask> <servermask>";
}
- void Handle (const char** parameters, int pcnt, userrec *user)
+ CmdResult Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick,parameters[0],parameters[1]);
/* Is this aimed at our server? */
const char* para[1];
para[0] = parameters[1];
Creator->OnPreCommand("CONNECT", para, 1, user, true);
+
+ return CMD_SUCCESS;
}
+
+ return CMD_FAILURE;
}
};
#ifdef SUPPORT_IP6LINKS
ip6support = 1;
#endif
- this->WriteLine("CAPAB CAPABILITIES :NICKMAX="+ConvToStr(NICKMAX)+" HALFOP="+ConvToStr(this->Instance->Config->AllowHalfop)+" CHANMAX="+ConvToStr(CHANMAX)+" MAXMODES="+ConvToStr(MAXMODES)+" IDENTMAX="+ConvToStr(IDENTMAX)+" MAXQUIT="+ConvToStr(MAXQUIT)+" MAXTOPIC="+ConvToStr(MAXTOPIC)+" MAXKICK="+ConvToStr(MAXKICK)+" MAXGECOS="+ConvToStr(MAXGECOS)+" MAXAWAY="+ConvToStr(MAXAWAY)+" IP6NATIVE="+ConvToStr(ip6)+" IP6SUPPORT="+ConvToStr(ip6support));
+ this->WriteLine("CAPAB CAPABILITIES :NICKMAX="+ConvToStr(NICKMAX)+" HALFOP="+ConvToStr(this->Instance->Config->AllowHalfop)+" CHANMAX="+ConvToStr(CHANMAX)+" MAXMODES="+ConvToStr(MAXMODES)+" IDENTMAX="+ConvToStr(IDENTMAX)+" MAXQUIT="+ConvToStr(MAXQUIT)+" MAXTOPIC="+ConvToStr(MAXTOPIC)+" MAXKICK="+ConvToStr(MAXKICK)+" MAXGECOS="+ConvToStr(MAXGECOS)+" MAXAWAY="+ConvToStr(MAXAWAY)+" IP6NATIVE="+ConvToStr(ip6)+" IP6SUPPORT="+ConvToStr(ip6support)+" PROTOCOL="+ConvToStr(ProtocolVersion));
this->WriteLine("CAPAB END");
}
if (((this->CapKeys.find("NICKMAX") == this->CapKeys.end()) || ((this->CapKeys.find("NICKMAX") != this->CapKeys.end()) && (this->CapKeys.find("NICKMAX")->second != ConvToStr(NICKMAX)))))
reason = "Maximum nickname lengths differ or remote nickname length not specified";
+ if (((this->CapKeys.find("PROTOCOL") == this->CapKeys.end()) || ((this->CapKeys.find("PROTOCOL") != this->CapKeys.end()) && (this->CapKeys.find("PROTOCOL")->second != ConvToStr(ProtocolVersion)))))
+ {
+ if (this->CapKeys.find("PROTOCOL") != this->CapKeys.end())
+ {
+ reason = "Mismatched protocol versions "+this->CapKeys.find("PROTOCOL")->second+" and "+ConvToStr(ProtocolVersion);
+ }
+ else
+ {
+ reason = "Protocol version not specified";
+ }
+ }
+
if (((this->CapKeys.find("HALFOP") == this->CapKeys.end()) && (Instance->Config->AllowHalfop)) || ((this->CapKeys.find("HALFOP") != this->CapKeys.end()) && (this->CapKeys.find("HALFOP")->second != ConvToStr(Instance->Config->AllowHalfop))))
reason = "We don't both have halfop support enabled/disabled identically";
}
else
{
- for (unsigned int f = 2; f < modectr; f++)
- free(mode_users[f]);
-
- this->WriteLine("ERROR :Invalid user '"+std::string(usr)+"' in FJOIN to '"+channel+"'");
- return false;
+ ServerInstance->Log(SPARSE,"Warning! Invalid user %s in FJOIN to channel %s IGNORED", who->nick, channel.c_str());
+ continue;
}
}
}
return true;
}
- bool SyncChannelTS(std::string source, std::deque<std::string> ¶ms)
- {
- if (params.size() >= 2)
- {
- chanrec* c = this->Instance->FindChan(params[0]);
- if (c)
- {
- time_t theirTS = atoi(params[1].c_str());
- time_t ourTS = c->age;
- if (ourTS >= theirTS)
- {
- ServerInstance->Log(DEBUG,"Updating timestamp for %s, our timestamp was %lu and theirs is %lu",c->name,ourTS,theirTS);
- c->age = theirTS;
- }
- }
- }
- DoOneToAllButSender(this->Instance->Config->ServerName,"SYNCTS",params,source);
- return true;
- }
-
/* NICK command */
bool IntroduceClient(std::string source, std::deque<std::string> ¶ms)
{
{
strparams[q] = params[q].c_str();
}
- if (!this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
+ switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
{
- this->WriteLine("ERROR :Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
- return false;
+ case CMD_INVALID:
+ this->WriteLine("ERROR :Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
+ return false;
+ break;
+ case CMD_FAILURE:
+ return true;
+ break;
+ default:
+ break;
}
}
else
this->HandleVersion(parameters,pcnt,user);
return 1;
}
- else if (ServerInstance->IsValidModuleCommand(command, pcnt, user))
+
+ return 0;
+ }
+
+ virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result)
+ {
+ if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, pcnt, user)))
{
// this bit of code cleverly routes all module commands
// to all remote severs *automatically* so that modules
ServerInstance->Log(DEBUG,"Globally route '%s'",command.c_str());
DoOneToMany(user->nick,command,params);
}
- return 0;
}
virtual void OnGetServerDescription(const std::string &servername,std::string &description)
// 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
{
// first in the channel, set up their permissions
// and the channel TS with FJOIN.
- char ts[24];
- snprintf(ts,24,"%lu",(unsigned long)channel->age);
params.clear();
params.push_back(channel->name);
params.push_back(ts);
List[I_OnUserQuit] = List[I_OnUserPostNick] = List[I_OnUserKick] = List[I_OnRemoteKill] = List[I_OnRehash] = 1;
List[I_OnOper] = List[I_OnAddGLine] = List[I_OnAddZLine] = List[I_OnAddQLine] = List[I_OnAddELine] = 1;
List[I_OnDelGLine] = List[I_OnDelZLine] = List[I_OnDelQLine] = List[I_OnDelELine] = List[I_ProtoSendMode] = List[I_OnMode] = 1;
- List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = List[I_OnSetAway] = List[I_OnCancelAway] = 1;
+ List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = List[I_OnSetAway] = List[I_OnCancelAway] = List[I_OnPostCommand] = 1;
}
/* It is IMPORTANT that m_spanningtree is the last module in the chain