ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
: Module(Me), max_local(0), max_global(0)
{
- ServerInstance->UseInterface("InspSocketHook");
+ ServerInstance->Modules->UseInterface("InspSocketHook");
Utils = new SpanningTreeUtilities(Me, this);
command_rconnect = new cmd_rconnect(ServerInstance, this, Utils);
ServerInstance->AddCommand(command_rconnect);
{
if (serv->AnsweredLastPing())
{
- sock->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" PING "+serv->GetName());
+ sock->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" PING "+serv->GetID());
serv->SetNextPingTime(curtime + Utils->PingFreq);
serv->LastPing = curtime;
timeval t;
*/
void ModuleSpanningTree::RemoteMessage(userrec* user, const char* format, ...)
{
+ /* This could cause an infinite loop, because DoOneToMany() will, on error,
+ * call TreeSocket::OnError(), which in turn will call this function to
+ * notify everyone of the error. So, drop any messages that are generated
+ * during the sending of another message. -Special */
+ static bool SendingRemoteMessage = false;
+ if (SendingRemoteMessage)
+ return;
+ SendingRemoteMessage = true;
+
std::deque<std::string> params;
char text[MAXBUF];
va_list argsPtr;
Utils->DoOneToMany(ServerInstance->Config->GetSID(), "PUSH", params);
}
}
+
+ SendingRemoteMessage = false;
}
int ModuleSpanningTree::HandleConnect(const char** parameters, int pcnt, userrec* user)
TreeServer* CheckDupe = Utils->FindServer(x->Name.c_str());
if (!CheckDupe)
{
- RemoteMessage(user, "*** CONNECT: Connecting to server: \002%s\002 (%s:%d)",user->nick,x->Name.c_str(),(x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()),x->Port);
+ RemoteMessage(user, "*** CONNECT: Connecting to server: \002%s\002 (%s:%d)",x->Name.c_str(),(x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()),x->Port);
ConnectServer(&(*x));
return 1;
}
else
{
- RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002",user->nick,x->Name.c_str(),CheckDupe->GetParent()->GetName().c_str());
+ RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002",x->Name.c_str(),CheckDupe->GetParent()->GetName().c_str());
return 1;
}
}
}
- RemoteMessage(user, "NOTICE %s :*** CONNECT: No server matching \002%s\002 could be found in the config file.",user->nick,parameters[0]);
+ RemoteMessage(user, "*** CONNECT: No server matching \002%s\002 could be found in the config file.",parameters[0]);
return 1;
}
std::deque<std::string> params;
params.push_back(ConvToStr(ServerInstance->Time(false)));
params.push_back("FORCE");
- Utils->DoOneToMany(Utils->TreeRoot->GetName(), "TIMESET", params);
+ Utils->DoOneToMany(ServerInstance->Config->GetSID(), "TIMESET", params);
}
}
int n_translate = thiscmd->translation.size();
TranslateType translate_to;
+ /* To make sure that parameters with spaces, or empty
+ * parameters, etc, are always sent properly, *always*
+ * prefix the last parameter with a :. This also removes
+ * an extra strchr() */
for (int j = 0; j < pcnt; j++)
{
std::string target;
ServerInstance->Log(DEBUG,"TRANSLATION: %s - type is %d", parameters[j], translate_to);
ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target);
-
- if (strchr(parameters[j],' '))
+
+ if (j == (pcnt - 1))
params.push_back(":" + target);
else
params.push_back(target);
void ModuleSpanningTree::OnUserConnect(userrec* user)
{
- char agestr[MAXBUF];
if (IS_LOCAL(user))
{
std::deque<std::string> params;
- snprintf(agestr,MAXBUF,"%lu",(unsigned long)user->age);
params.push_back(user->uuid);
- params.push_back(agestr);
+ params.push_back(ConvToStr(user->age));
params.push_back(user->nick);
params.push_back(user->host);
params.push_back(user->dhost);
params.push_back(user->ident);
params.push_back("+"+std::string(user->FormatModes()));
params.push_back(user->GetIPString());
+ params.push_back(ConvToStr(user->signon));
params.push_back(":"+std::string(user->fullname));
Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params);
// User is Local, change needs to be reflected!
{
std::deque<std::string> params;
params.push_back(user->nick);
+
+ /** IMPORTANT: We don't update the TS if the oldnick is just a case change of the newnick!
+ */
+ if (irc::string(user->nick) != assign(oldnick))
+ user->age = ServerInstance->Time(true);
+
+ params.push_back(ConvToStr(user->age));
Utils->DoOneToMany(user->uuid,"NICK",params);
}
}
ServerInstance->Timers->DelTimer(RefreshTimer);
- ServerInstance->DoneWithInterface("InspSocketHook");
+ ServerInstance->Modules->DoneWithInterface("InspSocketHook");
}
Version ModuleSpanningTree::GetVersion()
}
MODULE_INIT(ModuleSpanningTree)
-