mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Add the cloak_static module to cloak using a fixed value.
This commit is contained in:
parent
96eab46e44
commit
906142676e
@ -716,6 +716,29 @@
|
||||
# case="lower"
|
||||
# pathparts="1">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Static cloak module: Adds the "static" (fixed value) cloak method.
|
||||
#<module name="cloak_static">
|
||||
#
|
||||
#-#-#-#-#-#-#-#-#-#- ACCOUNT CLOAK CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#
|
||||
# To use the cloak_static module you must define a <cloak> tag. This #
|
||||
# tag can have the following fields. #
|
||||
# #
|
||||
# class - If non-empty then a comma-delimited list of connect class #
|
||||
# names that a user has to be in to get the cloak from this tag. #
|
||||
# #
|
||||
# cloak - The cloak to give to users. #
|
||||
# #
|
||||
# IMPORTANT: Changing these details will break all of your existing #
|
||||
# bans. If you do not want this to happen you can define multiple #
|
||||
# cloak tags. The first will be used for hostnames and the rest will #
|
||||
# be used for checking if a user is banned in a channel. #
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
#
|
||||
#<cloak method="static"
|
||||
# class=""
|
||||
# cloak="some.fixed.value">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Codepage module: Allows using a custom 8-bit codepage for nicknames
|
||||
# and case mapping.
|
||||
|
84
src/modules/m_cloak_static.cpp
Normal file
84
src/modules/m_cloak_static.cpp
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user