*/
#include "inspircd.h"
-#include "configreader.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
+bool SpanningTreeUtilities::IsSID(const std::string &str)
+{
+ /* Returns true if the string given is exactly 3 characters long,
+ * starts with a digit, and has no '.' in the other 2
+ */
+ return ((str.length() == 3) && isdigit(str[0]) && (str[1] != '.' && str[2] != '.'));
+}
+
/** Yay for fast searches!
* This is hundreds of times faster than recursion
* or even scanning a linked list, especially when
*/
TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
{
+ if (IsSID(ServerName))
+ return this->FindServerID(ServerName);
+
server_hash::iterator iter = serverlist.find(ServerName.c_str());
if (iter != serverlist.end())
{
return NULL;
}
+TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id)
+{
+ ServerInstance->Log(DEBUG,"Looking for id: %s", id.c_str());
+ server_hash::iterator iter = sidlist.find(id);
+ if (iter != sidlist.end())
+ return iter->second;
+ else
+ return NULL;
+}
+
/* A convenient wrapper that returns true if a server exists */
bool SpanningTreeUtilities::IsServer(const std::string &ServerName)
{
lines_to_apply = 0;
- this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);
+ ServerInstance->Log(DEBUG, "SpanningTreeUtilities: SID: %s", OurSID.c_str());
+
+ this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
modulelist* ml = ServerInstance->FindInterface("InspSocketHook");
{
ServerInstance->SE->DelFd(Bindings[i]);
Bindings[i]->Close();
- DELETE(Bindings[i]);
}
while (TreeRoot->ChildCount())
{
TreeSocket* sock = child_server->GetSocket();
ServerInstance->SE->DelFd(sock);
sock->Close();
- DELETE(sock);
}
}
delete TreeRoot;
+ ServerInstance->InspSocketCull();
}
void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &list)
{
ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port: %s:%d: %s",IP.c_str(), portno, strerror(errno));
listener->Close();
- DELETE(listener);
}
}
}
ChallengeResponse = !Conf->ReadFlag("options", "disablehmac", 0);
quiet_bursts = Conf->ReadFlag("options", "quietbursts", 0);
PingWarnTime = Conf->ReadInteger("options", "pingwarning", 0, true);
+ PingFreq = Conf->ReadInteger("options", "serverpingfreq", 0, true);
+
+ if (PingFreq == 0)
+ PingFreq = 60;
- if (PingWarnTime < 0 || PingWarnTime > 59)
+ if (PingWarnTime < 0 || PingWarnTime > PingFreq - 1)
PingWarnTime = 0;
LinkBlocks.clear();
{
if (x->FailOver == x->Name)
{
- 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());
+ 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());
return;
}
Link* TryThisOne = this->FindLink(x->FailOver.c_str());
if (TryThisOne)
{
- ServerInstance->SNO->WriteToSnoMask('l',"FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
+ Creator->RemoteMessage(NULL,"FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
Creator->ConnectServer(TryThisOne);
}
else
{
- ServerInstance->SNO->WriteToSnoMask('l',"FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
+ Creator->RemoteMessage(NULL,"FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
}
}
}