]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_vhost.cpp
Fix IPv6 cloaking in compatability mode (was using the wrong xtab confusor)
[user/henk/code/inspircd.git] / src / modules / m_vhost.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Provides masking of user hostnames via traditional /VHOST command */
17
18 /** Handle /VHOST
19  */
20 class CommandVhost : public Command
21 {
22  public:
23         CommandVhost(Module* Creator) : Command(Creator,"VHOST", 2)
24         {
25                 syntax = "<username> <password>";
26         }
27
28         CmdResult Handle (const std::vector<std::string> &parameters, User *user)
29         {
30                 ConfigTagList tags = ServerInstance->Config->ConfTags("vhost");
31                 for(ConfigIter i = tags.first; i != tags.second; ++i)
32                 {
33                         ConfigTag* tag = i->second;
34                         std::string mask = tag->getString("host");
35                         std::string username = tag->getString("user");
36                         std::string pass = tag->getString("pass");
37                         std::string hash = tag->getString("hash");
38
39                         if (parameters[0] == username && !ServerInstance->PassCompare(user, pass, parameters[1], hash))
40                         {
41                                 if (!mask.empty())
42                                 {
43                                         user->WriteServ("NOTICE "+user->nick+" :Setting your VHost: " + mask);
44                                         user->ChangeDisplayedHost(mask.c_str());
45                                         return CMD_SUCCESS;
46                                 }
47                         }
48                 }
49
50                 user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
51                 return CMD_FAILURE;
52         }
53 };
54
55 class ModuleVHost : public Module
56 {
57  private:
58         CommandVhost cmd;
59
60  public:
61         ModuleVHost() : cmd(this)
62         {
63                 ServerInstance->AddCommand(&cmd);
64         }
65
66         virtual ~ModuleVHost()
67         {
68         }
69
70
71         virtual Version GetVersion()
72         {
73                 return Version("Provides masking of user hostnames via traditional /VHOST command",VF_VENDOR);
74         }
75
76 };
77
78 MODULE_INIT(ModuleVHost)
79