X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreeserver.cpp;h=34b71e07fb82deb403c7a4d4e8eeafa97b00fd8f;hb=11916574f67962dce1d7a2fdf7ef6a3d2d1fa49f;hp=0fad3132d8f629c9f31e5276e06c53b62d146c5e;hpb=5dcd385b772f2ce822cf0700912ced93bd06c914;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 0fad3132d..34b71e07f 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -33,7 +33,8 @@ * no socket associated with it. Its version string is our own local version. */ TreeServer::TreeServer() - : Parent(NULL), Route(NULL), ServerName(ServerInstance->Config->ServerName), ServerDesc(ServerInstance->Config->ServerDesc) + : Server(ServerInstance->Config->ServerName) + , Parent(NULL), Route(NULL), ServerDesc(ServerInstance->Config->ServerDesc) , 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) { @@ -45,9 +46,11 @@ TreeServer::TreeServer() * its ping counters so that it will be pinged one minute from now. */ 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)) + : Server(Name) + , Parent(Above), ServerDesc(Desc), Socket(Sock), sid(id), ServerUser(new FakeUser(id, this)) , age(ServerInstance->Time()), Warned(false), bursting(true), UserCount(0), OperCount(0), rtt(0), Hidden(Hide) { + CheckULine(); SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); SetPingFlag(); @@ -119,9 +122,9 @@ void TreeServer::FinishBurstInternal() this->bursting = false; SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); SetPingFlag(); - for(unsigned int q=0; q < ChildCount(); q++) + for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i) { - TreeServer* child = GetChild(q); + TreeServer* child = *i; child->FinishBurstInternal(); } } @@ -133,36 +136,36 @@ void TreeServer::FinishBurst() long ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000); unsigned long bursttime = ts - this->StartBurst; ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)", - ServerName.c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); - AddServerEvent(Utils->Creator, ServerName); + GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); + AddServerEvent(Utils->Creator, GetName()); } int TreeServer::QuitUsers(const std::string &reason) { - const char* reason_s = reason.c_str(); - std::vector time_to_die; - for (user_hash::iterator n = ServerInstance->Users->clientlist->begin(); n != ServerInstance->Users->clientlist->end(); n++) + std::string publicreason = ServerInstance->Config->HideSplits ? "*.net *.split" : reason; + + const user_hash& users = *ServerInstance->Users->clientlist; + unsigned int original_size = users.size(); + for (user_hash::const_iterator i = users.begin(); i != users.end(); ) { - if (n->second->server == ServerName) - { - time_to_die.push_back(n->second); - } + User* user = i->second; + // Increment the iterator now because QuitUser() removes the user from the container + ++i; + if (user->server == this) + ServerInstance->Users->QuitUser(user, publicreason, &reason); } - for (std::vector::iterator n = time_to_die.begin(); n != time_to_die.end(); n++) - { - User* a = (User*)*n; - if (!IS_LOCAL(a)) - { - if (Utils->quiet_bursts) - a->quietquit = true; + return original_size - users.size(); +} - if (ServerInstance->Config->HideSplits) - ServerInstance->Users->QuitUser(a, "*.net *.split", reason_s); - else - ServerInstance->Users->QuitUser(a, reason_s); - } +void TreeServer::CheckULine() +{ + uline = silentuline = false; + std::map::iterator it = ServerInstance->Config->ulines.find(GetName().c_str()); + if (it != ServerInstance->Config->ulines.end()) + { + uline = true; + silentuline = it->second; } - return time_to_die.size(); } /** This method is used to add the structure to the @@ -171,7 +174,7 @@ int TreeServer::QuitUsers(const std::string &reason) */ void TreeServer::AddHashEntry() { - Utils->serverlist[ServerName] = this; + Utils->serverlist[GetName()] = this; Utils->sidlist[sid] = this; } @@ -229,28 +232,6 @@ void TreeServer::SetVersion(const std::string &Version) VersionString = Version; } -unsigned int TreeServer::ChildCount() -{ - return Children.size(); -} - -TreeServer* TreeServer::GetChild(unsigned int n) -{ - if (n < Children.size()) - { - /* Make sure they cant request - * an out-of-range object. After - * all we know what these programmer - * types are like *grin*. - */ - return Children[n]; - } - else - { - return NULL; - } -} - void TreeServer::AddChild(TreeServer* Child) { Children.push_back(Child); @@ -288,7 +269,7 @@ void TreeServer::Tidy() CullResult TreeServer::cull() { - if (ServerUser != ServerInstance->FakeClient) + if (!IsRoot()) ServerUser->cull(); return classbase::cull(); } @@ -296,9 +277,9 @@ CullResult TreeServer::cull() TreeServer::~TreeServer() { /* We'd better tidy up after ourselves, eh? */ - if (ServerUser != ServerInstance->FakeClient) + if (!IsRoot()) delete ServerUser; Utils->sidlist.erase(sid); - Utils->serverlist.erase(ServerName); + Utils->serverlist.erase(GetName()); }