From 144f168729eb58262660afa4fb0a27445290f7f7 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 28 Aug 2007 18:14:26 +0000 Subject: First round of servername->sid stuffs git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7961 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/main.cpp | 48 ++++++++++++------------- src/modules/m_spanningtree/rsquit.cpp | 3 +- src/modules/m_spanningtree/treesocket1.cpp | 56 +++++++++++++++++------------- 3 files changed, 57 insertions(+), 50 deletions(-) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index c9fb7debd..dd6282a63 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -436,7 +436,7 @@ int ModuleSpanningTree::HandleTime(const char** parameters, int pcnt, userrec* u std::deque params; params.push_back(found->GetName()); params.push_back(user->uuid); - Utils->DoOneToOne(ServerInstance->Config->ServerName,"TIME",params,found->GetName()); + Utils->DoOneToOne(ServerInstance->Config->GetSID(),"TIME",params,found->GetName()); } else { @@ -480,7 +480,7 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime) { if (serv->AnsweredLastPing()) { - sock->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PING "+serv->GetName()); + sock->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" PING "+serv->GetName()); serv->SetNextPingTime(curtime + Utils->PingFreq); serv->LastPing = curtime; timeval t; @@ -643,7 +643,7 @@ void ModuleSpanningTree::RemoteMessage(userrec* user, const char* format, ...) ServerInstance->SNO->WriteToSnoMask('l', "%s", text); params.push_back("l"); params.push_back(std::string(":") + text); - Utils->DoOneToMany(ServerInstance->Config->ServerName, "SNONOTICE", params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "SNONOTICE", params); } else { @@ -654,7 +654,7 @@ void ModuleSpanningTree::RemoteMessage(userrec* user, const char* format, ...) params.push_back(user->uuid); params.push_back(std::string("::") + ServerInstance->Config->ServerName + " NOTICE " + user->nick + " :*** From " + ServerInstance->Config->ServerName+ ": " + text); - Utils->DoOneToMany(ServerInstance->Config->ServerName, "PUSH", params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "PUSH", params); } } } @@ -992,11 +992,11 @@ void ModuleSpanningTree::OnUserJoin(userrec* user, chanrec* channel, bool &silen params.push_back(channel->name); params.push_back(ConvToStr(channel->age)); params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->uuid)); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FJOIN",params); /* First user in, sync the modes for the channel */ params.pop_back(); params.push_back(channel->ChanModes(true)); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",params); } else { @@ -1056,7 +1056,7 @@ void ModuleSpanningTree::OnUserConnect(userrec* user) params.push_back("+"+std::string(user->FormatModes())); params.push_back(user->GetIPString()); params.push_back(":"+std::string(user->fullname)); - Utils->DoOneToMany(ServerInstance->Config->ServerName, "UID", params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params); // User is Local, change needs to be reflected! TreeServer* SourceServer = Utils->FindServer(user->server); if (SourceServer) @@ -1115,7 +1115,7 @@ void ModuleSpanningTree::OnUserKick(userrec* source, userrec* user, chanrec* cha params.push_back(chan->name); params.push_back(user->uuid); params.push_back(":"+reason); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"KICK",params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"KICK",params); } } @@ -1137,7 +1137,7 @@ void ModuleSpanningTree::OnRehash(userrec* user, const std::string ¶meter) { std::deque params; params.push_back(parameter); - Utils->DoOneToMany(user ? user->nick : ServerInstance->Config->ServerName, "REHASH", params); + Utils->DoOneToMany(user ? user->nick : ServerInstance->Config->GetSID(), "REHASH", params); // check for self if (ServerInstance->MatchText(ServerInstance->Config->ServerName,parameter)) { @@ -1172,7 +1172,7 @@ void ModuleSpanningTree::OnLine(userrec* source, const std::string &host, bool a (unsigned long)duration, reason.c_str()); std::deque params; params.push_back(data); - Utils->DoOneToMany(ServerInstance->Config->ServerName, "ADDLINE", params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ADDLINE", params); } else { @@ -1303,12 +1303,12 @@ void ModuleSpanningTree::ProtoSendMode(void* opaque, int target_type, void* targ if (target_type == TYPE_USER) { userrec* u = (userrec*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" FMODE "+u->uuid+" "+ConvToStr(u->age)+" "+output_text); + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" FMODE "+u->uuid+" "+ConvToStr(u->age)+" "+output_text); } else { chanrec* c = (chanrec*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" "+output_text); + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" FMODE "+c->name+" "+ConvToStr(c->age)+" "+output_text); } } } @@ -1321,17 +1321,17 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, int target_type, void* if (target_type == TYPE_USER) { userrec* u = (userrec*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" METADATA "+u->uuid+" "+extname+" :"+extdata); + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata); } else if (target_type == TYPE_CHANNEL) { chanrec* c = (chanrec*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" METADATA "+c->name+" "+extname+" :"+extdata); + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+extname+" :"+extdata); } } if (target_type == TYPE_OTHER) { - s->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" METADATA * "+extname+" :"+extdata); + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata); } } @@ -1343,7 +1343,7 @@ void ModuleSpanningTree::OnEvent(Event* event) if (params->size() < 3) return; (*params)[2] = ":" + (*params)[2]; - Utils->DoOneToMany(ServerInstance->Config->ServerName,"METADATA",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"METADATA",*params); } else if (event->GetEventID() == "send_topic") { @@ -1352,7 +1352,7 @@ void ModuleSpanningTree::OnEvent(Event* event) (*params)[1] = ":" + (*params)[1]; params->insert(params->begin() + 1,ServerInstance->Config->ServerName); params->insert(params->begin() + 1,ConvToStr(ServerInstance->Time(true))); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"FTOPIC",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC",*params); } else if (event->GetEventID() == "send_mode") { @@ -1370,7 +1370,7 @@ void ModuleSpanningTree::OnEvent(Event* event) if (a) { ourTS = a->age; - Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",*params); return; } else @@ -1380,7 +1380,7 @@ void ModuleSpanningTree::OnEvent(Event* event) { ourTS = a->age; params->insert(params->begin() + 1,ConvToStr(ourTS)); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",*params); } } } @@ -1394,28 +1394,28 @@ void ModuleSpanningTree::OnEvent(Event* event) for (size_t n = 0; n < params->size(); n++) ServerInstance->Parser->TranslateUIDs(TR_NICK, (*params)[n], (*params)[n]); - Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",*params); } else if (event->GetEventID() == "send_opers") { if (params->size() < 1) return; (*params)[0] = ":" + (*params)[0]; - Utils->DoOneToMany(ServerInstance->Config->ServerName,"OPERNOTICE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"OPERNOTICE",*params); } else if (event->GetEventID() == "send_modeset") { if (params->size() < 2) return; (*params)[1] = ":" + (*params)[1]; - Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODENOTICE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODENOTICE",*params); } else if (event->GetEventID() == "send_snoset") { if (params->size() < 2) return; (*params)[1] = ":" + (*params)[1]; - Utils->DoOneToMany(ServerInstance->Config->ServerName,"SNONOTICE",*params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"SNONOTICE",*params); } else if (event->GetEventID() == "send_push") { @@ -1429,7 +1429,7 @@ void ModuleSpanningTree::OnEvent(Event* event) (*params)[0] = a->uuid; (*params)[1] = ":" + (*params)[1]; - Utils->DoOneToOne(ServerInstance->Config->ServerName, "PUSH", *params, a->server); + Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", *params, a->server); } } diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index 3654b2b50..0ea7988ec 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -114,6 +114,7 @@ void cmd_rsquit::NoticeUser(userrec* user, const std::string &msg) std::deque params; params.push_back(user->nick); params.push_back("NOTICE "+ConvToStr(user->nick)+" :"+msg); - Utils->DoOneToOne(ServerInstance->Config->ServerName, "PUSH", params, user->server); + Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", params, user->server); } } + diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index f2be6dd31..59f39a1d4 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -731,7 +731,7 @@ bool TreeSocket::ForceTopic(const std::string &source, std::deque & userrec* user = this->Instance->FindNick(source); if (!user) { - c->WriteChannelWithServ(Instance->Config->ServerName, "TOPIC %s :%s", c->name, c->topic); + c->WriteChannelWithServ(Instance->Config->GetSID(), "TOPIC %s :%s", c->name, c->topic); } else { @@ -824,7 +824,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p { chan->age = TS; param_list.push_back(channel); - this->RemoveStatus(Instance->Config->ServerName, param_list); + this->RemoveStatus(Instance->Config->GetSID(), param_list); } } @@ -990,7 +990,7 @@ int TreeSocket::DoCollision(userrec *u, time_t remotets, const char *remoteident else { /* user has not been introduced yet, just inform their server */ - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" SVSNICK "+remoteuid+" " + remoteuid); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" SVSNICK "+remoteuid+" " + remoteuid); } if (!bChangeLocal) @@ -1007,7 +1007,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque &pa */ if (params.size() != 9) { - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[0]+" :Invalid client introduction ("+params[0]+"?)"); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction ("+params[0]+"?)"); return true; } @@ -1022,14 +1022,14 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque &pa if (!remoteserver) { - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[0]+" :Invalid client introduction (Unknown server "+source+")"); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (Unknown server "+source+")"); return true; } /* Check parameters for validity before introducing the client, discovered by dmb */ if (!age) { - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[0]+" :Invalid client introduction (Invalid TS?)"); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (Invalid TS?)"); return true; } @@ -1037,7 +1037,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque &pa { if (params[valid[x].param].length() > valid[x].length) { - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[0]+" :Invalid client introduction (" + valid[x].item + " > " + ConvToStr(valid[x].length) + ")"); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (" + valid[x].item + " > " + ConvToStr(valid[x].length) + ")"); return true; } } @@ -1145,10 +1145,10 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c) { std::string buffer; char list[MAXBUF]; - std::string individual_halfops = std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age); + 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->ServerName,c->name,(unsigned long)c->age); + dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID(),c->name,(unsigned long)c->age); int numusers = 0; char* ptr = list + dlen; @@ -1169,7 +1169,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c) if (curlen > (480-NICKMAX)) { buffer.append(list).append("\r\n"); - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age); + dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID(),c->name,(unsigned long)c->age); ptr = list + dlen; ptrlen = 0; numusers = 0; @@ -1179,7 +1179,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c) if (numusers) buffer.append(list).append("\r\n"); - buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).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++) @@ -1195,7 +1195,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c) if ((params.length() >= MAXMODES) || (currsize > 350)) { /* Wrap at MAXMODES */ - buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n"); + buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n"); modes.clear(); params.clear(); linesize = 1; @@ -1204,7 +1204,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c) /* Only send these if there are any */ if (!modes.empty()) - buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params); + buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params); this->WriteLine(buffer); } @@ -1214,7 +1214,7 @@ void TreeSocket::SendXLines(TreeServer* Current) { char data[MAXBUF]; std::string buffer; - std::string n = this->Instance->Config->ServerName; + std::string n = this->Instance->Config->GetSID(); const char* sn = n.c_str(); /* Yes, these arent too nice looking, but they get the job done */ for (std::vector::iterator i = Instance->XLines->zlines.begin(); i != Instance->XLines->zlines.end(); i++) @@ -1267,7 +1267,7 @@ void TreeSocket::SendChannelModes(TreeServer* Current) { char data[MAXBUF]; std::deque list; - std::string n = this->Instance->Config->ServerName; + std::string n = this->Instance->Config->GetSID(); const char* sn = n.c_str(); Instance->Log(DEBUG,"Sending channels and modes, %d to send", this->Instance->chanlist->size()); for (chan_hash::iterator c = this->Instance->chanlist->begin(); c != this->Instance->chanlist->end(); c++) @@ -1298,17 +1298,23 @@ void TreeSocket::SendUsers(TreeServer* Current) { if (u->second->registered == REG_ALL) { - snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s +%s %s :%s", u->second->server, u->second->uuid, (unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->FormatModes(),u->second->GetIPString(),u->second->fullname); - this->WriteLine(data); - if (*u->second->oper) - { - snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid, u->second->oper); - this->WriteLine(data); - } - if (*u->second->awaymsg) + TreeServer* theirserver = Utils->FindServer(u->second->server); + if (theirserver) { - snprintf(data,MAXBUF,":%s AWAY :%s", u->second->uuid, u->second->awaymsg); + snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s +%s %s :%s", theirserver->GetID(), u->second->uuid, + (unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost, + u->second->ident,u->second->FormatModes(),u->second->GetIPString(),u->second->fullname); this->WriteLine(data); + if (*u->second->oper) + { + snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid, u->second->oper); + this->WriteLine(data); + } + if (*u->second->awaymsg) + { + snprintf(data,MAXBUF,":%s AWAY :%s", u->second->uuid, u->second->awaymsg); + this->WriteLine(data); + } } } } @@ -1338,7 +1344,7 @@ void TreeSocket::DoBurst(TreeServer* s) this->Instance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s).", name.c_str(), this->GetTheirChallenge().empty() ? "plaintext password" : "SHA256-HMAC challenge-response"); this->WriteLine(burst); /* send our version string */ - this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" VERSION :"+this->Instance->GetVersionString()); + this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" VERSION :"+this->Instance->GetVersionString()); /* Send server tree */ this->SendServers(Utils->TreeRoot,s,1); /* Send users and their oper status */ -- cgit v1.2.3