bool DoOneToOne(std::string prefix, std::string command, std::deque<std::string> params, std::string target);
bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit);
bool DoOneToMany(std::string prefix, std::string command, std::deque<std::string> params);
+bool DoOneToAllButSenderRaw(std::string data,std::string omit);
class TreeServer
{
{
std::deque<std::string> params;
params.push_back(Current->GetName());
- params.push_back(reason);
+ params.push_back(":"+reason);
DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
if (Current->GetParent() == TreeRoot)
{
}
TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
ParentOfThis->AddChild(Node);
+ params[3] = ":" + params[3];
DoOneToAllButSender(prefix,"SERVER",params,prefix);
Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
return true;
return false;
}
- std::deque<std::string> Split(std::string line)
+ std::deque<std::string> Split(std::string line, bool stripcolon)
{
std::deque<std::string> n;
std::stringstream s(line);
bool ProcessLine(std::string line)
{
Srv->Log(DEBUG,"inbound-line: '"+line+"'");
-
- std::deque<std::string> params = this->Split(line);
+ std::deque<std::string> params = this->Split(line,true);
std::string command = "";
std::string prefix = "";
if (((params[0].c_str())[0] == ':') && (params.size() > 1))
params.push_back(InboundServerName);
params.push_back("*");
params.push_back("1");
- params.push_back(InboundDescription);
+ params.push_back(":"+InboundDescription);
DoOneToAllButSender(TreeRoot->GetName(),"SERVER",params,InboundServerName);
this->DoBurst(Node);
}
return true;
}
}
- return DoOneToAllButSender(prefix,command,params,sourceserv);
+ return DoOneToAllButSenderRaw(line,sourceserv);
}
return true;
{
std::deque<std::string> params;
params.push_back(quitserver);
- params.push_back("Remote host closed the connection");
+ params.push_back(":Remote host closed the connection");
DoOneToAllButSender(Srv->GetServerName(),"SQUIT",params,quitserver);
Squit(s,"Remote host closed the connection");
}
}
};
+bool DoOneToAllButSenderRaw(std::string data,std::string omit)
+{
+ for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
+ {
+ TreeServer* Route = TreeRoot->GetChild(x);
+ if ((Route->GetSocket()) && (Route->GetName() != omit) && (BestRouteTo(omit) != Route))
+ {
+ TreeSocket* Sock = Route->GetSocket();
+ log(DEBUG,"Sending RAW to %s",Route->GetName().c_str());
+ Sock->WriteLine(data);
+ }
+ }
+ return true;
+}
+
bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit)
{
log(DEBUG,"ALLBUTONE: Comes from %s SHOULD NOT go back to %s",prefix.c_str(),omit.c_str());
std::string FullLine = ":" + prefix + " " + command;
for (unsigned int x = 0; x < params.size(); x++)
{
- if (!strchr(params[x].c_str(),' '))
- {
- FullLine = FullLine + " " + params[x];
- }
- else
- {
- FullLine = FullLine + " :" + params[x];
- }
+ FullLine = FullLine + " " + params[x];
}
for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
{
std::string FullLine = ":" + prefix + " " + command;
for (unsigned int x = 0; x < params.size(); x++)
{
- if (!strchr(params[x].c_str(),' '))
- {
- FullLine = FullLine + " " + params[x];
- }
- else
- {
- FullLine = FullLine + " :" + params[x];
- }
+ FullLine = FullLine + " " + params[x];
}
for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
{
std::string FullLine = ":" + prefix + " " + command;
for (unsigned int x = 0; x < params.size(); x++)
{
- if (!strchr(params[x].c_str(),' '))
- {
- FullLine = FullLine + " " + params[x];
- }
- else
- {
- FullLine = FullLine + " :" + params[x];
- }
+ FullLine = FullLine + " " + params[x];
}
if (Route->GetSocket())
{
return 0;
}
+ virtual void OnUserNotice(userrec* user, void* dest, int target_type, std::string text)
+ {
+ if (target_type == TYPE_USER)
+ {
+ userrec* d = (userrec*)dest;
+ if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
+ {
+ std::deque<std::string> params;
+ params.clear();
+ params.push_back(d->nick);
+ params.push_back(":"+text);
+ DoOneToOne(user->nick,"NOTICE",params,d->server);
+ }
+ }
+ else
+ {
+ if (std::string(user->server) == Srv->GetServerName())
+ {
+ chanrec *c = (chanrec*)dest;
+ std::deque<std::string> params;
+ params.push_back(c->name);
+ params.push_back(":"+text);
+ DoOneToMany(user->nick,"NOTICE",params);
+ }
+ }
+ }
+
virtual void OnUserMessage(userrec* user, void* dest, int target_type, std::string text)
{
if (target_type == TYPE_USER)
std::deque<std::string> params;
params.clear();
params.push_back(d->nick);
- params.push_back(text);
+ params.push_back(":"+text);
DoOneToOne(user->nick,"PRIVMSG",params,d->server);
}
}
chanrec *c = (chanrec*)dest;
std::deque<std::string> params;
params.push_back(c->name);
- params.push_back(text);
+ params.push_back(":"+text);
DoOneToMany(user->nick,"PRIVMSG",params);
}
}