1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 /* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
26 class ModuleHostChange : public Module
35 ModuleHostChange(Server* Me)
39 Conf = new ConfigReader;
40 MySuffix = Conf->ReadValue("host","suffix",0);
43 virtual ~ModuleHostChange()
50 return (Priority)Srv->PriorityAfter("m_cloaking.so");
53 void Implements(char* List)
55 List[I_OnRehash] = List[I_OnUserConnect] = 1;
58 virtual void OnRehash(std::string parameter)
61 Conf = new ConfigReader;
62 MySuffix = Conf->ReadValue("host","suffix",0);
65 virtual Version GetVersion()
67 // returns the version number of the module to be
69 return Version(1,0,0,1,VF_VENDOR);
72 virtual void OnUserConnect(userrec* user)
74 for (int index = 0; index < Conf->Enumerate("hostchange"); index++)
76 std::string mask = Conf->ReadValue("hostchange","mask",index);
77 if (Srv->MatchText(std::string(user->ident)+"@"+std::string(user->host),mask))
79 std::string newhost = "";
80 // host of new user matches a hostchange tag's mask
81 std::string action = Conf->ReadValue("hostchange","action",index);
84 newhost = Conf->ReadValue("hostchange","value",index);
86 else if (action == "suffix")
90 else if (action == "addnick")
92 // first take their nick and strip out non-dns, leaving just [A-Z0-9\-]
93 std::string complete = "";
94 std::string old = user->nick;
95 for (unsigned int j = 0; j < old.length(); j++)
97 if (((old[j] >= 'A') && (old[j] <= 'Z')) ||
98 ((old[j] >= 'a') && (old[j] <= 'z')) ||
99 ((old[j] >= '0') && (old[j] <= '9')) ||
102 complete = complete + old[j];
106 complete = "i-have-a-lame-nick";
107 newhost = complete + "." + MySuffix;
111 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + newhost);
112 Srv->ChangeHost(user,newhost);
120 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
122 class ModuleHostChangeFactory : public ModuleFactory
125 ModuleHostChangeFactory()
129 ~ModuleHostChangeFactory()
133 virtual Module * CreateModule(Server* Me)
135 return new ModuleHostChange(Me);
141 extern "C" void * init_module( void )
143 return new ModuleHostChangeFactory;