Can be a useful distinction for bigger networks or networks with more distinction on what people can and cannot see.
This also makes RemoteMessage more match it's docs and removes useless redundancy.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10759
e03df62e-2008-0410-955e-
edbf42e46eb7
if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
{
if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
{
- RemoteMessage(NULL, "CONNECT: Not connecting to myself.");
+ this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
- RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+ this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
ServerInstance->SocketCull[newsocket] = newsocket;
Utils->DoFailOver(x);
if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
ServerInstance->SocketCull[newsocket] = newsocket;
Utils->DoFailOver(x);
}
catch (ModuleException& e)
{
}
catch (ModuleException& e)
{
- RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
Utils->DoFailOver(x);
}
}
Utils->DoFailOver(x);
}
}
-/* This method will attempt to get a link message out to as many people as is required.
- * If a user is provided, and that user is local, then the user is sent the message using
- * WriteServ (they are the local initiator of that message). If the user is remote, they are
- * sent that message remotely via PUSH.
- * If the user is NULL, then the notice is sent locally via WriteToSnoMask with snomask 'l',
- * and remotely via SNONOTICE with mask 'l'.
+/* This method will attempt to get a message to a remote user.
*/
void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...)
{
*/
void ModuleSpanningTree::RemoteMessage(User* 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;
-
char text[MAXBUF];
va_list argsPtr;
char text[MAXBUF];
va_list argsPtr;
vsnprintf(text, MAXBUF, format, argsPtr);
va_end(argsPtr);
vsnprintf(text, MAXBUF, format, argsPtr);
va_end(argsPtr);
- if (!user)
- {
- /* No user, target it generically at everyone */
- ServerInstance->SNO->WriteToSnoMask('l', "%s", text);
- }
+ if (IS_LOCAL(user))
+ user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text);
- {
- if (IS_LOCAL(user))
- user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text);
- else
- ServerInstance->PI->SendUserNotice(user, text);
- }
-
- SendingRemoteMessage = false;
+ ServerInstance->PI->SendUserNotice(user, text);
}
int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
}
int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
else
{
/* Something barfed, show the opers */
else
{
/* Something barfed, show the opers */
- Utils->Creator->RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
+ ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
ServerInstance->SocketCull[newsocket] = newsocket;
Utils->DoFailOver(&MyLink);
if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
ServerInstance->SocketCull[newsocket] = newsocket;
Utils->DoFailOver(&MyLink);
ServerInstance->AddResolver(snr, cached);
return;
}
ServerInstance->AddResolver(snr, cached);
return;
}
- Utils->Creator->RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s", MyLink.Name.c_str(), errormessage.c_str() );
+ ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s", MyLink.Name.c_str(), errormessage.c_str() );
Utils->DoFailOver(&MyLink);
}
Utils->DoFailOver(&MyLink);
}
{
if (x->Name == this->myhost)
{
{
if (x->Name == this->myhost)
{
- Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()));
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()));
if (Hook)
{
BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
if (Hook)
{
BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
- Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()),
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()),
x->Hook.c_str());
}
this->OutboundPass = x->SendPass;
x->Hook.c_str());
}
this->OutboundPass = x->SendPass;
* If that happens the connection hangs here until it's closed. Unlikely
* and rather harmless.
*/
* If that happens the connection hangs here until it's closed. Unlikely
* and rather harmless.
*/
- this->Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2 lost link tag(!)", myhost.c_str());
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2 lost link tag(!)", myhost.c_str());
switch (e)
{
case I_ERR_CONNECT:
switch (e)
{
case I_ERR_CONNECT:
- Utils->Creator->RemoteMessage(NULL,"Connection failed: Connection to \002%s\002 refused", myhost.c_str());
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Connection to \002%s\002 refused", myhost.c_str());
MyLink = Utils->FindLink(myhost);
if (MyLink)
Utils->DoFailOver(MyLink);
break;
case I_ERR_SOCKET:
MyLink = Utils->FindLink(myhost);
if (MyLink)
Utils->DoFailOver(MyLink);
break;
case I_ERR_SOCKET:
- Utils->Creator->RemoteMessage(NULL,"Connection failed: Could not create socket (%s)", strerror(errno));
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Could not create socket (%s)", strerror(errno));
- Utils->Creator->RemoteMessage(NULL,"Connection failed: Error binding socket to address or port (%s)", strerror(errno));
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Error binding socket to address or port (%s)", strerror(errno));
- Utils->Creator->RemoteMessage(NULL,"Connection failed: I/O error on connection (%s)", errno ? strerror(errno) : "Connection closed unexpectedly");
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: I/O error on connection (%s)", errno ? strerror(errno) : "Connection closed unexpectedly");
break;
case I_ERR_NOMOREFDS:
break;
case I_ERR_NOMOREFDS:
- Utils->Creator->RemoteMessage(NULL,"Connection failed: Operating system is out of file descriptors!");
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Operating system is out of file descriptors!");
break;
default:
if ((errno) && (errno != EINPROGRESS) && (errno != EAGAIN))
break;
default:
if ((errno) && (errno != EINPROGRESS) && (errno != EAGAIN))
- Utils->Creator->RemoteMessage(NULL,"Connection to \002%s\002 failed with OS error: %s", myhost.c_str(), strerror(errno));
+ ServerInstance->SNO->WriteToSnoMask('l', "Connection to \002%s\002 failed with OS error: %s", myhost.c_str(), strerror(errno));
void TreeSocket::SendError(const std::string &errormessage)
{
/* Display the error locally as well as sending it remotely */
void TreeSocket::SendError(const std::string &errormessage)
{
/* Display the error locally as well as sending it remotely */
- Utils->Creator->RemoteMessage(NULL, "Sent \2ERROR\2 to %s: %s", (this->InboundServerName.empty() ? this->GetIP().c_str() : this->InboundServerName.c_str()), errormessage.c_str());
+ ServerInstance->SNO->WriteToSnoMask('l', "Sent \2ERROR\2 to %s: %s", (this->InboundServerName.empty() ? this->GetIP().c_str() : this->InboundServerName.c_str()), errormessage.c_str());
this->WriteLine("ERROR :"+errormessage);
/* One last attempt to make sure the error reaches its target */
this->FlushWriteBuffer();
this->WriteLine("ERROR :"+errormessage);
/* One last attempt to make sure the error reaches its target */
this->FlushWriteBuffer();
*/
void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
{
*/
void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
{
+ bool LocalSquit = false;
+
if ((Current) && (Current != Utils->TreeRoot))
{
Event rmode((char*)Current->GetName().c_str(), (Module*)Utils->Creator, "lost_server");
if ((Current) && (Current != Utils->TreeRoot))
{
Event rmode((char*)Current->GetName().c_str(), (Module*)Utils->Creator, "lost_server");
Utils->DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
if (Current->GetParent() == Utils->TreeRoot)
{
Utils->DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
if (Current->GetParent() == Utils->TreeRoot)
{
- this->ServerInstance->SNO->WriteToSnoMask('l',"Server \002"+Current->GetName()+"\002 split: "+reason);
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Server \002"+Current->GetName()+"\002 split: "+reason);
+ LocalSquit = true;
- this->ServerInstance->SNO->WriteToSnoMask('l',"Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+ this->ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
}
num_lost_servers = 0;
num_lost_users = 0;
}
num_lost_servers = 0;
num_lost_users = 0;
Current->Tidy();
Current->GetParent()->DelChild(Current);
delete Current;
Current->Tidy();
Current->GetParent()->DelChild(Current);
delete Current;
- this->ServerInstance->SNO->WriteToSnoMask('l',"Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+ if (LocalSquit)
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+ else
+ this->ServerInstance->SNO->WriteToSnoMask('L', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
}
else
ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Squit from unknown server");
}
else
ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Squit from unknown server");
{
if (this->LinkState == CONNECTING)
{
{
if (this->LinkState == CONNECTING)
{
- Utils->Creator->RemoteMessage(NULL, "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
Link* MyLink = Utils->FindLink(myhost);
if (MyLink)
Utils->DoFailOver(MyLink);
Link* MyLink = Utils->FindLink(myhost);
if (MyLink)
Utils->DoFailOver(MyLink);
if (!quitserver.empty())
{
if (!quitserver.empty())
{
- Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' failed.",quitserver.c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' failed.",quitserver.c_str());
+
time_t server_uptime = ServerInstance->Time() - this->age;
if (server_uptime)
time_t server_uptime = ServerInstance->Time() - this->age;
if (server_uptime)
- Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
- Utils->Creator->RemoteMessage(NULL,"Server connection from %s denied (no link blocks with that IP address)", ip);
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
ServerInstance->SE->Close(newsock);
return;
}
ServerInstance->SE->Close(newsock);
return;
}
{
if (x->FailOver == x->Name)
{
{
if (x->FailOver == x->Name)
{
- Creator->RemoteMessage(NULL,"FAILOVER: Some muppet configured the failover for server \002%s\002 to point at itself. Not following it!", x->Name.c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Some muppet configured the failover for server \002%s\002 to point at itself. Not following it!", x->Name.c_str());
return;
}
Link* TryThisOne = this->FindLink(x->FailOver.c_str());
return;
}
Link* TryThisOne = this->FindLink(x->FailOver.c_str());
- Creator->RemoteMessage(NULL,"FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
Creator->ConnectServer(TryThisOne);
}
}
else
{
Creator->ConnectServer(TryThisOne);
}
}
else
{
- Creator->RemoteMessage(NULL,"FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
+ this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
this->EnableSnomask('k',"KILL"); /* Kill notices */
this->EnableSnomask('K',"REMOTEKILL"); /* Remote kill notices */
this->EnableSnomask('l',"LINK"); /* Link notices */
this->EnableSnomask('k',"KILL"); /* Kill notices */
this->EnableSnomask('K',"REMOTEKILL"); /* Remote kill notices */
this->EnableSnomask('l',"LINK"); /* Link notices */
+ this->EnableSnomask('L',"REMOTELINK"); /* Link notices */
this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
this->EnableSnomask('A',"ANNOUNCEMENT"); /* formerly WriteOpers() - generic notices to all opers */
this->EnableSnomask('d',"DEBUG"); /* Debug notices */
this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
this->EnableSnomask('A',"ANNOUNCEMENT"); /* formerly WriteOpers() - generic notices to all opers */
this->EnableSnomask('d',"DEBUG"); /* Debug notices */