From e950f568d0f571e9475aa38177486468714de4d3 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 15 Aug 2013 16:15:26 +0200 Subject: m_spanningtree Remove SpanningTreeUtilities* fields and parameters --- src/modules/m_spanningtree/cachetimer.h | 6 +----- src/modules/m_spanningtree/commands.h | 6 ++---- src/modules/m_spanningtree/fjoin.cpp | 2 -- src/modules/m_spanningtree/ijoin.cpp | 2 -- src/modules/m_spanningtree/main.cpp | 9 +++++---- src/modules/m_spanningtree/main.h | 2 -- src/modules/m_spanningtree/opertype.cpp | 1 - src/modules/m_spanningtree/rconnect.cpp | 4 ++-- src/modules/m_spanningtree/resolvers.cpp | 20 +++++++++++--------- src/modules/m_spanningtree/resolvers.h | 6 ++---- src/modules/m_spanningtree/rsquit.cpp | 4 ++-- src/modules/m_spanningtree/server.cpp | 4 ++-- src/modules/m_spanningtree/treeserver.cpp | 10 +++++----- src/modules/m_spanningtree/treeserver.h | 5 ++--- src/modules/m_spanningtree/treesocket.h | 5 ++--- src/modules/m_spanningtree/treesocket1.cpp | 9 +++++---- src/modules/m_spanningtree/treesocket2.cpp | 2 +- src/modules/m_spanningtree/uid.cpp | 1 - src/modules/m_spanningtree/utils.cpp | 9 +++++---- src/modules/m_spanningtree/utils.h | 2 ++ 20 files changed, 49 insertions(+), 60 deletions(-) diff --git a/src/modules/m_spanningtree/cachetimer.h b/src/modules/m_spanningtree/cachetimer.h index ab6dcdf09..89933cc4b 100644 --- a/src/modules/m_spanningtree/cachetimer.h +++ b/src/modules/m_spanningtree/cachetimer.h @@ -19,17 +19,13 @@ #pragma once -class SpanningTreeUtilities; - /** Create a timer which recurs every second, we inherit from Timer. * Timer is only one-shot however, so at the end of each Tick() we simply * insert another of ourselves into the pending queue :) */ class CacheRefreshTimer : public Timer { - private: - SpanningTreeUtilities *Utils; public: - CacheRefreshTimer(SpanningTreeUtilities* Util); + CacheRefreshTimer(); bool Tick(time_t TIME); }; diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index dd54b5b6b..44f26ae6c 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -25,18 +25,16 @@ */ class CommandRConnect : public Command { - SpanningTreeUtilities* Utils; /* Utility class */ public: - CommandRConnect (Module* Callback, SpanningTreeUtilities* Util); + CommandRConnect(Module* Creator); CmdResult Handle (const std::vector& parameters, User *user); RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; class CommandRSQuit : public Command { - SpanningTreeUtilities* Utils; /* Utility class */ public: - CommandRSQuit(Module* Callback, SpanningTreeUtilities* Util); + CommandRSQuit(Module* Creator); CmdResult Handle (const std::vector& parameters, User *user); RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 37683a440..21327581a 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -28,7 +28,6 @@ /** FJOIN, almost identical to TS6 SJOIN, except for nicklist handling. */ CmdResult CommandFJoin::Handle(const std::vector& params, User *srcuser) { - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; /* 1.1+ FJOIN works as follows: * * Each FJOIN is sent along with a timestamp, and the side with the lowest @@ -167,7 +166,6 @@ bool CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_ } /* Check that the user's 'direction' is correct */ - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; TreeServer* route_back_again = Utils->BestRouteTo(who->server); if ((!route_back_again) || (route_back_again->GetSocket() != src_socket)) { diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index ce4f4668b..8185216d3 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -34,7 +34,6 @@ CmdResult CommandIJoin::HandleRemote(const std::vector& params, Rem parameterlist p; p.push_back(params[0]); - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; Utils->DoOneToOne(ServerInstance->Config->GetSID(), "RESYNC", p, user->server); return CMD_FAILURE; @@ -75,7 +74,6 @@ CmdResult CommandResync::HandleServer(const std::vector& params, Fa return CMD_FAILURE; } - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; TreeServer* server = Utils->FindServer(user->server); if (!server) return CMD_FAILURE; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 59e17f88e..a49383523 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -36,12 +36,12 @@ #include "protocolinterface.h" ModuleSpanningTree::ModuleSpanningTree() - : commands(NULL), DNS(this, "DNS"), Utils(NULL) + : commands(NULL), DNS(this, "DNS") { } SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module) - : rconnect(module, module->Utils), rsquit(module, module->Utils), + : rconnect(module), rsquit(module), svsjoin(module), svspart(module), svsnick(module), metadata(module), uid(module), opertype(module), fjoin(module), ijoin(module), resync(module), fmode(module), ftopic(module), fhost(module), fident(module), fname(module) @@ -53,6 +53,7 @@ void ModuleSpanningTree::init() ServerInstance->SNO->EnableSnomask('l', "LINK"); Utils = new SpanningTreeUtilities(this); + Utils->TreeRoot = new TreeServer; commands = new SpanningTreeCommands(this); ServerInstance->Modules->AddService(commands->rconnect); ServerInstance->Modules->AddService(commands->rsquit); @@ -275,7 +276,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) if (ipvalid) { /* Gave a hook, but it wasnt one we know */ - TreeSocket* newsocket = new TreeSocket(Utils, x, y, x->IPAddr); + TreeSocket* newsocket = new TreeSocket(x, y, x->IPAddr); if (newsocket->GetFd() > -1) { /* Handled automatically on success */ @@ -293,7 +294,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) } else { - ServernameResolver* snr = new ServernameResolver(Utils, *DNS, x->IPAddr, x, start_type, y); + ServernameResolver* snr = new ServernameResolver(*DNS, x->IPAddr, x, start_type, y); try { DNS->Process(snr); diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 28ebbc373..07b0762e5 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -57,8 +57,6 @@ class ModuleSpanningTree : public Module public: dynamic_reference DNS; - SpanningTreeUtilities* Utils; - /** Set to true if inside a spanningtree call, to prevent sending * xlines and other things back to their source */ diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index 6402b89dc..835448503 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -28,7 +28,6 @@ */ CmdResult CommandOpertype::Handle(const std::vector& params, User *u) { - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; const std::string& opertype = params[0]; if (!u->IsOper()) ServerInstance->Users->all_opers.push_back(u); diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 7398f6e9a..c5d3a5b52 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -24,8 +24,8 @@ #include "utils.h" #include "commands.h" -CommandRConnect::CommandRConnect (Module* Creator, SpanningTreeUtilities* Util) - : Command(Creator, "RCONNECT", 2), Utils(Util) +CommandRConnect::CommandRConnect (Module* Creator) + : Command(Creator, "RCONNECT", 2) { flags_needed = 'o'; syntax = " "; diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp index 6c0830ac7..80e8aeb0e 100644 --- a/src/modules/m_spanningtree/resolvers.cpp +++ b/src/modules/m_spanningtree/resolvers.cpp @@ -34,8 +34,9 @@ * 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. */ -ServernameResolver::ServernameResolver(SpanningTreeUtilities* Util, DNS::Manager *mgr, const std::string &hostname, Link* x, DNS::QueryType qt, Autoconnect* myac) - : DNS::Request(mgr, Util->Creator, hostname, qt), Utils(Util), query(qt), host(hostname), MyLink(x), myautoconnect(myac) +ServernameResolver::ServernameResolver(DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt, Autoconnect* myac) + : DNS::Request(mgr, Utils->Creator, hostname, qt) + , query(qt), host(hostname), MyLink(x), myautoconnect(myac) { } @@ -50,7 +51,7 @@ void ServernameResolver::OnLookupComplete(const DNS::Query *r) TreeServer* CheckDupe = Utils->FindServer(MyLink->Name.c_str()); if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */ { - TreeSocket* newsocket = new TreeSocket(Utils, MyLink, myautoconnect, ans_record.rdata); + TreeSocket* newsocket = new TreeSocket(MyLink, myautoconnect, ans_record.rdata); if (newsocket->GetFd() > -1) { /* We're all OK */ @@ -70,7 +71,7 @@ void ServernameResolver::OnError(const DNS::Query *r) /* Ooops! */ if (query == DNS::QUERY_AAAA) { - ServernameResolver* snr = new ServernameResolver(Utils, this->manager, host, MyLink, DNS::QUERY_A, myautoconnect); + ServernameResolver* snr = new ServernameResolver(this->manager, host, MyLink, DNS::QUERY_A, myautoconnect); try { this->manager->Process(snr); @@ -86,8 +87,9 @@ void ServernameResolver::OnError(const DNS::Query *r) Utils->Creator->ConnectServer(myautoconnect, false); } -SecurityIPResolver::SecurityIPResolver(Module* me, SpanningTreeUtilities* U, DNS::Manager *mgr, const std::string &hostname, Link* x, DNS::QueryType qt) - : DNS::Request(mgr, me, hostname, qt), MyLink(x), Utils(U), mine(me), host(hostname), query(qt) +SecurityIPResolver::SecurityIPResolver(Module* me, DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt) + : DNS::Request(mgr, me, hostname, qt) + , MyLink(x), mine(me), host(hostname), query(qt) { } @@ -110,7 +112,7 @@ void SecurityIPResolver::OnError(const DNS::Query *r) { if (query == DNS::QUERY_AAAA) { - SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, this->manager, host, MyLink, DNS::QUERY_A); + SecurityIPResolver* res = new SecurityIPResolver(mine, this->manager, host, MyLink, DNS::QUERY_A); try { this->manager->Process(res); @@ -125,8 +127,8 @@ void SecurityIPResolver::OnError(const DNS::Query *r) MyLink->Name.c_str(), this->manager->GetErrorStr(r->error).c_str()); } -CacheRefreshTimer::CacheRefreshTimer(SpanningTreeUtilities* Util) - : Timer(3600, ServerInstance->Time(), true), Utils(Util) +CacheRefreshTimer::CacheRefreshTimer() + : Timer(3600, ServerInstance->Time(), true) { } diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h index 249414617..782ac86ef 100644 --- a/src/modules/m_spanningtree/resolvers.h +++ b/src/modules/m_spanningtree/resolvers.h @@ -32,12 +32,11 @@ class SecurityIPResolver : public DNS::Request { private: reference MyLink; - SpanningTreeUtilities* Utils; Module* mine; std::string host; DNS::QueryType query; public: - SecurityIPResolver(Module* me, SpanningTreeUtilities* U, DNS::Manager *mgr, const std::string &hostname, Link* x, DNS::QueryType qt); + SecurityIPResolver(Module* me, DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt); void OnLookupComplete(const DNS::Query *r) CXX11_OVERRIDE; void OnError(const DNS::Query *q) CXX11_OVERRIDE; }; @@ -51,13 +50,12 @@ class SecurityIPResolver : public DNS::Request class ServernameResolver : public DNS::Request { private: - SpanningTreeUtilities* Utils; DNS::QueryType query; std::string host; reference MyLink; reference myautoconnect; public: - ServernameResolver(SpanningTreeUtilities* Util, DNS::Manager *mgr, const std::string &hostname, Link* x, DNS::QueryType qt, Autoconnect* myac); + ServernameResolver(DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt, Autoconnect* myac); void OnLookupComplete(const DNS::Query *r) CXX11_OVERRIDE; void OnError(const DNS::Query *q) CXX11_OVERRIDE; }; diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index be658120b..9437c174a 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -24,8 +24,8 @@ #include "treeserver.h" #include "commands.h" -CommandRSQuit::CommandRSQuit (Module* Creator, SpanningTreeUtilities* Util) - : Command(Creator, "RSQUIT", 1), Utils(Util) +CommandRSQuit::CommandRSQuit(Module* Creator) + : Command(Creator, "RSQUIT", 1) { flags_needed = 'o'; syntax = " [reason]"; diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index f4be16625..aebc16568 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -72,7 +72,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist ¶ms) Link* lnk = Utils->FindLink(servername); - TreeServer *Node = new TreeServer(Utils, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); + TreeServer *Node = new TreeServer(servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); ParentOfThis->AddChild(Node); params[4] = ":" + params[4]; @@ -149,7 +149,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist ¶ms) Utils->timeoutlist.erase(this); linkID = sname; - MyRoot = new TreeServer(Utils, sname, description, sid, Utils->TreeRoot, this, x->Hidden); + MyRoot = new TreeServer(sname, description, sid, Utils->TreeRoot, this, x->Hidden); Utils->TreeRoot->AddChild(MyRoot); this->DoBurst(MyRoot); diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 8da5a2bd5..fe7dbe170 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -32,9 +32,9 @@ * represents our own server. Therefore, it has no route, no parent, and * no socket associated with it. Its version string is our own local version. */ -TreeServer::TreeServer(SpanningTreeUtilities* Util) +TreeServer::TreeServer() : Parent(NULL), Route(NULL), ServerName(ServerInstance->Config->ServerName), ServerDesc(ServerInstance->Config->ServerDesc) - , VersionString(ServerInstance->GetVersionString()), Socket(NULL), Utils(Util), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient) + , VersionString(ServerInstance->GetVersionString()), Socket(NULL), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(false) { AddHashEntry(); @@ -44,8 +44,8 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util) * This constructor initializes the server's Route and Parent, and sets up * its ping counters so that it will be pinged one minute from now. */ -TreeServer::TreeServer(SpanningTreeUtilities* Util, const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) - : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock), Utils(Util), sid(id), ServerUser(new FakeUser(id, Name)) +TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) + : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock), sid(id), ServerUser(new FakeUser(id, Name)) , age(ServerInstance->Time()), Warned(false), bursting(true), UserCount(0), OperCount(0), rtt(0), Hidden(Hide) { SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); @@ -153,7 +153,7 @@ int TreeServer::QuitUsers(const std::string &reason) User* a = (User*)*n; if (!IS_LOCAL(a)) { - if (this->Utils->quiet_bursts) + if (Utils->quiet_bursts) a->quietquit = true; if (ServerInstance->Config->HideSplits) diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index a579d2fc7..7792f2191 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -48,7 +48,6 @@ class TreeServer : public classbase TreeSocket* Socket; /* For directly connected servers this points at the socket object */ time_t NextPing; /* After this time, the server should be PINGed*/ bool LastPingWasGood; /* True if the server responded to the last PING with a PONG */ - SpanningTreeUtilities* Utils; /* Utility class */ std::string sid; /* Server ID */ /** This method is used to add this TreeServer to the @@ -70,13 +69,13 @@ class TreeServer : public classbase * represents our own server. Therefore, it has no route, no parent, and * no socket associated with it. Its version string is our own local version. */ - TreeServer(SpanningTreeUtilities* Util); + TreeServer(); /** When we create a new server, we call this constructor to initialize it. * This constructor initializes the server's Route and Parent, and sets up * its ping counters so that it will be pinged one minute from now. */ - TreeServer(SpanningTreeUtilities* Util, const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide); + TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide); int QuitUsers(const std::string &reason); diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index ded03d6ca..ba22e2841 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -89,7 +89,6 @@ struct CapabData */ class TreeSocket : public BufferedSocket { - SpanningTreeUtilities* Utils; /* Utility class */ std::string linkID; /* Description for this link */ ServerState LinkState; /* Link state */ CapabData* capab; /* Link setup data (held until burst is sent) */ @@ -111,13 +110,13 @@ class TreeSocket : public BufferedSocket * most of the action, and append a few of our own values * to it. */ - TreeSocket(SpanningTreeUtilities* Util, Link* link, Autoconnect* myac, const std::string& ipaddr); + TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr); /** When a listening socket gives us a new file descriptor, * we must associate it with a socket without creating a new * connection. This constructor is used for this purpose. */ - TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); + TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); /** Get link state */ diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 1c72f3ad7..e2afe6421 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -35,8 +35,8 @@ * most of the action, and append a few of our own values * to it. */ -TreeSocket::TreeSocket(SpanningTreeUtilities* Util, Link* link, Autoconnect* myac, const std::string& ipaddr) - : Utils(Util), linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0), ConnectionFailureShown(false) +TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr) + : linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0), ConnectionFailureShown(false) , age(ServerInstance->Time()) { capab = new CapabData; @@ -62,8 +62,9 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, Link* link, Autoconnect* mya * we must associate it with a socket without creating a new * connection. This constructor is used for this purpose. */ -TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) - : BufferedSocket(newfd), Utils(Util), linkID("inbound from " + client->addr()), LinkState(WAIT_AUTH_1), MyRoot(NULL), proto_version(0) +TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) + : BufferedSocket(newfd) + , linkID("inbound from " + client->addr()), LinkState(WAIT_AUTH_1), MyRoot(NULL), proto_version(0) , ConnectionFailureShown(false), age(ServerInstance->Time()) { capab = new CapabData; diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 070c003cc..f2ea0808f 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -172,7 +172,7 @@ void TreeSocket::ProcessLine(std::string &line) linkID = capab->name; - MyRoot = new TreeServer(Utils, capab->name, capab->description, capab->sid, Utils->TreeRoot, this, capab->hidden); + MyRoot = new TreeServer(capab->name, capab->description, capab->sid, Utils->TreeRoot, this, capab->hidden); Utils->TreeRoot->AddChild(MyRoot); MyRoot->bursting = true; diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index cc583bd33..a24d44e53 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -27,7 +27,6 @@ CmdResult CommandUID::Handle(const parameterlist ¶ms, User* serversrc) { - SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; /** Do we have enough parameters: * 0 1 2 3 4 5 6 7 8 9 (n-1) * UID uuid age nick host dhost ident ip.string signon +modes (modepara) :gecos diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 79cd74505..5330d2eb3 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -28,6 +28,8 @@ #include "treesocket.h" #include "resolvers.h" +SpanningTreeUtilities* Utils = NULL; + /* Create server sockets off a listener. */ ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) { @@ -41,7 +43,7 @@ ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from if (*i == "*" || *i == incomingip || irc::sockets::cidr_mask(*i).match(*client)) { /* we don't need to do anything with the pointer, creating it stores it in the necessary places */ - new TreeSocket(Utils, newsock, from, client, server); + new TreeSocket(newsock, from, client, server); return MOD_RES_ALLOW; } } @@ -127,11 +129,10 @@ TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id) } SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) - : RefreshTimer(this), Creator(C) + : Creator(C), TreeRoot(NULL) { ServerInstance->Timers->AddTimer(&RefreshTimer); - this->TreeRoot = new TreeServer(this); this->ReadConfiguration(); } @@ -288,7 +289,7 @@ void SpanningTreeUtilities::RefreshIPCache() ValidIPs.push_back(L->IPAddr); else if (this->Creator->DNS) { - SecurityIPResolver* sr = new SecurityIPResolver(Creator, this, *this->Creator->DNS, L->IPAddr, L, DNS::QUERY_AAAA); + SecurityIPResolver* sr = new SecurityIPResolver(Creator, *this->Creator->DNS, L->IPAddr, L, DNS::QUERY_AAAA); try { this->Creator->DNS->Process(sr); diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 1048e1c87..bf81ef47f 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -33,6 +33,8 @@ class Autoconnect; class ModuleSpanningTree; class SpanningTreeUtilities; +extern SpanningTreeUtilities* Utils; + /* This hash_map holds the hash equivalent of the server * tree, used for rapid linear lookups. */ -- cgit v1.2.3