1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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()
48 virtual void OnRehash(std::string parameter)
51 Conf = new ConfigReader;
52 MySuffix = Conf->ReadValue("host","suffix",0);
55 virtual Version GetVersion()
57 // returns the version number of the module to be
59 return Version(1,0,0,1,VF_VENDOR);
62 virtual void OnUserConnect(userrec* user)
64 for (int index = 0; index < Conf->Enumerate("hostchange"); index++)
66 std::string mask = Conf->ReadValue("hostchange","mask",index);
67 if (Srv->MatchText(std::string(user->ident)+"@"+std::string(user->host),mask))
69 std::string newhost = "";
70 // host of new user matches a hostchange tag's mask
71 std::string action = Conf->ReadValue("hostchange","action",index);
74 newhost = Conf->ReadValue("hostchange","value",index);
76 else if (action == "suffix")
80 else if (action == "addnick")
82 // first take their nick and strip out non-dns, leaving just [A-Z0-9\-]
83 std::string complete = "";
84 std::string old = user->nick;
85 for (unsigned int j = 0; j < old.length(); j++)
87 if (((old[j] >= 'A') && (old[j] <= 'Z')) ||
88 ((old[j] >= 'a') && (old[j] <= 'z')) ||
89 ((old[j] >= '0') && (old[j] <= '9')) ||
92 complete = complete + old[j];
96 complete = "i-have-a-lame-nick";
97 newhost = complete + "." + MySuffix;
101 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + newhost);
102 Srv->ChangeHost(user,newhost);
110 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
112 class ModuleHostChangeFactory : public ModuleFactory
115 ModuleHostChangeFactory()
119 ~ModuleHostChangeFactory()
123 virtual Module * CreateModule(Server* Me)
125 return new ModuleHostChange(Me);
131 extern "C" void * init_module( void )
133 return new ModuleHostChangeFactory;