]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added remote rehash (even to a mask)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 30 Nov 2005 15:46:11 +0000 (15:46 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 30 Nov 2005 15:46:11 +0000 (15:46 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2061 e03df62e-2008-0410-955e-edbf42e46eb7

src/commands.cpp
src/modules/m_spanningtree.cpp

index 82a6a2237670992be8a0569cbd3bcad37790aa1c..a2514f29a7547f59ca8db66760a1e8c4c74f0c20 100644 (file)
@@ -1075,12 +1075,17 @@ void handle_list(char **parameters, int pcnt, userrec *user)
 void handle_rehash(char **parameters, int pcnt, userrec *user)
 {
        WriteServ(user->fd,"382 %s %s :Rehashing",user->nick,CleanFilename(CONFIG_FILE));
-       ReadConfig(false,user);
        std::string parameter = "";
        if (pcnt)
+       {
                parameter = parameters[0];
+       }
+       else
+       {
+               WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
+               ReadConfig(false,user);
+       }
        FOREACH_MOD OnRehash(parameter);
-       WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
 }
 
 void handle_lusers(char **parameters, int pcnt, userrec *user)
index 63a68c5a98cc5ced2e47076cd32b6239455bc4c3..fa22f80a1555bd523e0328078845a33f21e23990 100644 (file)
@@ -706,6 +706,19 @@ class TreeSocket : public InspSocket
                return true;
        }
 
+       bool RemoteRehash(std::string prefix, std::deque<std::string> params)
+       {
+               if (params.size() < 1)
+                       return true;
+               std::string servermask = params[0];
+               if (Srv->MatchText(Srv->GetServerName(),servermask))
+               {
+                       Srv->RehashServer();
+               }
+               DoOneToAllButSender(prefix,"REHASH",params,prefix);
+               return;
+       }
+
        bool RemoteKill(std::string prefix, std::deque<std::string> params)
        {
                if (params.size() != 2)
@@ -982,6 +995,10 @@ class TreeSocket : public InspSocket
                                {
                                        return this->ForceTopic(prefix,params);
                                }
+                               else if (command == "REHASH")
+                               {
+                                       return this->RemoteRehash(prefix,params);
+                               }
                                else if (command == "SQUIT")
                                {
                                        if (params.size() == 2)
@@ -1550,6 +1567,21 @@ class ModuleSpanningTree : public Module
                DoOneToMany(source->nick,"KILL",params);
        }
 
+       virtual void OnRehash(std::string parameter)
+       {
+               if (parameter != "")
+               {
+                       std::deque<std::string> params;
+                       params.push_back(parameter);
+                       DoOneToMany(Srv->GetServerName(),"REHASH",params);
+                       // check for self
+                       if (Srv->MatchText(Srv->GetServerName(),parameter))
+                       {
+                               Srv->RehashServer();
+                       }
+               }
+       }
+
        // note: the protocol does not allow direct umode +o except
        // via NICK with 8 params. sending OPERTYPE infers +o modechange
        // locally.