Merge branch 'insp3' into master.

This commit is contained in:
Sadie Powell 2022-03-11 14:27:32 +00:00
commit 2d329701db
15 changed files with 70 additions and 44 deletions

View File

@ -7,7 +7,7 @@ on:
jobs:
build:
if: "!contains(github.event.head_commit.message, '[skip windows ci]')"
runs-on: windows-latest
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
@ -20,7 +20,7 @@ jobs:
- name: Install libraries
working-directory: ${{ github.workspace }}/win/build
run: |
conan install ..
conan install .. --build=missing
- name: Run CMake
working-directory: ${{ github.workspace }}/win/build

View File

@ -1,6 +1,6 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = InspIRCd
PROJECT_NUMBER = 4.0
PROJECT_NUMBER = v4
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = docs/doxygen

View File

@ -649,6 +649,8 @@
# letters (requires the blockcaps module).
# - blockcolor Channel mode +c - blocks messages with formatting codes
# (requires the blockcolor module).
# - delaymsg Channel mode +d - blocks sending messages until specified
# seconds have passed since user join
# - filter Channel mode +g - blocks messages containing the given
# glob mask (requires the chanfilter module).
# - flood Channel mode +f - kicks (and bans) on text flood of a

View File

@ -1673,9 +1673,14 @@
#
# 'saveperiod' determines how often to check if the database needs to be
# saved to disk. Defaults to every five seconds.
#
# 'operonly' determines whether a server operator or services server is
# needed to enable the permchannels mode. You should generally keep this
# set to yes unless you know what you are doing.
#<permchanneldb filename="permchannels.conf"
# listmodes="yes"
# saveperiod="5s">
# saveperiod="5s"
# operonly="yes">
#<include file="permchannels.conf" missingokay="yes">
#
# You may also create channels on startup by using the <permchannels> block.

View File

@ -27,6 +27,7 @@
# - users/mass-message: allows opers with this priv to PRIVMSG and NOTICE to a server mask (e.g. NOTICE $*).
# - users/samode-usermodes: allows opers with this priv to change the user modes of any other user using /SAMODE.
# PERMISSIONS:
# - channels/ignore-delaymsg: allows opers with this priv to be immune to delaymsg restriction on a +d channel.
# - channels/ignore-noctcp: allows opers with this priv to send a CTCP to a +C channel.
# - channels/ignore-nonicks: allows opers with this priv to change their nick when on a +N channel.
# - channels/ignore-opmoderated: allows opers with this priv to ignore +U.

View File

@ -65,7 +65,8 @@ enum TranslateType
};
/** The type of routes that a message can take. */
enum class RouteType : uint8_t
enum class RouteType
: uint8_t
{
/** The message is only routed to the local server. */
LOCAL,

View File

@ -126,7 +126,7 @@ public:
};
/**
* This #define allows us to call a method in all
* This \#define allows us to call a method in all
* loaded modules in a readable simple way, e.g.:
* 'FOREACH_MOD(OnConnect,(user));'
*/

View File

@ -131,7 +131,7 @@ public:
* @param c A code which represents this error.
* @param m A custom error message.
*/
Error(ErrorCode c, const std::string m)
Error(ErrorCode c, const std::string& m)
: message(m)
, code(c)
{

View File

@ -137,7 +137,6 @@ public:
{
return IsUsable() && trusted && !unknownsigner;
}
};
/** I/O hook provider for TLS modules. */

View File

@ -356,25 +356,34 @@ std::string InspIRCd::DurationString(time_t duration)
if (duration == 0)
return "0s";
time_t years = duration / 31449600;
time_t weeks = (duration / 604800) % 52;
time_t days = (duration / 86400) % 7;
time_t hours = (duration / 3600) % 24;
time_t minutes = (duration / 60) % 60;
time_t seconds = duration % 60;
std::string ret;
if (duration < 0)
{
ret = "-";
duration = std::abs(duration);
}
time_t years = duration / 31449600;
if (years)
ret = ConvToStr(years) + "y";
ret += ConvToStr(years) + "y";
time_t weeks = (duration / 604800) % 52;
if (weeks)
ret += ConvToStr(weeks) + "w";
time_t days = (duration / 86400) % 7;
if (days)
ret += ConvToStr(days) + "d";
time_t hours = (duration / 3600) % 24;
if (hours)
ret += ConvToStr(hours) + "h";
time_t minutes = (duration / 60) % 60;
if (minutes)
ret += ConvToStr(minutes) + "m";
time_t seconds = duration % 60;
if (seconds)
ret += ConvToStr(seconds) + "s";

View File

@ -47,12 +47,13 @@ public:
ChanLogTargets newlogs;
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("chanlog"))
{
std::string channel = tag->getString("channel");
std::string snomasks = tag->getString("snomasks");
if (channel.empty() || snomasks.empty())
{
throw ModuleException(this, "Malformed chanlog tag at " + tag->source.str());
}
const std::string channel = tag->getString("channel");
if (!ServerInstance->Channels.IsChannel(channel))
throw ModuleException(this, "<chanlog:channel> must be set to a channel name, at " + tag->source.str());
const std::string snomasks = tag->getString("snomasks");
if (snomasks.empty())
throw ModuleException(this, "<chanlog:snomasks> must not be empty, at " + tag->source.str());
for (const auto& snomask : snomasks)
{
@ -61,7 +62,6 @@ public:
}
}
logstreams.swap(newlogs);
}
ModResult OnSendSnotice(char &sno, std::string &desc, const std::string &msg) override

View File

@ -24,7 +24,7 @@
#include "inspircd.h"
static std::bitset<256> allowedmap;
static std::bitset<UCHAR_MAX + 1> allowedmap;
class NewIsChannelHandler final
{
@ -61,11 +61,6 @@ public:
{
}
void init() override
{
ServerInstance->Channels.IsChannel = NewIsChannelHandler::Call;
}
void ValidateChans()
{
Modes::ChangeList removepermchan;
@ -119,17 +114,18 @@ public:
irc::portparser denyrange(denyToken, false);
long denyno = -1;
while (0 != (denyno = denyrange.GetToken()))
allowedmap[denyno & 0xFF] = false;
allowedmap[denyno & UCHAR_MAX] = false;
irc::portparser allowrange(allowToken, false);
long allowno = -1;
while (0 != (allowno = allowrange.GetToken()))
allowedmap[allowno & 0xFF] = true;
allowedmap[allowno & UCHAR_MAX] = true;
allowedmap[0x07] = false; // BEL
allowedmap[0x20] = false; // ' '
allowedmap[0x2C] = false; // ','
ServerInstance->Channels.IsChannel = NewIsChannelHandler::Call;
ValidateChans();
}

View File

@ -22,6 +22,7 @@
#include "inspircd.h"
#include "modules/ctctags.h"
#include "modules/exemption.h"
class DelayMsgMode final
: public ParamMode<DelayMsgMode, IntExtItem>
@ -57,6 +58,7 @@ class ModuleDelayMsg final
private:
DelayMsgMode djm;
bool allownotice;
CheckExemption::EventProvider exemptionprov;
ModResult HandleMessage(User* user, const MessageTarget& target, bool notice);
public:
@ -64,6 +66,7 @@ public:
: Module(VF_VENDOR, "Adds channel mode d (delaymsg) which prevents newly joined users from speaking until the specified number of seconds have passed.")
, CTCTags::EventListener(this)
, djm(this)
, exemptionprov(this)
{
}
@ -131,12 +134,16 @@ ModResult ModuleDelayMsg::HandleMessage(User* user, const MessageTarget& target,
if ((ts + len) > ServerInstance->Time())
{
if (channel->GetPrefixValue(user) < VOICE_VALUE)
{
const std::string message = InspIRCd::Format("You cannot send messages to this channel until you have been a member for %ld seconds.", len);
user->WriteNumeric(Numerics::CannotSendTo(channel, message));
return MOD_RES_DENY;
}
ModResult res = CheckExemption::Call(exemptionprov, user, channel, "delaymsg");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
if (user->HasPrivPermission("channels/ignore-delaymsg"))
return MOD_RES_PASSTHRU;
const std::string message = InspIRCd::Format("You cannot send messages to this channel until you have been a member for %ld seconds.", len);
user->WriteNumeric(Numerics::CannotSendTo(channel, message));
return MOD_RES_DENY;
}
else
{

View File

@ -52,6 +52,11 @@ public:
return MODEACTION_DENY;
}
void SetOperOnly(bool value)
{
oper = value;
}
};
// Not in a class due to circular dependency hell.
@ -183,6 +188,7 @@ public:
auto tag = ServerInstance->Config->ConfValue("permchanneldb");
permchannelsconf = tag->getString("filename");
save_listmodes = tag->getBool("listmodes", true);
p.SetOperOnly(tag->getBool("operonly", true));
SetInterval(tag->getDuration("saveperiod", 5));
if (!permchannelsconf.empty())

View File

@ -8,20 +8,20 @@
argon2/20190702
# libmaxminddb/1.6.0
libpq/13.4
# mbedtls/3.0.0
# mbedtls/3.1.0
mysql-connector-c/6.1.11
# openssl/3.0.0
# openssl/3.0.1
pcre2/10.37
re2/20210901
sqlite3/3.36.0
re2/20211101
sqlite3/3.37.2
[options]
argon2:shared=True
# libmaxminddb:shared=True
libmaxminddb:shared=True
libpq:shared=True
# mbedtls:shared=True
mbedtls:shared=True
mysql-connector:shared=True
# openssl:shared=True
openssl:shared=True
pcre2:shared=True
re2:shared=True
sqlite3:shared=True