]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_oper/core_oper.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / coremods / core_oper / core_oper.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
6  *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21
22 #include "inspircd.h"
23 #include "core_oper.h"
24
25 class CoreModOper : public Module
26 {
27         std::string powerhash;
28
29         CommandDie cmddie;
30         CommandKill cmdkill;
31         CommandOper cmdoper;
32         CommandRehash cmdrehash;
33         CommandRestart cmdrestart;
34
35  public:
36         CoreModOper()
37                 : cmddie(this, powerhash)
38                 , cmdkill(this)
39                 , cmdoper(this)
40                 , cmdrehash(this)
41                 , cmdrestart(this, powerhash)
42         {
43         }
44
45         void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
46         {
47                 ConfigTag* tag = ServerInstance->Config->ConfValue("power");
48
49                 // The hash method for *BOTH* the die and restart passwords
50                 powerhash = tag->getString("hash");
51
52                 cmddie.password = tag->getString("diepass", ServerInstance->Config->ServerName, 1);
53                 cmdrestart.password = tag->getString("restartpass", ServerInstance->Config->ServerName, 1);
54
55                 ConfigTag* security = ServerInstance->Config->ConfValue("security");
56                 cmdkill.hidenick = security->getString("hidekills");
57                 cmdkill.hideuline = security->getBool("hideulinekills");
58         }
59
60         void OnPostOper(User* user, const std::string&, const std::string&) CXX11_OVERRIDE
61         {
62                 LocalUser* luser = IS_LOCAL(user);
63                 if (!luser)
64                         return;
65
66                 const std::string vhost = luser->oper->getConfig("vhost");
67                 if (!vhost.empty())
68                         luser->ChangeDisplayedHost(vhost);
69
70                 const std::string klass = luser->oper->getConfig("class");
71                 if (!klass.empty())
72                         luser->SetClass(klass);
73         }
74
75         Version GetVersion() CXX11_OVERRIDE
76         {
77                 return Version("Provides the DIE, KILL, OPER, REHASH, and RESTART commands", VF_VENDOR | VF_CORE);
78         }
79 };
80
81 MODULE_INIT(CoreModOper)