X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree.cpp;h=3bf13d59afceb054232533909a1db3bf20acc583;hb=3f455b1747f822e867c37bc8902e51b5a36efba7;hp=b81e2e95a63a38c987568c0bb80df4de2e1386fe;hpb=32cb484b7ab86d4bd866d50ff95875e05a9f8b0d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index b81e2e95a..3bf13d59a 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -26,11 +26,8 @@ #include "inspircd.h" #include "wildcard.h" #include "xline.h" -#include "cull_list.h" #include "aes.h" -using irc::sockets::MatchCIDR; - /** If you make a change which breaks the protocol, increment this. * If you completely change the protocol, completely change the number. */ @@ -83,6 +80,28 @@ class ModuleSpanningTree; */ typedef nspace::hash_map, irc::StrHashComp> server_hash; + +/** The Link class might as well be a struct, + * but this is C++ and we don't believe in structs (!). + * It holds the entire information of one + * tag from the main config file. We maintain a list + * of them, and populate the list on rehash/load. + */ +class Link : public classbase +{ + public: + irc::string Name; + std::string IPAddr; + int Port; + std::string SendPass; + std::string RecvPass; + unsigned long AutoConnect; + time_t NextConnectTime; + std::string EncryptionKey; + bool HiddenFromStats; + std::string FailOver; +}; + /** Contains helper functions and variables for this module, * and keeps them out of the global namespace */ @@ -192,7 +211,6 @@ class SpanningTreeUtilities class TreeServer : public classbase { InspIRCd* ServerInstance; /* Creator */ - SpanningTreeUtilities* Utils; /* Utility class */ TreeServer* Parent; /* Parent entry */ TreeServer* Route; /* Route entry */ std::vector Children; /* List of child objects */ @@ -204,13 +222,14 @@ 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 */ public: /** We don't use this constructor. Its a dummy, and won't cause any insertion * of the TreeServer into the hash_map. See below for the two we DO use. */ - TreeServer(SpanningTreeUtilities* Utils, InspIRCd* Instance) : ServerInstance(Instance) + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : ServerInstance(Instance), Utils(Util) { Parent = NULL; ServerName = ""; @@ -224,7 +243,7 @@ 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* Utils, InspIRCd* Instance, std::string Name, std::string Desc) : ServerInstance(Instance), ServerName(Name.c_str()), ServerDesc(Desc) + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc) : ServerInstance(Instance), ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util) { Parent = NULL; VersionString = ""; @@ -239,8 +258,8 @@ class TreeServer : public classbase * 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* Utils, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock) - : ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock) + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock) + : ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util) { VersionString = ""; UserCount = OperCount = 0; @@ -494,27 +513,6 @@ class TreeServer : public classbase } }; -/** The Link class might as well be a struct, - * but this is C++ and we don't believe in structs (!). - * It holds the entire information of one - * tag from the main config file. We maintain a list - * of them, and populate the list on rehash/load. - */ -class Link : public classbase -{ - public: - irc::string Name; - std::string IPAddr; - int Port; - std::string SendPass; - std::string RecvPass; - unsigned long AutoConnect; - time_t NextConnectTime; - std::string EncryptionKey; - bool HiddenFromStats; - irc::string FailOver; -}; - /** Yay for fast searches! * This is hundreds of times faster than recursion * or even scanning a linked list, especially when @@ -3444,7 +3442,7 @@ class TreeSocket : public InspSocket if (!found) { for (vector::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++) - if (MatchCIDR(ip, (*i).c_str())) + if (irc::sockets::MatchCIDR(ip, (*i).c_str())) found = true; if (!found) @@ -3540,8 +3538,8 @@ class SecurityIPResolver : public Resolver SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* C) : ServerInstance(Instance), Creator(C) { Bindings.clear(); - this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); this->ReadConfiguration(true); + this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); } SpanningTreeUtilities::~SpanningTreeUtilities() @@ -3566,6 +3564,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities() DELETE(sock); } } + delete TreeRoot; } void SpanningTreeUtilities::AddThisServer(TreeServer* server, std::deque &list)