X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fmain.cpp;h=8014d562d15a0db7561a5997ace5549796ac0b00;hb=23fb1f062bc993bdce30f643b905105fd2f1b78e;hp=61df8cb5ef52761ef6f23d608b88b0d4f8fec705;hpb=38ba80102f0c349c0d0df83990180320ddd054f8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 61df8cb5e..8014d562d 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -37,19 +37,11 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me) : Module(Me), max_local(0), max_global(0) { ServerInstance->Modules->UseInterface("BufferedSocketHook"); - Utils = new SpanningTreeUtilities(Me, this); + Utils = new SpanningTreeUtilities(ServerInstance, this); command_rconnect = new cmd_rconnect(ServerInstance, this, Utils); ServerInstance->AddCommand(command_rconnect); command_rsquit = new cmd_rsquit(ServerInstance, this, Utils); ServerInstance->AddCommand(command_rsquit); - if (Utils->EnableTimeSync) - { - SyncTimer = new TimeSyncTimer(ServerInstance, this); - ServerInstance->Timers->AddTimer(SyncTimer); - } - else - SyncTimer = NULL; - RefreshTimer = new CacheRefreshTimer(ServerInstance, Utils); ServerInstance->Timers->AddTimer(RefreshTimer); @@ -64,7 +56,7 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me) }; ServerInstance->Modules->Attach(eventlist, this, 29); - for (std::vector::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + for (std::vector::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { this->OnPostConnect((*i)); } @@ -114,20 +106,20 @@ int ModuleSpanningTree::CountServs() return Utils->serverlist.size(); } -void ModuleSpanningTree::HandleLinks(const char** parameters, int pcnt, User* user) +void ModuleSpanningTree::HandleLinks(const char* const* parameters, int pcnt, User* user) { ShowLinks(Utils->TreeRoot,user,0); user->WriteServ("365 %s * :End of /LINKS list.",user->nick); return; } -void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* user) +void ModuleSpanningTree::HandleLusers(const char* const* parameters, int pcnt, User* user) { - unsigned int n_users = ServerInstance->UserCount(); + unsigned int n_users = ServerInstance->Users->UserCount(); /* Only update these when someone wants to see them, more efficient */ - if ((unsigned int)ServerInstance->LocalUserCount() > max_local) - max_local = ServerInstance->LocalUserCount(); + if ((unsigned int)ServerInstance->Users->LocalUserCount() > max_local) + max_local = ServerInstance->Users->LocalUserCount(); if (n_users > max_global) max_global = n_users; @@ -150,21 +142,21 @@ void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* u } } user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick, - n_users-ServerInstance->ModeCount('i'), - ServerInstance->ModeCount('i'), + n_users-ServerInstance->Users->ModeCount('i'), + ServerInstance->Users->ModeCount('i'), ulined_count ? this->CountServs() - ulined_count : this->CountServs()); - if (ServerInstance->OperCount()) - user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->OperCount()); + if (ServerInstance->Users->OperCount()) + user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount()); - if (ServerInstance->UnregisteredUserCount()) - user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->UnregisteredUserCount()); + if (ServerInstance->Users->UnregisteredUserCount()) + user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->Users->UnregisteredUserCount()); if (ServerInstance->ChannelCount()) user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount()); - user->WriteServ("255 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs()); - user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,ServerInstance->LocalUserCount(),max_local); + user->WriteServ("255 %s :I have %d clients and %d servers",user->nick,ServerInstance->Users->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs()); + user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,ServerInstance->Users->LocalUserCount(),max_local); user->WriteServ("266 %s :Current Global Users: %d Max: %d",user->nick,n_users,max_global); return; } @@ -197,7 +189,6 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime) { sock->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" PING "+serv->GetID()); serv->SetNextPingTime(curtime + Utils->PingFreq); - serv->LastPing = curtime; timeval t; gettimeofday(&t, NULL); long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000); @@ -223,11 +214,19 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime) } } - /* Cancel remote burst mode on any servers which still have it enabled due to latency/lack of data. + /* + * Cancel remote burst mode on any servers which still have it enabled due to latency/lack of data. * This prevents lost REMOTECONNECT notices + * XXX this should probably not do this until server has been bursting for, say, 60 seconds or something */ for (server_hash::iterator i = Utils->serverlist.begin(); i != Utils->serverlist.end(); i++) - Utils->SetRemoteBursting(i->second, false); + { + if (i->second->bursting) + { + ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not finished burst, forcing end of burst.", i->second->GetName().c_str()); + i->second->FinishBurst(); + } + } } void ModuleSpanningTree::ConnectServer(Link* x) @@ -315,7 +314,7 @@ void ModuleSpanningTree::AutoConnectServers(time_t curtime) } } -int ModuleSpanningTree::HandleVersion(const char** parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleVersion(const char* const* parameters, int pcnt, User* user) { // we've already checked if pcnt > 0, so this is safe TreeServer* found = Utils->FindServerMask(parameters[0]); @@ -385,7 +384,7 @@ void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...) SendingRemoteMessage = false; } -int ModuleSpanningTree::HandleConnect(const char** parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleConnect(const char* const* parameters, int pcnt, User* user) { for (std::vector::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++) { @@ -409,17 +408,6 @@ int ModuleSpanningTree::HandleConnect(const char** parameters, int pcnt, User* u return 1; } -void ModuleSpanningTree::BroadcastTimeSync() -{ - if (Utils->MasterTime) - { - std::deque params; - params.push_back(ConvToStr(ServerInstance->Time(false))); - params.push_back("FORCE"); - Utils->DoOneToMany(ServerInstance->Config->GetSID(), "TIMESET", params); - } -} - void ModuleSpanningTree::OnGetServerDescription(const std::string &servername,std::string &description) { TreeServer* s = Utils->FindServer(servername); @@ -429,13 +417,14 @@ void ModuleSpanningTree::OnGetServerDescription(const std::string &servername,st } } -void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel) +void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel, time_t expiry) { if (IS_LOCAL(source)) { std::deque params; params.push_back(dest->uuid); params.push_back(channel->name); + params.push_back(ConvToStr(expiry)); Utils->DoOneToMany(source->uuid,"INVITE",params); } } @@ -683,7 +672,7 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick) /** IMPORTANT: We don't update the TS if the oldnick is just a case change of the newnick! */ if (irc::string(user->nick) != assign(oldnick)) - user->age = ServerInstance->Time(true); + user->age = ServerInstance->Time(); params.push_back(ConvToStr(user->age)); Utils->DoOneToMany(user->uuid,"NICK",params); @@ -732,7 +721,7 @@ void ModuleSpanningTree::OnRehash(User* user, const std::string ¶meter) // check for self if (ServerInstance->MatchText(ServerInstance->Config->ServerName,parameter)) { - ServerInstance->WriteOpers("*** Remote rehash initiated locally by \002%s\002", user ? user->nick : ServerInstance->Config->ServerName); + ServerInstance->SNO->WriteToSnoMask('A', "Remote rehash initiated locally by \002%s\002", user ? user->nick : ServerInstance->Config->ServerName); ServerInstance->RehashServer(); } } @@ -753,14 +742,14 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype) } } -void ModuleSpanningTree::OnAddLine(XLine* line, User* user) +void ModuleSpanningTree::OnAddLine(User* user, XLine *x) { - if (line->type == "K") + if (!x->IsBurstable()) return; char data[MAXBUF]; - snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time, - line->duration, line->reason); + snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", x->type.c_str(), x->Displayable(), + ServerInstance->Config->ServerName, (unsigned long)x->set_time, (unsigned long)x->duration, x->reason); std::deque params; params.push_back(data); @@ -776,13 +765,13 @@ void ModuleSpanningTree::OnAddLine(XLine* line, User* user) } } -void ModuleSpanningTree::OnDelLine(XLine* line, User* user) +void ModuleSpanningTree::OnDelLine(User* user, XLine *x) { - if (line->type == "K") + if (x->type == "K") return; char data[MAXBUF]; - snprintf(data,MAXBUF,"%s %s", line->type.c_str(), line->Displayable()); + snprintf(data,MAXBUF,"%s %s", x->type.c_str(), x->Displayable()); std::deque params; params.push_back(data); @@ -908,7 +897,7 @@ void ModuleSpanningTree::OnEvent(Event* event) return; (*params)[1] = ":" + (*params)[1]; params->insert(params->begin() + 1,ServerInstance->Config->ServerName); - params->insert(params->begin() + 1,ConvToStr(ServerInstance->Time(true))); + params->insert(params->begin() + 1,ConvToStr(ServerInstance->Time())); Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC",*params); } else if (event->GetEventID() == "send_mode") @@ -932,10 +921,10 @@ void ModuleSpanningTree::OnEvent(Event* event) } else { - Channel* a = ServerInstance->FindChan((*params)[0]); - if (a) + Channel* c = ServerInstance->FindChan((*params)[0]); + if (c) { - ourTS = a->age; + ourTS = c->age; params->insert(params->begin() + 1,ConvToStr(ourTS)); Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",*params); } @@ -994,8 +983,6 @@ ModuleSpanningTree::~ModuleSpanningTree() { /* This will also free the listeners */ delete Utils; - if (SyncTimer) - ServerInstance->Timers->DelTimer(SyncTimer); ServerInstance->Timers->DelTimer(RefreshTimer);