]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_hostchange.cpp
Untested! New m_watch that should be hundreds of times faster (im not joking either)
[user/henk/code/inspircd.git] / src / modules / m_hostchange.cpp
index 1dc280266bd41f2702616c6e14e14d05d5d141fc..3d036621424b7a3ea2af363de3ee4639735e0b31 100644 (file)
@@ -24,7 +24,9 @@ using namespace std;
 
 /* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
 
-class Host
+/** Holds information on a host set by m_hostchange
+ */
+class Host : public classbase
 {
  public:
        std::string action;
@@ -37,17 +39,17 @@ class ModuleHostChange : public Module
 {
  private:
 
-       Server *Srv;
+       
        ConfigReader *Conf;
        hostchanges_t hostchanges;
        std::string MySuffix;
         
  public:
-       ModuleHostChange(Server* Me)
+       ModuleHostChange(InspIRCd* Me)
                : Module::Module(Me)
        {
-               Srv = Me;
-               Conf = new ConfigReader;
+               
+               Conf = new ConfigReader(ServerInstance);
                OnRehash("");
        }
        
@@ -58,7 +60,7 @@ class ModuleHostChange : public Module
 
        Priority Prioritize()
        {
-               return (Priority)Srv->PriorityAfter("m_cloaking.so");
+               return (Priority)ServerInstance->PriorityAfter("m_cloaking.so");
        }
 
        void Implements(char* List)
@@ -69,7 +71,7 @@ class ModuleHostChange : public Module
        virtual void OnRehash(const std::string &parameter)
        {
                DELETE(Conf);
-               Conf = new ConfigReader;
+               Conf = new ConfigReader(ServerInstance);
                MySuffix = Conf->ReadValue("host","suffix",0);
                for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
                {
@@ -92,14 +94,14 @@ class ModuleHostChange : public Module
        {
                // returns the version number of the module to be
                // listed in /MODULES
-               return Version(1,0,0,1,VF_VENDOR);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
        virtual void OnUserConnect(userrec* user)
        {
                for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
                {
-                       if (Srv->MatchText(std::string(user->ident)+"@"+std::string(user->host),i->first))
+                       if (ServerInstance->MatchText(std::string(user->ident)+"@"+std::string(user->host),i->first))
                        {
                                Host* h = (Host*)i->second;
                                // host of new user matches a hostchange tag's mask
@@ -133,8 +135,9 @@ class ModuleHostChange : public Module
                                }
                                if (newhost != "")
                                {
-                                       Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your virtual host: " + newhost);
-                                       Srv->ChangeHost(user,newhost);
+                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your virtual host: " + newhost);
+                                       if (!user->ChangeDisplayedHost(newhost.c_str()))
+                                               user->WriteServ("NOTICE "+std::string(user->nick)+" :Could not set your virtual host: " + newhost);
                                        return;
                                }
                        }
@@ -155,7 +158,7 @@ class ModuleHostChangeFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleHostChange(Me);
        }