X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree.cpp;h=1e908f07b139ce063d5dfccfa4b50358e811c58b;hb=922d4ebf7a27a6577d6b4f91e0f42ccdfa989455;hp=e98b7b4602e1e860ef79523616f51354d077383b;hpb=7363f470f07527e29fd94fdcea77965173cf332a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index e98b7b460..1e908f07b 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -330,7 +330,7 @@ class TreeServer : public classbase userrec* a = (userrec*)*n; log(DEBUG,"Kill %s fd=%d",a->nick,a->fd); if (!IS_LOCAL(a)) - kill_link(a,reason_s); + userrec::QuitUser(a,reason_s); } return time_to_die.size(); } @@ -1338,11 +1338,11 @@ class TreeSocket : public InspSocket userrec* user = Srv->FindNick(source); if (!user) { - WriteChannelWithServ(source.c_str(), c, "TOPIC %s :%s", c->name, c->topic); + c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic); } else { - WriteChannel(c, user, "TOPIC %s :%s", c->name, c->topic); + c->WriteChannel(user, "TOPIC %s :%s", c->name, c->topic); nsource = user->server; } /* all done, send it on its way */ @@ -1430,7 +1430,7 @@ class TreeSocket : public InspSocket who = Srv->FindNick(usr); if (who) { - Srv->JoinUserToChannel(who,channel,key); + chanrec::JoinUser(who, channel.c_str(), true, key); if (modectr >= (MAXMODES-1)) { /* theres a mode for this user. push them onto the mode queue, and flush it @@ -2014,7 +2014,11 @@ class TreeSocket : public InspSocket /* This is not required as one is sent in OnUserPostNick below */ //DoOneToMany(u->nick,"NICK",par); - Srv->ChangeUserNick(u,params[1]); + if (!u->ForceNickChange(params[1].c_str())) + { + userrec::QuitUser(u, "Nickname collision"); + return true; + } u->age = atoi(params[2].c_str()); } } @@ -2030,7 +2034,7 @@ class TreeSocket : public InspSocket if (u) { - Srv->JoinUserToChannel(u,params[1],""); + chanrec::JoinUser(u, params[1].c_str(), false); DoOneToAllButSender(prefix,"SVSJOIN",params,prefix); } return true; @@ -2078,7 +2082,7 @@ class TreeSocket : public InspSocket params[1] = ":" + params[1]; DoOneToAllButSender(prefix,"KILL",params,sourceserv); ::Write(who->fd, ":%s KILL %s :%s (%s)", sourceserv.c_str(), who->nick, sourceserv.c_str(), reason.c_str()); - Srv->QuitUser(who,reason); + userrec::QuitUser(who,reason); } return true; } @@ -2896,7 +2900,9 @@ class TreeSocket : public InspSocket chanrec* chan = Srv->FindChannel(params[0]); if (user && chan) { - server_kick_channel(user,chan,(char*)params[2].c_str(),false); + if (!chan->ServerKickUser(user, params[2].c_str(), false)) + /* Yikes, the channels gone! */ + delete chan; } } if (this->InboundServerName != "") @@ -2963,11 +2969,11 @@ class TreeSocket : public InspSocket p.push_back(prefix); p.push_back("Nickname collision"); DoOneToMany(Srv->GetServerName(),"KILL",p); - Srv->QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")"); + userrec::QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")"); userrec* y = Srv->FindNick(prefix); if (y) { - Srv->QuitUser(y,"Nickname collision"); + userrec::QuitUser(y,"Nickname collision"); } return DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params); } @@ -3050,13 +3056,20 @@ class TreeSocket : public InspSocket * IPs for which we don't have a link block. */ bool found = false; - vector::iterator i; + found = (std::find(ValidIPs.begin(), ValidIPs.end(), ip) != ValidIPs.end()); if (!found) { - WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip); - close(newsock); - return false; + for (vector::iterator i = ValidIPs.begin(); i != ValidIPs.end(); i++) + if (MatchCIDR(ip, (*i).c_str())) + found = true; + + if (!found) + { + WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip); + close(newsock); + return false; + } } TreeSocket* s = new TreeSocket(newsock, ip); Srv->AddSocket(s); @@ -3345,6 +3358,7 @@ void ReadConfiguration(bool rebind) for (int j =0; j < Conf->Enumerate("link"); j++) { Link L; + std::string Allow = Conf->ReadValue("link","allowmask",j); L.Name = (Conf->ReadValue("link","name",j)).c_str(); L.IPAddr = Conf->ReadValue("link","ipaddr",j); L.Port = Conf->ReadInteger("link","port",j,true); @@ -3359,6 +3373,9 @@ void ReadConfiguration(bool rebind) { ValidIPs.push_back(L.IPAddr); + if (Allow.length()) + ValidIPs.push_back(Allow); + /* Needs resolving */ insp_inaddr binip; if (insp_aton(L.IPAddr.c_str(), &binip) < 1)