]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
userrec::UpdateNickHash(), userrec::ForceNickChange(), userrec::FullConnect()
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index dad289d8e550f88d2a1a8b00fe76078f55419bfa..1e908f07b139ce063d5dfccfa4b50358e811c58b 100644 (file)
@@ -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
@@ -1445,6 +1445,7 @@ class TreeSocket : public InspSocket
                                                        {
                                                                log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
                                                                us->age = TS;
+                                                               ourTS = TS;
                                                        }
                                                }
                                                else
@@ -1485,6 +1486,7 @@ class TreeSocket : public InspSocket
                                {
                                        log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
                                        us->age = TS;
+                                       ourTS = TS;
                                }
                        }
                        else
@@ -2012,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());
                        }
                }
@@ -2028,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;
@@ -2076,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;
        }
@@ -2894,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 != "")
@@ -2961,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);
                                                        }
@@ -3048,13 +3056,20 @@ class TreeSocket : public InspSocket
                 * IPs for which we don't have a link block.
                 */
                bool found = false;
-               vector<Link>::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<std::string>::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);
@@ -3343,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);
@@ -3357,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)