diff options
| author | 2023-05-02 14:05:03 +0100 | |
|---|---|---|
| committer | 2023-05-02 14:10:43 +0100 | |
| commit | 906142676eee2f1dbbbd2babaecbd426d12302a6 (patch) | |
| tree | 8a2adc72d856ab8dde57026ff6c94c863a5418c9 /src/modules | |
| parent | Add the cloak_nick module to cloak based on a nickname. (diff) | |
Add the cloak_static module to cloak using a fixed value.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_cloak_static.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/modules/m_cloak_static.cpp b/src/modules/m_cloak_static.cpp new file mode 100644 index 000000000..7c56654f6 --- /dev/null +++ b/src/modules/m_cloak_static.cpp @@ -0,0 +1,84 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2023 Sadie Powell <sadie@witchery.services> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "inspircd.h" +#include "modules/cloak.h" + +class StaticMethod final + : public Cloak::Method +{ +private: + // The cloak to set on users. + std::string cloak; + +public: + StaticMethod(const Cloak::Engine* engine, const std::shared_ptr<ConfigTag>& tag) ATTR_NOT_NULL(2) + : Cloak::Method(engine, tag) + , cloak(tag->getString("cloak")) + { + } + + std::string Generate(LocalUser* user) override ATTR_NOT_NULL(2) + { + if (!MatchesUser(user)) + return {}; // We shouldn't cloak this user. + + return cloak; + } + + std::string Generate(const std::string& hostip) override + { + return cloak; + } + + void GetLinkData(Module::LinkData& data, std::string& compatdata) override + { + data["cloak"] = cloak; + } +}; + +class StaticEngine final + : public Cloak::Engine +{ +public: + StaticEngine(Module* Creator) + : Cloak::Engine(Creator, "static") + { + } + + Cloak::MethodPtr Create(const std::shared_ptr<ConfigTag>& tag, bool primary) override + { + return std::make_shared<StaticMethod>(this, tag); + } +}; + +class ModuleCloakStatic final + : public Module +{ +private: + StaticEngine nickcloak; + +public: + ModuleCloakStatic() + : Module(VF_VENDOR, "Adds the static cloaking method for use with the cloak module.") + , nickcloak(this) + { + } +}; + +MODULE_INIT(ModuleCloakStatic) |
