ps.parentname = s ? s->GetName() : "";
ps.usercount = i->second->UserCount;
ps.opercount = i->second->OperCount;
- ps.gecos = i->second->GetDesc();
+ ps.description = i->second->GetDesc();
ps.latencyms = i->second->rtt;
sl.push_back(ps);
}
}
-bool SpanningTreeProtocolInterface::SendEncapsulatedData(const parameterlist &encap)
+bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source)
{
- CmdBuilder params("ENCAP");
- params.insert(encap);
- if (encap[0].find_first_of("*?") != std::string::npos)
+ if (!source)
+ source = ServerInstance->FakeClient;
+
+ CmdBuilder encap(source, "ENCAP");
+
+ // Are there any wildcards in the target string?
+ if (targetmask.find_first_of("*?") != std::string::npos)
{
- params.Broadcast();
- return true;
+ // Yes, send the target string as-is; servers will decide whether or not it matches them
+ encap.push(targetmask).push(cmd).insert(params).Broadcast();
}
- return params.Unicast(encap[0]);
+ else
+ {
+ // No wildcards which means the target string has to be the name of a known server
+ TreeServer* server = Utils->FindServer(targetmask);
+ if (!server)
+ return false;
+
+ // Use the SID of the target in the message instead of the server name
+ encap.push(server->GetID()).push(cmd).insert(params).Unicast(server->ServerUser);
+ }
+
+ return true;
}
-void SpanningTreeProtocolInterface::SendMetaData(Extensible* target, const std::string &key, const std::string &data)
+void SpanningTreeProtocolInterface::BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source, User* omit)
{
- User* u = dynamic_cast<User*>(target);
- Channel* c = dynamic_cast<Channel*>(target);
- if (u)
- CommandMetadata::Builder(u, key, data).Broadcast();
- else if (c)
- CommandMetadata::Builder(c, key, data).Broadcast();
- else
- CommandMetadata::Builder(key, data).Broadcast();
+ if (!source)
+ source = ServerInstance->FakeClient;
+
+ // If omit is non-NULL we pass the route belonging to the user to Forward(),
+ // otherwise we pass NULL, which is equivalent to Broadcast()
+ TreeServer* server = (omit ? TreeServer::Get(omit)->GetRoute() : NULL);
+ CmdBuilder(source, "ENCAP * ").push_raw(cmd).insert(params).Forward(server);
}
-void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
+void SpanningTreeProtocolInterface::SendMetaData(User* u, const std::string& key, const std::string& data)
{
- CommandFTopic::Builder(ServerInstance->FakeClient, channel).Broadcast();
+ CommandMetadata::Builder(u, key, data).Broadcast();
}
-void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const std::vector<std::string>& modedata, const std::vector<TranslateType>& translate)
+void SpanningTreeProtocolInterface::SendMetaData(Channel* c, const std::string& key, const std::string& data)
{
- if (u)
- {
- if (u->registered != REG_ALL)
- return;
+ CommandMetadata::Builder(c, key, data).Broadcast();
+}
- CmdBuilder params(source, "MODE");
- params.push_back(u->uuid);
- params.insert(modedata);
- params.Broadcast();
- }
- else
- {
- CmdBuilder params(source, "FMODE");
- params.push_back(c->name);
- params.push_back(ConvToStr(c->age));
- params.push_back(CommandParser::TranslateUIDs(translate, modedata));
- params.Broadcast();
- }
+void SpanningTreeProtocolInterface::SendMetaData(const std::string& key, const std::string& data)
+{
+ CommandMetadata::Builder(key, data).Broadcast();
}
-void SpanningTreeProtocolInterface::SendSNONotice(const std::string &snomask, const std::string &text)
+void SpanningTreeProtocolInterface::Server::SendMetaData(const std::string& key, const std::string& data)
{
- CmdBuilder("SNONOTICE").push(snomask).push_last(text).Broadcast();
+ sock->WriteLine(CommandMetadata::Builder(key, data));
}
-void SpanningTreeProtocolInterface::PushToClient(User* target, const std::string &rawline)
+void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::string &text)
{
- CmdBuilder("PUSH").push(target->uuid).push_last(rawline).Unicast(target);
+ CmdBuilder("SNONOTICE").push(snomask).push_last(text).Broadcast();
}
void SpanningTreeProtocolInterface::SendMessage(Channel* target, char status, const std::string& text, MessageType msgtype)
{
const char* cmd = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
CUList exempt_list;
- Utils->SendChannelMessage(ServerInstance->Config->GetSID(), target, text, status, exempt_list, cmd);
+ ClientProtocol::TagMap tags;
+ Utils->SendChannelMessage(ServerInstance->FakeClient, target, text, status, tags, exempt_list, cmd);
}
void SpanningTreeProtocolInterface::SendMessage(User* target, const std::string& text, MessageType msgtype)
{
CmdBuilder p(msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
- p.push_back(target->uuid);
+ p.push(target->uuid);
p.push_last(text);
p.Unicast(target);
}