summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/main.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-19 17:43:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-19 17:43:50 +0000
commita17174ec0aeeffc1236d0ddbcf6a63f56205acea (patch)
treebe61dc2a7ef2650f0276b0085bc14cb4b453807e /src/modules/m_spanningtree/main.cpp
parent5e0830de3d8e99bbf391f23c359febe429d604ba (diff)
Split this up even more, much smaller files that are easier for gcc to digest
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6395 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree/main.cpp')
-rw-r--r--src/modules/m_spanningtree/main.cpp85
1 files changed, 2 insertions, 83 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 83a6b4e19..0ddb6b291 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -25,6 +25,8 @@
#include "xline.h"
#include "transport.h"
+#include "m_spanningtree/timesynctimer.h"
+#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
#include "m_spanningtree/utils.h"
#include "m_spanningtree/treeserver.h"
@@ -72,79 +74,6 @@ class cmd_rconnect : public command_t
}
};
-/** This class is used to resolve server hostnames during /connect and autoconnect.
- * As of 1.1, the resolver system is seperated out from InspSocket, so we must do this
- * resolver step first ourselves if we need it. This is totally nonblocking, and will
- * callback to OnLookupComplete or OnError when completed. Once it has completed we
- * will have an IP address which we can then use to continue our connection.
- */
-class ServernameResolver : public Resolver
-{
- private:
- /** A copy of the Link tag info for what we're connecting to.
- * We take a copy, rather than using a pointer, just in case the
- * admin takes the tag away and rehashes while the domain is resolving.
- */
- Link MyLink;
- SpanningTreeUtilities* Utils;
- public:
- ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(Util)
- {
- /* Nothing in here, folks */
- }
-
- void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
- {
- /* Initiate the connection, now that we have an IP to use.
- * Passing a hostname directly to InspSocket causes it to
- * just bail and set its FD to -1.
- */
- TreeServer* CheckDupe = Utils->FindServer(MyLink.Name.c_str());
- if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */
- {
-
- if ((!MyLink.Hook.empty()) && (Utils->hooks.find(MyLink.Hook.c_str()) == Utils->hooks.end()))
- return;
-
- TreeSocket* newsocket = new TreeSocket(this->Utils, ServerInstance, result,MyLink.Port,false,MyLink.Timeout ? MyLink.Timeout : 10,MyLink.Name.c_str(),
- MyLink.Hook.empty() ? NULL : Utils->hooks[MyLink.Hook.c_str()]);
- if (newsocket->GetFd() > -1)
- {
- /* We're all OK */
- }
- else
- {
- /* Something barfed, show the opers */
- ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
- delete newsocket;
- Utils->DoFailOver(&MyLink);
- }
- }
- }
-
- void OnError(ResolverError e, const std::string &errormessage)
- {
- /* Ooops! */
- 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);
- }
-};
-
-/** Create a timer which recurs every second, we inherit from InspTimer.
- * InspTimer is only one-shot however, so at the end of each Tick() we simply
- * insert another of ourselves into the pending queue :)
- */
-class TimeSyncTimer : public InspTimer
-{
- private:
- InspIRCd *Instance;
- ModuleSpanningTree *Module;
- public:
- TimeSyncTimer(InspIRCd *Instance, ModuleSpanningTree *Mod);
- virtual void Tick(time_t TIME);
-};
-
-
ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
: Module::Module(Me), max_local(0), max_global(0)
{
@@ -1360,16 +1289,6 @@ Priority ModuleSpanningTree::Prioritize()
return PRIORITY_LAST;
}
-TimeSyncTimer::TimeSyncTimer(InspIRCd *Inst, ModuleSpanningTree *Mod) : InspTimer(43200, Inst->Time(), true), Instance(Inst), Module(Mod)
-{
-}
-
-void TimeSyncTimer::Tick(time_t TIME)
-{
- Module->BroadcastTimeSync();
-}
-
-
class ModuleSpanningTreeFactory : public ModuleFactory
{
public: