From 889d521e05f2e922683d48c74eb00290e7a2f548 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 17 Jul 2024 00:06:50 +0100 Subject: Shuffle the modules about a bit. --- src/modules/m_cloak_static.cpp | 91 ------------------------------------------ 1 file changed, 91 deletions(-) delete mode 100644 src/modules/m_cloak_static.cpp (limited to 'src/modules/m_cloak_static.cpp') diff --git a/src/modules/m_cloak_static.cpp b/src/modules/m_cloak_static.cpp deleted file mode 100644 index 637951571..000000000 --- a/src/modules/m_cloak_static.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * Copyright (C) 2023 Sadie Powell - * - * 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 . - */ - -#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& tag, const std::string& c) ATTR_NOT_NULL(2) - : Cloak::Method(engine, tag) - , cloak(c) - { - } - - 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& tag, bool primary) override - { - const std::string cloak = tag->getString("cloak"); - if (cloak.empty() || cloak.length() > ServerInstance->Config->Limits.MaxHost) - { - throw ModuleException(creator, fmt::format("Your static cloak must be between 1 and {} characters long, at {}", - ServerInstance->Config->Limits.MaxHost, tag->source.str())); - } - - return std::make_shared(this, tag, cloak); - } -}; - -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) -- cgit v1.3.1-10-gc9f91