X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree.cpp;h=24997b93972c2628467e03fc1bb722ea2252ea7f;hb=412ab8a25a442fd49726b9f78c039a622ee09319;hp=2ecfdc696d5d6650ef24d83f7b307ad55562e5c2;hpb=3b7216d69b6de51cd9530ca9a468b0276f49ce53;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 2ecfdc696..24997b939 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -468,6 +468,13 @@ class Link ConfigReader *Conf; std::vector LinkBlocks; +template inline string ConvToStr(const T &in) +{ + stringstream tmp; + if (!(tmp << in)) return string(); + return tmp.str(); +} + /* Yay for fast searches! * This is hundreds of times faster than recursion * or even scanning a linked list, especially when @@ -1133,23 +1140,25 @@ class TreeSocket : public InspSocket log(DEBUG,"Sending FJOINs to other server for %s",c->name); char list[MAXBUF]; std::string individual_halfops = ":"+Srv->GetServerName()+" FMODE "+c->name; - snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); - std::map *ulist = c->GetUsers(); + size_t counter = snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); + size_t initial = counter; + + CUList *ulist = c->GetUsers(); std::vector specific_halfop; std::vector specific_voice; - for (std::map::iterator i = ulist->begin(); i != ulist->end(); i++) + + for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { - char* o = i->second; - userrec* otheruser = (userrec*)o; charlcat(list,' ',MAXBUF); - int x = cflags(otheruser,c); + counter++; + int x = cflags(i->second,c); if ((x & UCMODE_HOP) && (x & UCMODE_OP)) { - specific_halfop.push_back(otheruser); + specific_halfop.push_back(i->second); } if (((x & UCMODE_HOP) || (x & UCMODE_OP)) && (x & UCMODE_VOICE)) { - specific_voice.push_back(otheruser); + specific_voice.push_back(i->second); } char n = 0; @@ -1167,14 +1176,18 @@ class TreeSocket : public InspSocket } if (n) + { charlcat(list,n,MAXBUF); + counter++; + } + + counter += strlcat(list,i->second->nick,MAXBUF); - strlcat(list,otheruser->nick,MAXBUF); - if (strlen(list)>(480-NICKMAX)) + if (counter > (480-NICKMAX)) { log(DEBUG,"FJOIN line wrapped"); this->WriteLine(list); - snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); + counter = snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); for (unsigned int y = 0; y < specific_voice.size(); y++) { this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" +v "+specific_voice[y]->nick); @@ -1185,7 +1198,7 @@ class TreeSocket : public InspSocket } } } - if (list[strlen(list)-1] != ':') + if (counter != initial) { log(DEBUG,"Final FJOIN line"); this->WriteLine(list); @@ -1357,7 +1370,7 @@ class TreeSocket : public InspSocket * back to the core so that a large burst is split into at least 6 sections * (possibly more) */ - std::string burst = "BURST"; + std::string burst = "BURST "+ConvToStr(time(NULL)); std::string endburst = "ENDBURST"; Srv->SendOpers("*** Bursting to \2"+s->GetName()+"\2."); this->WriteLine(burst); @@ -2256,6 +2269,22 @@ class TreeSocket : public InspSocket } else if (command == "BURST") { + if (params.size()) + { + /* If a time stamp is provided, try and check syncronization */ + time_t THEM = atoi(params[0].c_str()); + long delta = THEM-time(NULL); + if ((delta < -600) || (delta > 600)) + { + WriteOpers("*** \2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta)); + this->WriteLine("ERROR :Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than ten minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!"); + return false; + } + else if ((delta < -60) || (delta > 60)) + { + WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta)); + } + } this->LinkState = CONNECTED; Node = new TreeServer(InboundServerName,InboundDescription,TreeRoot,this); TreeRoot->AddChild(Node); @@ -2629,14 +2658,12 @@ void AddThisServer(TreeServer* server, std::deque &list) // returns a list of DIRECT servernames for a specific channel void GetListOfServersForChannel(chanrec* c, std::deque &list) { - std::map *ulist = c->GetUsers(); - for (std::map::iterator i = ulist->begin(); i != ulist->end(); i++) + CUList *ulist = c->GetUsers(); + for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { - char* o = i->second; - userrec* otheruser = (userrec*)o; - if (otheruser->fd < 0) + if (i->second->fd < 0) { - TreeServer* best = BestRouteTo(otheruser->server); + TreeServer* best = BestRouteTo(i->second->server); if (best) AddThisServer(best,list); } @@ -2943,7 +2970,7 @@ class ModuleSpanningTree : public Module WriteServ(user->fd,"254 %s %d :channels formed",user->nick,chancount()); WriteServ(user->fd,"254 %s :I have %d clients and %d servers",user->nick,local_count(),this->CountLocalServs()); WriteServ(user->fd,"265 %s :Current Local Users: %d Max: %d",user->nick,local_count(),max_local); - WriteServ(user->fd,"266 %s :Current Global Users: %d Max: %d",user->nick,clientlist.size(),max_global); + WriteServ(user->fd,"266 %s :Current Global Users: %d Max: %d",user->nick,usercnt(),max_global); return; }