X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Futils.cpp;h=3c4d32c29ac0402e3f61a9a3b2cc6d2b049d2953;hb=bc9352391f179dbe2a325ff36b00930c886ef1b3;hp=c6c9ae700f2c3a3fa269a88f000d41524e9f0b40;hpb=c9d94ba9cd653574ce4aba06d13b130f7a175480;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index c6c9ae700..3c4d32c29 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -2,8 +2,8 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -48,7 +48,7 @@ void ServerSocketListener::OnAcceptReady(const std::string &ipconnectedto, int n if (!found) { - 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; } @@ -154,24 +154,7 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT ServerInstance->Logs->Log("m_spanningtree",DEBUG,"***** Using SID for hash: %s *****", ServerInstance->Config->GetSID().c_str()); this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID()); - - modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook"); - - /* Did we find any modules? */ - if (ml) - { - /* Yes, enumerate them all to find out the hook name */ - for (modulelist::iterator m = ml->begin(); m != ml->end(); m++) - { - /* Make a request to it for its name, its implementing - * BufferedSocketHook so we know its safe to do this - */ - std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send(); - /* Build a map of them */ - hooks[name.c_str()] = *m; - hooknames.push_back(name); - } - } + this->ServerUser = new FakeUser(ServerInstance, TreeRoot->GetID()); this->ReadConfiguration(true); } @@ -194,6 +177,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities() } } delete TreeRoot; + delete ServerUser; ServerInstance->BufferedSocketCull(); } @@ -449,6 +433,30 @@ void SpanningTreeUtilities::RefreshIPCache() void SpanningTreeUtilities::ReadConfiguration(bool rebind) { ConfigReader* Conf = new ConfigReader(ServerInstance); + + /* We don't need to worry about these being *unloaded* on the fly, only loaded, + * because we 'use' the interface locking the module in memory. + */ + hooks.clear(); + hooknames.clear(); + modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook"); + + /* Did we find any modules? */ + if (ml) + { + /* Yes, enumerate them all to find out the hook name */ + for (modulelist::iterator m = ml->begin(); m != ml->end(); m++) + { + /* Make a request to it for its name, its implementing + * BufferedSocketHook so we know its safe to do this + */ + std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send(); + /* Build a map of them */ + hooks[name.c_str()] = *m; + hooknames.push_back(name); + } + } + if (rebind) { for (unsigned int i = 0; i < Bindings.size(); i++) @@ -536,7 +544,9 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) } - L.NextConnectTime = time(NULL) + L.AutoConnect; + // Fix: Only trip autoconnects if this wouldn't delay autoconnect.. + if (L.NextConnectTime > ((time_t)(ServerInstance->Time() + L.AutoConnect))) + L.NextConnectTime = ServerInstance->Time() + L.AutoConnect; if (L.Name.find('.') == std::string::npos) throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character"); @@ -628,7 +638,7 @@ void SpanningTreeUtilities::DoFailOver(Link* x) { 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()); @@ -641,20 +651,20 @@ void SpanningTreeUtilities::DoFailOver(Link* x) } else { - 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->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()); } } } Link* SpanningTreeUtilities::FindLink(const std::string& name) { - for (std::vector::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++) + for (std::vector::iterator x = LinkBlocks.begin(); x != LinkBlocks.end(); x++) { if (InspIRCd::Match(x->Name.c_str(), name.c_str())) {