mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Merge branch 'insp3' into master.
This commit is contained in:
commit
3ca912ad71
5
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
5
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@ -13,10 +13,7 @@ The GitHub issue tracker is for bug reports ONLY. General support can be found a
|
||||
Discussions: https://github.com/inspircd/inspircd/discussions
|
||||
Docs: https://docs.inspircd.org
|
||||
IRC: irc.inspircd.org #inspircd
|
||||
|
||||
Example configs:
|
||||
3.0 (stable) - https://github.com/inspircd/inspircd/tree/insp3/docs/conf
|
||||
2.0 (old stable) - https://github.com/inspircd/inspircd/tree/insp20/docs/conf
|
||||
Example configs: https://github.com/inspircd/inspircd/tree/insp3/docs/conf
|
||||
-->
|
||||
|
||||
**Description**
|
||||
|
5
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
5
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
@ -11,10 +11,7 @@ The GitHub issue tracker is for feature requests ONLY. General support can be fo
|
||||
Discussions: https://github.com/inspircd/inspircd/discussions
|
||||
Docs: https://docs.inspircd.org
|
||||
IRC: irc.inspircd.org #inspircd
|
||||
|
||||
Example configs:
|
||||
3.0 (stable) - https://github.com/inspircd/inspircd/tree/insp3/docs/conf
|
||||
2.0 (old stable) - https://github.com/inspircd/inspircd/tree/insp20/docs/conf
|
||||
Example configs: https://github.com/inspircd/inspircd/tree/insp3/docs/conf
|
||||
-->
|
||||
|
||||
**Description**
|
||||
|
2
configure
vendored
2
configure
vendored
@ -78,7 +78,7 @@ my @opt_disableextras;
|
||||
|
||||
exit 1 unless GetOptions(
|
||||
'clean' => \&cmd_clean,
|
||||
'help' => \&cmd_help,
|
||||
'help' => \&cmd_help,
|
||||
'update' => \&cmd_update,
|
||||
|
||||
'binary-dir=s' => \$opt_binary_dir,
|
||||
|
@ -42,7 +42,7 @@ class CoreExport Channel : public Extensible
|
||||
public:
|
||||
/** A map of Memberships on a channel keyed by User pointers
|
||||
*/
|
||||
typedef std::map<User*, insp::aligned_storage<Membership> > MemberMap;
|
||||
typedef std::map<User*, insp::aligned_storage<Membership> > MemberMap;
|
||||
|
||||
private:
|
||||
/** Set default modes for the channel on creation
|
||||
@ -117,23 +117,23 @@ class CoreExport Channel : public Extensible
|
||||
void SetMode(ModeHandler* mode, bool value);
|
||||
|
||||
/** Returns true if a mode is set on a channel
|
||||
* @param mode The mode character you wish to query
|
||||
* @return True if the custom mode is set, false if otherwise
|
||||
*/
|
||||
* @param mode The mode character you wish to query
|
||||
* @return True if the custom mode is set, false if otherwise
|
||||
*/
|
||||
bool IsModeSet(ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); }
|
||||
bool IsModeSet(ModeHandler& mode) { return IsModeSet(&mode); }
|
||||
bool IsModeSet(ChanModeReference& mode);
|
||||
|
||||
/** Returns the parameter for a custom mode on a channel.
|
||||
* @param mode The mode character you wish to query
|
||||
*
|
||||
* For example if "+L #foo" is set, and you pass this method
|
||||
* 'L', it will return '\#foo'. If the mode is not set on the
|
||||
* channel, or the mode has no parameters associated with it,
|
||||
* it will return an empty string.
|
||||
*
|
||||
* @return The parameter for this mode is returned, or an empty string
|
||||
*/
|
||||
* @param mode The mode character you wish to query
|
||||
*
|
||||
* For example if "+L #foo" is set, and you pass this method
|
||||
* 'L', it will return '\#foo'. If the mode is not set on the
|
||||
* channel, or the mode has no parameters associated with it,
|
||||
* it will return an empty string.
|
||||
*
|
||||
* @return The parameter for this mode is returned, or an empty string
|
||||
*/
|
||||
std::string GetModeParameter(ModeHandler* mode);
|
||||
std::string GetModeParameter(ChanModeReference& mode);
|
||||
std::string GetModeParameter(ParamModeBase* pm);
|
||||
|
@ -249,7 +249,7 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
|
||||
: ptr(NULL)
|
||||
, owned(true)
|
||||
{
|
||||
new(str) std::string(s);
|
||||
new(str) std::string(s);
|
||||
}
|
||||
|
||||
Param(const Param& other)
|
||||
|
@ -34,7 +34,7 @@
|
||||
class CoreExport CommandParser
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<std::string, Command*, irc::insensitive, irc::StrHashComp> CommandMap;
|
||||
typedef std::unordered_map<std::string, Command*, irc::insensitive, irc::StrHashComp> CommandMap;
|
||||
|
||||
private:
|
||||
/** Process a command from a user.
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
Items items;
|
||||
|
||||
public:
|
||||
/** The name of the configuration tag (e.g. "foo" for \<foo bar="baz">). */
|
||||
/** The name of the configuration tag (e.g. "foo" for \<foo bar="baz">). */
|
||||
const std::string name;
|
||||
|
||||
/** The position within the source file that this tag was read from. */
|
||||
|
@ -73,7 +73,7 @@ class CoreExport CullList
|
||||
class CoreExport ActionBase : public Cullable
|
||||
{
|
||||
public:
|
||||
/** Executes this action. */
|
||||
/** Executes this action. */
|
||||
virtual void Call() = 0;
|
||||
};
|
||||
|
||||
|
@ -214,7 +214,7 @@ class CoreExport StreamSocket : public EventHandler
|
||||
}
|
||||
|
||||
private:
|
||||
/** Private send queue. Note that individual strings may be shared.
|
||||
/** Private send queue. Note that individual strings may be shared.
|
||||
*/
|
||||
Container data;
|
||||
|
||||
@ -274,7 +274,7 @@ class CoreExport StreamSocket : public EventHandler
|
||||
* @param hook Next IOHook in the chain, can be NULL
|
||||
* @param rq Receive queue to put incoming data into
|
||||
* @return < 0 on error or close, 0 if no new data is ready (but the socket is still connected), > 0 if data was read from
|
||||
the socket and put into the recvq
|
||||
* the socket and put into the recvq
|
||||
*/
|
||||
int HookChainRead(IOHook* hook, std::string& rq);
|
||||
|
||||
|
@ -26,7 +26,7 @@ class IOHookProvider
|
||||
: public std::enable_shared_from_this<IOHookProvider>
|
||||
, public ServiceProvider
|
||||
{
|
||||
const bool middlehook;
|
||||
const bool middlehook;
|
||||
|
||||
public:
|
||||
enum Type
|
||||
|
@ -42,7 +42,7 @@ class CoreExport MessageDetails
|
||||
/** Whether to update the source user's idle time. */
|
||||
bool update_idle = true;
|
||||
|
||||
/** The users who are exempted from receiving this message. */
|
||||
/** The users who are exempted from receiving this message. */
|
||||
CUList exemptions;
|
||||
|
||||
/* The original message as sent by the user. */
|
||||
|
@ -99,7 +99,7 @@ class ParamModeBase;
|
||||
class CoreExport ModeHandler : public ServiceProvider
|
||||
{
|
||||
public:
|
||||
typedef size_t Id;
|
||||
typedef size_t Id;
|
||||
|
||||
enum Class
|
||||
{
|
||||
@ -570,7 +570,7 @@ class CoreExport ModeParser
|
||||
private:
|
||||
/** Type of the container that maps mode names to ModeWatchers
|
||||
*/
|
||||
typedef insp::flat_multimap<std::string, ModeWatcher*> ModeWatcherMap;
|
||||
typedef insp::flat_multimap<std::string, ModeWatcher*> ModeWatcherMap;
|
||||
|
||||
/** Last item in the ModeType enum
|
||||
*/
|
||||
|
@ -28,7 +28,7 @@ namespace CallerID
|
||||
class CallerID::APIBase : public DataProvider
|
||||
{
|
||||
public:
|
||||
APIBase(Module* parent)
|
||||
APIBase(Module* parent)
|
||||
: DataProvider(parent, "m_callerid_api")
|
||||
{
|
||||
}
|
||||
|
@ -174,8 +174,8 @@ namespace DNS
|
||||
/* Use result cache if available */
|
||||
bool use_cache;
|
||||
/* Request id */
|
||||
RequestId id = 0;
|
||||
/* Creator of this request */
|
||||
RequestId id = 0;
|
||||
/* Creator of this request */
|
||||
Module* const creator;
|
||||
|
||||
Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true, unsigned int timeout = 0)
|
||||
|
@ -84,7 +84,7 @@ class Regex::SimpleEngine final
|
||||
: public Regex::Engine
|
||||
{
|
||||
public:
|
||||
/** @copydoc Regex::Engine::Engine */
|
||||
/** @copydoc Regex::Engine::Engine */
|
||||
SimpleEngine(Module* Creator, const std::string& Name)
|
||||
: Regex::Engine(Creator, Name)
|
||||
{
|
||||
|
@ -239,7 +239,7 @@ class SSLIOHook : public IOHook
|
||||
class SSLClientCert
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Get the client certificate from a socket
|
||||
* @param sock The socket to get the certificate from, the socket does not have to use TLS
|
||||
* @return The TLS client certificate information, NULL if the peer is not using TLS
|
||||
@ -272,7 +272,7 @@ class SSLClientCert
|
||||
class UserCertificateAPIBase : public DataProvider
|
||||
{
|
||||
public:
|
||||
UserCertificateAPIBase(Module* parent)
|
||||
UserCertificateAPIBase(Module* parent)
|
||||
: DataProvider(parent, "m_sslinfo_api")
|
||||
{
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
class CoreExport ParamModeBase : public ModeHandler
|
||||
{
|
||||
private:
|
||||
virtual void OnUnsetInternal(User* source, Channel* chan) = 0;
|
||||
virtual void OnUnsetInternal(User* source, Channel* chan) = 0;
|
||||
|
||||
public:
|
||||
ParamModeBase(Module* Creator, const std::string& Name, char modeletter, ParamSpec ps)
|
||||
|
@ -44,7 +44,7 @@ class CoreExport Serializable
|
||||
EntryMap entries;
|
||||
|
||||
public:
|
||||
/** Retrieves the child elements. */
|
||||
/** Retrieves the child elements. */
|
||||
const ChildMap& GetChildren() const { return children; }
|
||||
ChildMap& GetChildren() { return children; }
|
||||
|
||||
|
@ -61,8 +61,8 @@ enum RegistrationState {
|
||||
|
||||
REG_USER = 1, /* Has sent USER */
|
||||
REG_NICK = 2, /* Has sent NICK */
|
||||
REG_NICKUSER = 3, /* Bitwise combination of REG_NICK and REG_USER */
|
||||
REG_ALL = 7 /* REG_NICKUSER plus next bit along */
|
||||
REG_NICKUSER = 3, /* Bitwise combination of REG_NICK and REG_USER */
|
||||
REG_ALL = 7 /* REG_NICKUSER plus next bit along */
|
||||
};
|
||||
|
||||
/** Holds information relevant to <connect allow> and <connect deny> tags in the config file.
|
||||
@ -632,7 +632,7 @@ class CoreExport User : public Extensible
|
||||
class CoreExport UserIOHandler : public StreamSocket
|
||||
{
|
||||
private:
|
||||
size_t checked_until;
|
||||
size_t checked_until;
|
||||
public:
|
||||
LocalUser* const user;
|
||||
UserIOHandler(LocalUser* me)
|
||||
|
@ -28,7 +28,7 @@ namespace insp
|
||||
class insp::uncopiable
|
||||
{
|
||||
private:
|
||||
/** Prevents copying via the copy constructor. */
|
||||
/** Prevents copying via the copy constructor. */
|
||||
uncopiable(const uncopiable&) = delete;
|
||||
|
||||
/** Prevents copying via the assignment operator. */
|
||||
|
@ -491,7 +491,7 @@ bool ConfigTag::readString(const std::string& key, std::string& value, bool allo
|
||||
continue;
|
||||
|
||||
value = ivalue;
|
||||
if (!allow_lf && (value.find('\n') != std::string::npos))
|
||||
if (!allow_lf && (value.find('\n') != std::string::npos))
|
||||
{
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + name + ":" + key + "> at " + source.str() +
|
||||
" contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces.");
|
||||
|
@ -468,8 +468,8 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
|
||||
|
||||
auto binds = ConfTags("bind");
|
||||
if (binds.empty())
|
||||
errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
|
||||
<< "You will need to do this if you want clients to be able to connect!" << std::endl;
|
||||
errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
|
||||
<< "You will need to do this if you want clients to be able to connect!" << std::endl;
|
||||
|
||||
if (old && valid)
|
||||
{
|
||||
|
@ -211,7 +211,13 @@ class Packet : public Query
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (pos + rdlength > input_size)
|
||||
throw Exception("Unable to skip resource record");
|
||||
|
||||
pos += rdlength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!record.name.empty() && !record.rdata.empty())
|
||||
|
@ -62,8 +62,7 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters)
|
||||
}
|
||||
|
||||
bool has_priv = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex");
|
||||
const ModuleManager::ModuleMap& mods = ServerInstance->Modules.GetModules();
|
||||
for (const auto& [modname, mod] : mods)
|
||||
for (const auto& [modname, mod] : ServerInstance->Modules.GetModules())
|
||||
{
|
||||
const char* version = has_priv ? mod->ModuleDLLManager->GetVersion() : "*";
|
||||
const std::string props = has_priv ? mod->GetPropertyString() : "*";
|
||||
|
@ -31,10 +31,10 @@ static ClientProtocol::Serializer* dummyserializer;
|
||||
|
||||
class DummySerializer : public ClientProtocol::Serializer
|
||||
{
|
||||
bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientProtocol::SerializedMessage Serialize(const ClientProtocol::Message& msg, const ClientProtocol::TagSelection& tagwl) const override
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ class RFCSerializer : public ClientProtocol::Serializer
|
||||
{
|
||||
}
|
||||
|
||||
bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) override;
|
||||
bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) override;
|
||||
ClientProtocol::SerializedMessage Serialize(const ClientProtocol::Message& msg, const ClientProtocol::TagSelection& tagwl) const override;
|
||||
};
|
||||
|
||||
|
@ -167,7 +167,7 @@ class CommandUsers
|
||||
class CoreModStub : public Module
|
||||
{
|
||||
private:
|
||||
CommandCapab cmdcapab;
|
||||
CommandCapab cmdcapab;
|
||||
CommandConnect cmdconnect;
|
||||
CommandLinks cmdlinks;
|
||||
CommandSquit cmdsquit;
|
||||
|
@ -78,10 +78,10 @@ class CommandWhois : public SplitCommand
|
||||
void SendChanList(WhoisContextImpl& whois);
|
||||
|
||||
public:
|
||||
/** If true then all opers are shown with a generic 'is a server operator' line rather than the oper type. */
|
||||
/** If true then all opers are shown with a generic 'is a server operator' line rather than the oper type. */
|
||||
bool genericoper;
|
||||
|
||||
/** How to handle private/secret channels in the WHOIS response. */
|
||||
/** How to handle private/secret channels in the WHOIS response. */
|
||||
SplitWhoisState splitwhois;
|
||||
|
||||
|
||||
|
@ -271,7 +271,7 @@ bool InspIRCd::IsSID(const std::string &str)
|
||||
*/
|
||||
return ((str.length() == 3) && isdigit(str[0]) &&
|
||||
((str[1] >= 'A' && str[1] <= 'Z') || isdigit(str[1])) &&
|
||||
((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2])));
|
||||
((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2])));
|
||||
}
|
||||
|
||||
/** A lookup table of values for multiplier characters used by
|
||||
|
@ -552,7 +552,7 @@ void ModeParser::CleanMask(std::string &mask)
|
||||
else if ((pos_of_pling == std::string::npos) && (pos_of_at != std::string::npos))
|
||||
{
|
||||
/* Has an @ but no !, its a user@host */
|
||||
mask = "*!" + mask;
|
||||
mask = "*!" + mask;
|
||||
}
|
||||
else if ((pos_of_pling != std::string::npos) && (pos_of_at == std::string::npos))
|
||||
{
|
||||
@ -734,9 +734,9 @@ std::string ModeParser::GiveModeList(ModeType mt)
|
||||
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
|
||||
{
|
||||
ModeHandler* mh = modehandlers[mt][mode-65];
|
||||
/* One parameter when adding */
|
||||
if (mh)
|
||||
{
|
||||
/* One parameter when adding */
|
||||
if (mh->NeedsParam(true))
|
||||
{
|
||||
PrefixMode* pm = mh->IsPrefixMode();
|
||||
|
@ -146,15 +146,15 @@ void Module::OnChangeIdent(User*, const std::string&) { DetachEvent(I_OnChangeI
|
||||
void Module::OnAddLine(User*, XLine*) { DetachEvent(I_OnAddLine); }
|
||||
void Module::OnDelLine(User*, XLine*) { DetachEvent(I_OnDelLine); }
|
||||
void Module::OnExpireLine(XLine*) { DetachEvent(I_OnExpireLine); }
|
||||
void Module::OnCleanup(ExtensionItem::ExtensibleType, Extensible*) { }
|
||||
void Module::OnCleanup(ExtensionItem::ExtensibleType, Extensible*) { }
|
||||
ModResult Module::OnChannelPreDelete(Channel*) { DetachEvent(I_OnChannelPreDelete); return MOD_RES_PASSTHRU; }
|
||||
void Module::OnChannelDelete(Channel*) { DetachEvent(I_OnChannelDelete); }
|
||||
void Module::OnBuildNeighborList(User*, IncludeChanList&, std::map<User*,bool>&) { DetachEvent(I_OnBuildNeighborList); }
|
||||
void Module::OnGarbageCollect() { DetachEvent(I_OnGarbageCollect); }
|
||||
ModResult Module::OnSetConnectClass(LocalUser* user, std::shared_ptr<ConnectClass> myclass) { DetachEvent(I_OnSetConnectClass); return MOD_RES_PASSTHRU; }
|
||||
void Module::OnUserMessage(User*, const MessageTarget&, const MessageDetails&) { DetachEvent(I_OnUserMessage); }
|
||||
void Module::OnUserMessage(User*, const MessageTarget&, const MessageDetails&) { DetachEvent(I_OnUserMessage); }
|
||||
ModResult Module::OnNumeric(User*, const Numeric::Numeric&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; }
|
||||
ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; }
|
||||
ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; }
|
||||
void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); }
|
||||
void Module::OnServiceAdd(ServiceProvider&) { DetachEvent(I_OnServiceAdd); }
|
||||
void Module::OnServiceDel(ServiceProvider&) { DetachEvent(I_OnServiceDel); }
|
||||
|
@ -185,11 +185,11 @@ class PgSQLresult : public SQL::Result
|
||||
class SQLConn : public SQL::Provider, public EventHandler
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<ConfigTag> conf; /* The <database> entry */
|
||||
std::shared_ptr<ConfigTag> conf; /* The <database> entry */
|
||||
std::deque<QueueItem> queue;
|
||||
PGconn* sql = nullptr; /* PgSQL database connection handle */
|
||||
SQLstatus status = CWRITE; /* PgSQL database connection status */
|
||||
QueueItem qinprog; /* If there is currently a query in progress */
|
||||
PGconn* sql = nullptr; /* PgSQL database connection handle */
|
||||
SQLstatus status = CWRITE; /* PgSQL database connection status */
|
||||
QueueItem qinprog; /* If there is currently a query in progress */
|
||||
|
||||
SQLConn(Module* Creator, std::shared_ptr<ConfigTag> tag)
|
||||
: SQL::Provider(Creator, tag->getString("id"))
|
||||
|
@ -37,7 +37,7 @@
|
||||
/// $PackageInfo: require_system("centos") gnutls-devel pkgconfig
|
||||
/// $PackageInfo: require_system("darwin") gnutls pkg-config
|
||||
/// $PackageInfo: require_system("debian") gnutls-bin libgnutls28-dev pkg-config
|
||||
/// $PackageInfo: require_system("ubuntu") gnutls-bin libgnutls-dev pkg-config
|
||||
/// $PackageInfo: require_system("ubuntu") gnutls-bin libgnutls28-dev pkg-config
|
||||
|
||||
#include "inspircd.h"
|
||||
#include "modules/ssl.h"
|
||||
@ -1079,7 +1079,7 @@ class GnuTLSIOHookProvider : public SSLIOHookProvider
|
||||
GnuTLS::Profile profile;
|
||||
|
||||
public:
|
||||
GnuTLSIOHookProvider(Module* mod, GnuTLS::Profile::Config& config)
|
||||
GnuTLSIOHookProvider(Module* mod, GnuTLS::Profile::Config& config)
|
||||
: SSLIOHookProvider(mod, config.name)
|
||||
, profile(config)
|
||||
{
|
||||
|
@ -810,7 +810,7 @@ class mbedTLSIOHookProvider : public SSLIOHookProvider
|
||||
mbedTLS::Profile profile;
|
||||
|
||||
public:
|
||||
mbedTLSIOHookProvider(Module* mod, mbedTLS::Profile::Config& config)
|
||||
mbedTLSIOHookProvider(Module* mod, mbedTLS::Profile::Config& config)
|
||||
: SSLIOHookProvider(mod, config.name)
|
||||
, profile(config)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ enum
|
||||
class callerid_data
|
||||
{
|
||||
public:
|
||||
typedef insp::flat_set<User*> UserSet;
|
||||
typedef insp::flat_set<User*> UserSet;
|
||||
typedef std::vector<callerid_data*> CallerIdDataSet;
|
||||
|
||||
time_t lastnotify = 0;
|
||||
|
@ -75,8 +75,6 @@ class CBanFactory : public XLineFactory
|
||||
public:
|
||||
CBanFactory() : XLineFactory("CBAN") { }
|
||||
|
||||
/** Generate a CBAN
|
||||
*/
|
||||
XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
|
||||
{
|
||||
return new CBan(set_time, duration, source, reason, xline_specific_mask);
|
||||
@ -204,7 +202,7 @@ class ModuleCBan : public Module, public Stats::EventListener
|
||||
// Channel is banned.
|
||||
user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is CBANed: %s", cname.c_str(), rl->reason.c_str()));
|
||||
ServerInstance->SNO.WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)",
|
||||
user->nick.c_str(), cname.c_str(), rl->reason.c_str());
|
||||
user->nick.c_str(), cname.c_str(), rl->reason.c_str());
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ class ModuleClassBan
|
||||
ClassExtBan extban;
|
||||
|
||||
public:
|
||||
ModuleClassBan()
|
||||
: Module(VF_VENDOR | VF_OPTCOMMON, "Adds the n extended ban which check whether users are in a connect class matching the specified glob pattern.")
|
||||
ModuleClassBan()
|
||||
: Module(VF_VENDOR | VF_OPTCOMMON, "Adds the n extended ban which check whether users are in a connect class matching the specified glob pattern.")
|
||||
, extban(this)
|
||||
{
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class CommandClones : public SplitCommand
|
||||
IRCv3::Batch::Batch batch;
|
||||
|
||||
public:
|
||||
CommandClones(Module* Creator)
|
||||
CommandClones(Module* Creator)
|
||||
: SplitCommand(Creator,"CLONES", 1)
|
||||
, batchmanager(Creator)
|
||||
, batch("inspircd.org/clones")
|
||||
|
@ -352,7 +352,7 @@ class CommandDccallow : public Command
|
||||
|
||||
void DisplayDCCAllowList(User* user)
|
||||
{
|
||||
// display current DCCALLOW list
|
||||
// display current DCCALLOW list
|
||||
user->WriteNumeric(RPL_DCCALLOWSTART, "Users on your DCCALLOW list:");
|
||||
|
||||
dl = ext.Get(user);
|
||||
|
@ -110,7 +110,7 @@ struct HAProxyHeader
|
||||
class HAProxyHookProvider : public IOHookProvider
|
||||
{
|
||||
private:
|
||||
UserCertificateAPI sslapi;
|
||||
UserCertificateAPI sslapi;
|
||||
|
||||
public:
|
||||
HAProxyHookProvider(Module* mod)
|
||||
|
@ -89,7 +89,7 @@ class ModeHook : public ClientProtocol::EventHook
|
||||
const Modes::Change& curr = *i;
|
||||
if (settings.GetRequiredRank(*curr.mh) <= rank)
|
||||
{
|
||||
// No restriction on who can see this mode or there is one but the member's rank is sufficient
|
||||
// No restriction on who can see this mode or there is one but the member's rank is sufficient
|
||||
if (modechangelist)
|
||||
modechangelist->push(curr);
|
||||
|
||||
|
@ -341,7 +341,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
|
||||
{
|
||||
if (pathsegment == ".")
|
||||
{
|
||||
// Stay at the current level.
|
||||
// Stay at the current level.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ModuleHTTPAccessList : public Module, public HTTPACLEventListener
|
||||
HTTPdAPI API;
|
||||
|
||||
public:
|
||||
ModuleHTTPAccessList()
|
||||
ModuleHTTPAccessList()
|
||||
: Module(VF_VENDOR, "Allows the server administrator to control who can access resources served over HTTP with the httpd module.")
|
||||
, HTTPACLEventListener(this)
|
||||
, API(this)
|
||||
|
@ -51,10 +51,10 @@ class JoinHook : public ClientProtocol::EventHook
|
||||
ClientProtocol::Events::Join extendedjoinmsg;
|
||||
|
||||
public:
|
||||
const std::string asterisk;
|
||||
const std::string asterisk;
|
||||
ClientProtocol::EventProvider awayprotoev;
|
||||
AwayMessage awaymsg;
|
||||
Cap::Capability extendedjoincap;
|
||||
Cap::Capability extendedjoincap;
|
||||
Cap::Capability awaycap;
|
||||
|
||||
JoinHook(Module* mod)
|
||||
|
@ -59,12 +59,12 @@ struct IRCv3::Batch::BatchInfo
|
||||
|
||||
class IRCv3::Batch::ManagerImpl : public Manager
|
||||
{
|
||||
typedef std::vector<Batch*> BatchList;
|
||||
typedef std::vector<Batch*> BatchList;
|
||||
|
||||
Cap::Capability cap;
|
||||
ClientProtocol::EventProvider protoevprov;
|
||||
IntExtItem batchbits;
|
||||
BatchList active_batches;
|
||||
BatchList active_batches;
|
||||
bool unloading = false;
|
||||
|
||||
bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) override
|
||||
|
@ -325,7 +325,7 @@ public:
|
||||
whitelistedcidrs.clear();
|
||||
requiredattributes.clear();
|
||||
|
||||
base = tag->getString("baserdn");
|
||||
base = tag->getString("baserdn");
|
||||
attribute = tag->getString("attribute");
|
||||
killreason = tag->getString("killreason");
|
||||
vhost = tag->getString("host");
|
||||
|
@ -188,7 +188,7 @@ class IRCv3::Monitor::Manager
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<std::string, Entry, irc::insensitive, irc::StrHashComp> NickHash;
|
||||
typedef std::unordered_map<std::string, Entry, irc::insensitive, irc::StrHashComp> NickHash;
|
||||
|
||||
Entry* Find(const std::string& nick)
|
||||
{
|
||||
@ -237,9 +237,9 @@ class IRCv3::Monitor::Manager
|
||||
return &extdata->list;
|
||||
}
|
||||
|
||||
NickHash nicks;
|
||||
ExtItem ext;
|
||||
WatchedList emptywatchedlist;
|
||||
NickHash nicks;
|
||||
ExtItem ext;
|
||||
WatchedList emptywatchedlist;
|
||||
};
|
||||
|
||||
void IRCv3::Monitor::Manager::ExtItem::FromInternal(Extensible* container, const std::string& value) noexcept
|
||||
|
@ -40,7 +40,6 @@ class lwbNickHandler
|
||||
static bool Call(const std::string&);
|
||||
};
|
||||
|
||||
/*,m_reverse_additionalUp[256];*/
|
||||
static unsigned char m_reverse_additional[256],m_additionalMB[256],m_additionalUtf8[256],m_additionalUtf8range[256],m_additionalUtf8interval[256];
|
||||
|
||||
char utf8checkrest(unsigned char * mb, unsigned char cnt)
|
||||
@ -411,7 +410,7 @@ class ModuleNationalChars : public Module
|
||||
if (*p == '0')
|
||||
{
|
||||
if (p[1] == 'x')
|
||||
/* hex with the leading "0x" */
|
||||
/* hex with the leading "0x" */
|
||||
chartable[i] = symtoi(p + 2, 16);
|
||||
else
|
||||
chartable[i] = symtoi(p + 1, 8);
|
||||
@ -420,12 +419,13 @@ class ModuleNationalChars : public Module
|
||||
else if (*p == 'x')
|
||||
{
|
||||
chartable[i] = symtoi(p + 1, 16);
|
||||
}else /* decimal form */
|
||||
}
|
||||
else /* decimal form */
|
||||
{
|
||||
chartable[i] = symtoi(p, 10);
|
||||
}
|
||||
}
|
||||
else /* plain-text char between '' */
|
||||
else /* plain-text char between '' */
|
||||
{
|
||||
if (*(p + 1) == '\\')
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ class CommandOjoin : public SplitCommand
|
||||
// Make sure the channel name is allowable.
|
||||
if (!ServerInstance->Channels.IsChannel(parameters[0]))
|
||||
{
|
||||
user->WriteNotice("*** Invalid characters in channel name or name too long");
|
||||
user->WriteNumeric(ERR_BADCHANMASK, parameters[0], "Invalid channel name");
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class RemoveBase : public Command
|
||||
ChanModeReference& nokicksmode;
|
||||
|
||||
public:
|
||||
unsigned int protectedrank;
|
||||
unsigned int protectedrank;
|
||||
|
||||
RemoveBase(Module* Creator, bool& snk, ChanModeReference& nkm, const char* cmdn)
|
||||
: Command(Creator, cmdn, 2, 3)
|
||||
@ -109,7 +109,7 @@ class RemoveBase : public Command
|
||||
{
|
||||
/* We'll let everyone remove their level and below, eg:
|
||||
* ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1)
|
||||
a services target will get a higher level than it's possible for a /remover to get..so they're safe.
|
||||
* a services target will get a higher level than it's possible for a /remover to get..so they're safe.
|
||||
* Nobody may remove people with >= protectedrank rank.
|
||||
*/
|
||||
unsigned int ulevel = channel->GetPrefixValue(user);
|
||||
|
@ -30,7 +30,7 @@
|
||||
class ChannelSettings
|
||||
{
|
||||
public:
|
||||
enum RepeatAction
|
||||
enum RepeatAction
|
||||
{
|
||||
ACT_KICK,
|
||||
ACT_BLOCK,
|
||||
@ -125,7 +125,7 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
|
||||
}
|
||||
|
||||
public:
|
||||
ModuleSettings ms;
|
||||
ModuleSettings ms;
|
||||
SimpleExtItem<MemberInfo> MemberInfoExt;
|
||||
|
||||
RepeatMode(Module* Creator)
|
||||
|
@ -210,7 +210,7 @@ class ModuleRLine
|
||||
, public Stats::EventListener
|
||||
{
|
||||
private:
|
||||
Regex::EngineReference rxfactory;
|
||||
Regex::EngineReference rxfactory;
|
||||
RLineFactory f;
|
||||
CommandRLine r;
|
||||
bool MatchOnNickChange;
|
||||
|
@ -66,7 +66,7 @@ class CommandSajoin : public Command
|
||||
if (IS_LOCAL(user) && !ServerInstance->Channels.IsChannel(channel))
|
||||
{
|
||||
/* we didn't need to check this for each character ;) */
|
||||
user->WriteNotice("*** Invalid characters in channel name or name too long");
|
||||
user->WriteNumeric(ERR_BADCHANMASK, channel, "Invalid channel name");
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
|
@ -287,13 +287,13 @@ class SaslAuthenticator
|
||||
|
||||
switch (this->result)
|
||||
{
|
||||
case SASL_OK:
|
||||
case SASL_OK:
|
||||
this->user->WriteNumeric(RPL_SASLSUCCESS, "SASL authentication successful");
|
||||
break;
|
||||
case SASL_ABORT:
|
||||
case SASL_ABORT:
|
||||
this->user->WriteNumeric(ERR_SASLABORTED, "SASL authentication aborted");
|
||||
break;
|
||||
case SASL_FAIL:
|
||||
case SASL_FAIL:
|
||||
this->user->WriteNumeric(ERR_SASLFAIL, "SASL authentication failed");
|
||||
break;
|
||||
}
|
||||
@ -305,8 +305,8 @@ class SaslAuthenticator
|
||||
class CommandAuthenticate : public SplitCommand
|
||||
{
|
||||
private:
|
||||
// The maximum length of an AUTHENTICATE request.
|
||||
static const size_t MAX_AUTHENTICATE_SIZE = 400;
|
||||
// The maximum length of an AUTHENTICATE request.
|
||||
static const size_t MAX_AUTHENTICATE_SIZE = 400;
|
||||
|
||||
public:
|
||||
SimpleExtItem<SaslAuthenticator>& authExt;
|
||||
|
@ -166,7 +166,7 @@ class SHA1Context
|
||||
class SHA1HashProvider : public HashProvider
|
||||
{
|
||||
public:
|
||||
SHA1HashProvider(Module* mod)
|
||||
SHA1HashProvider(Module* mod)
|
||||
: HashProvider(mod, "sha1", 20, 64)
|
||||
{
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ class ShunFactory : public XLineFactory
|
||||
public:
|
||||
ShunFactory() : XLineFactory("SHUN") { }
|
||||
|
||||
/** Generate a shun
|
||||
*/
|
||||
XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
|
||||
{
|
||||
return new Shun(set_time, duration, source, reason, xline_specific_mask);
|
||||
|
@ -146,7 +146,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
|
||||
{
|
||||
if (user->IsOper())
|
||||
{
|
||||
ShowLinks(server, user, hops+1);
|
||||
ShowLinks(server, user, hops+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -78,8 +78,7 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo
|
||||
* if ident@ip is equal, and theirs is newer, or
|
||||
* ident@ip differ, and ours is newer
|
||||
*/
|
||||
if((SamePerson && remotets < localts) ||
|
||||
(!SamePerson && remotets > localts))
|
||||
if ((SamePerson && remotets < localts) || (!SamePerson && remotets > localts))
|
||||
{
|
||||
// Only remote needs to change
|
||||
bChangeLocal = false;
|
||||
|
@ -54,7 +54,7 @@ ModResult ModuleSpanningTree::HandleSquit(const CommandBase::Params& parameters,
|
||||
}
|
||||
else
|
||||
{
|
||||
user->WriteNotice("*** SQUIT: The server \002" + parameters[0] + "\002 does not exist on the network.");
|
||||
user->WriteNotice("*** SQUIT: The server \002" + parameters[0] + "\002 does not exist on the network.");
|
||||
}
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
@ -55,10 +55,10 @@
|
||||
* CONNECTING: indicates an outbound socket which is
|
||||
* waiting to be writeable.
|
||||
* WAIT_AUTH_1: indicates the socket is outbound and
|
||||
* has successfully connected, but has not
|
||||
* has successfully connected, but has not
|
||||
* yet sent and received SERVER strings.
|
||||
* WAIT_AUTH_2: indicates that the socket is inbound
|
||||
* but has not yet sent and received
|
||||
* but has not yet sent and received
|
||||
* SERVER strings.
|
||||
* CONNECTED: represents a fully authorized, fully
|
||||
* connected server.
|
||||
|
@ -50,7 +50,7 @@ class SpanningTreeUtilities : public Cullable
|
||||
CacheRefreshTimer RefreshTimer;
|
||||
|
||||
public:
|
||||
typedef std::set<TreeSocket*> TreeSocketSet;
|
||||
typedef std::set<TreeSocket*> TreeSocketSet;
|
||||
typedef std::map<TreeSocket*, std::pair<std::string, unsigned int> > TimeoutList;
|
||||
|
||||
/** Creator module
|
||||
|
@ -239,7 +239,10 @@ class CommandSSLInfo : public SplitCommand
|
||||
}
|
||||
|
||||
for (const auto& [u, _] : chan->GetUsers())
|
||||
HandleUserInternal(source, u, false);
|
||||
{
|
||||
if (!u->server->IsService())
|
||||
HandleUserInternal(source, u, false);
|
||||
}
|
||||
|
||||
return CmdResult::SUCCESS;
|
||||
}
|
||||
|
@ -81,8 +81,6 @@ class SVSHoldFactory : public XLineFactory
|
||||
public:
|
||||
SVSHoldFactory() : XLineFactory("SVSHOLD") { }
|
||||
|
||||
/** Generate an SVSHOLD
|
||||
*/
|
||||
XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
|
||||
{
|
||||
return new SVSHold(set_time, duration, source, reason, xline_specific_mask);
|
||||
|
@ -25,7 +25,8 @@
|
||||
#include "iohook.h"
|
||||
#include "modules/hash.h"
|
||||
|
||||
#include <utf8.h>
|
||||
#define UTF_CPP_CPLUSPLUS 199711L
|
||||
#include <unchecked.h>
|
||||
|
||||
static const char MagicGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
static const char whitespace[] = " \t\r\n";
|
||||
@ -339,6 +340,11 @@ class WebSocketHook : public IOHookMiddle
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FailHandshake(sock, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n", "WebSocket: Received HTTP request that did not send the Origin header");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!allowedorigin)
|
||||
{
|
||||
@ -437,7 +443,7 @@ class WebSocketHook : public IOHookMiddle
|
||||
{
|
||||
// If we send messages as text then we need to ensure they are valid UTF-8.
|
||||
std::string encoded;
|
||||
utf8::replace_invalid(message.begin(), message.end(), std::back_inserter(encoded));
|
||||
utf8::unchecked::replace_invalid(message.begin(), message.end(), std::back_inserter(encoded));
|
||||
|
||||
mysendq.push_back(PrepareSendQElem(encoded.length(), OP_TEXT));
|
||||
mysendq.push_back(encoded);
|
||||
|
@ -49,9 +49,9 @@ class ModuleXLineDB
|
||||
{
|
||||
/* Load the configuration
|
||||
* Note:
|
||||
* This is on purpose not changed on a rehash. It would be non-trivial to change the database on-the-fly.
|
||||
* Imagine a scenario where the new file already exists. Merging the current XLines with the existing database is likely a bad idea
|
||||
* ...and so is discarding all current in-memory XLines for the ones in the database.
|
||||
* This is on purpose not changed on a rehash. It would be non-trivial to change the database on-the-fly.
|
||||
* Imagine a scenario where the new file already exists. Merging the current XLines with the existing database is likely a bad idea
|
||||
* ...and so is discarding all current in-memory XLines for the ones in the database.
|
||||
*/
|
||||
auto Conf = ServerInstance->Config->ConfValue("xlinedb");
|
||||
xlinedbpath = ServerInstance->Config->Paths.PrependData(Conf->getString("filename", "xline.db", 1));
|
||||
@ -120,7 +120,7 @@ class ModuleXLineDB
|
||||
* xline types may not have a conf tag, so let's just write them.
|
||||
* In addition, let's use a file version, so we can maintain some
|
||||
* semblance of backwards compatibility for reading on startup..
|
||||
* -- w00t
|
||||
* -- w00t
|
||||
*/
|
||||
stream << "VERSION 1" << std::endl;
|
||||
|
||||
|
@ -398,7 +398,7 @@ XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pat
|
||||
|
||||
const time_t current = ServerInstance->Time();
|
||||
|
||||
LookupIter safei;
|
||||
LookupIter safei;
|
||||
|
||||
for (LookupIter i = x->second.begin(); i != x->second.end(); )
|
||||
{
|
||||
|
2
vendor/README.md
vendored
2
vendor/README.md
vendored
@ -38,7 +38,7 @@ This directory contains vendored dependencies that are shipped with InspIRCd to
|
||||
|
||||
**License** — Boost Software License
|
||||
|
||||
**Version** — v3.1.2
|
||||
**Version** — v3.2
|
||||
|
||||
**Website** — [https://github.com/nemtrif/utfcpp](https://github.com/nemtrif/utfcpp)
|
||||
|
||||
|
4
vendor/update.toml
vendored
4
vendor/update.toml
vendored
@ -24,8 +24,8 @@ website = "http://www.ouah.org/ogay/sha2/"
|
||||
|
||||
[utfcpp]
|
||||
author = "Nemanja Trifunovic"
|
||||
depth = 1
|
||||
files = "source/{**/*,*}.h"
|
||||
depth = 2
|
||||
files = "source/utf8/{core,unchecked}.h"
|
||||
git = "https://github.com/nemtrif/utfcpp"
|
||||
license = "Boost Software License"
|
||||
|
||||
|
34
vendor/utfcpp/utf8.h
vendored
34
vendor/utfcpp/utf8.h
vendored
@ -1,34 +0,0 @@
|
||||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "utf8/checked.h"
|
||||
#include "utf8/unchecked.h"
|
||||
|
||||
#endif // header guard
|
333
vendor/utfcpp/utf8/checked.h
vendored
333
vendor/utfcpp/utf8/checked.h
vendored
@ -1,333 +0,0 @@
|
||||
// Copyright 2006-2016 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "core.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// Base for the exceptions that may be thrown from the library
|
||||
class exception : public ::std::exception {
|
||||
};
|
||||
|
||||
// Exceptions that may be thrown from the library functions.
|
||||
class invalid_code_point : public exception {
|
||||
uint32_t cp;
|
||||
public:
|
||||
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid code point"; }
|
||||
uint32_t code_point() const {return cp;}
|
||||
};
|
||||
|
||||
class invalid_utf8 : public exception {
|
||||
uint8_t u8;
|
||||
public:
|
||||
invalid_utf8 (uint8_t u) : u8(u) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; }
|
||||
uint8_t utf8_octet() const {return u8;}
|
||||
};
|
||||
|
||||
class invalid_utf16 : public exception {
|
||||
uint16_t u16;
|
||||
public:
|
||||
invalid_utf16 (uint16_t u) : u16(u) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-16"; }
|
||||
uint16_t utf16_word() const {return u16;}
|
||||
};
|
||||
|
||||
class not_enough_room : public exception {
|
||||
public:
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Not enough space"; }
|
||||
};
|
||||
|
||||
/// The library API - functions intended to be called by the users
|
||||
|
||||
template <typename octet_iterator>
|
||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||
{
|
||||
if (!utf8::internal::is_code_point_valid(cp))
|
||||
throw invalid_code_point(cp);
|
||||
|
||||
if (cp < 0x80) // one octet
|
||||
*(result++) = static_cast<uint8_t>(cp);
|
||||
else if (cp < 0x800) { // two octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else if (cp < 0x10000) { // three octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else { // four octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
|
||||
{
|
||||
while (start != end) {
|
||||
octet_iterator sequence_start = start;
|
||||
internal::utf_error err_code = utf8::internal::validate_next(start, end);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
for (octet_iterator it = sequence_start; it != start; ++it)
|
||||
*out++ = *it;
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM:
|
||||
out = utf8::append (replacement, out);
|
||||
start = end;
|
||||
break;
|
||||
case internal::INVALID_LEAD:
|
||||
out = utf8::append (replacement, out);
|
||||
++start;
|
||||
break;
|
||||
case internal::INCOMPLETE_SEQUENCE:
|
||||
case internal::OVERLONG_SEQUENCE:
|
||||
case internal::INVALID_CODE_POINT:
|
||||
out = utf8::append (replacement, out);
|
||||
++start;
|
||||
// just one replacement mark for the sequence
|
||||
while (start != end && utf8::internal::is_trail(*start))
|
||||
++start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
|
||||
{
|
||||
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
|
||||
return utf8::replace_invalid(start, end, out, replacement_marker);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it, octet_iterator end)
|
||||
{
|
||||
uint32_t cp = 0;
|
||||
internal::utf_error err_code = utf8::internal::validate_next(it, end, cp);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM :
|
||||
throw not_enough_room();
|
||||
case internal::INVALID_LEAD :
|
||||
case internal::INCOMPLETE_SEQUENCE :
|
||||
case internal::OVERLONG_SEQUENCE :
|
||||
throw invalid_utf8(*it);
|
||||
case internal::INVALID_CODE_POINT :
|
||||
throw invalid_code_point(cp);
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return utf8::next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it, octet_iterator start)
|
||||
{
|
||||
// can't do much if it == start
|
||||
if (it == start)
|
||||
throw not_enough_room();
|
||||
|
||||
octet_iterator end = it;
|
||||
// Go back until we hit either a lead octet or start
|
||||
while (utf8::internal::is_trail(*(--it)))
|
||||
if (it == start)
|
||||
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
||||
return utf8::peek_next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename distance_type>
|
||||
void advance (octet_iterator& it, distance_type n, octet_iterator end)
|
||||
{
|
||||
const distance_type zero(0);
|
||||
if (n < zero) {
|
||||
// backward
|
||||
for (distance_type i = n; i < zero; ++i)
|
||||
utf8::prior(it, end);
|
||||
} else {
|
||||
// forward
|
||||
for (distance_type i = zero; i < n; ++i)
|
||||
utf8::next(it, end);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
typename std::iterator_traits<octet_iterator>::difference_type
|
||||
distance (octet_iterator first, octet_iterator last)
|
||||
{
|
||||
typename std::iterator_traits<octet_iterator>::difference_type dist;
|
||||
for (dist = 0; first < last; ++dist)
|
||||
utf8::next(first, last);
|
||||
return dist;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = utf8::internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (utf8::internal::is_lead_surrogate(cp)) {
|
||||
if (start != end) {
|
||||
uint32_t trail_surrogate = utf8::internal::mask16(*start++);
|
||||
if (utf8::internal::is_trail_surrogate(trail_surrogate))
|
||||
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
|
||||
}
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
}
|
||||
// Lone trail surrogate
|
||||
else if (utf8::internal::is_trail_surrogate(cp))
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
result = utf8::append(cp, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
|
||||
{
|
||||
while (start < end) {
|
||||
uint32_t cp = utf8::next(start, end);
|
||||
if (cp > 0xffff) { //make a surrogate pair
|
||||
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
*result++ = static_cast<uint16_t>(cp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
result = utf8::append(*(start++), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
|
||||
{
|
||||
while (start < end)
|
||||
(*result++) = utf8::next(start, end);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// The iterator class
|
||||
template <typename octet_iterator>
|
||||
class iterator {
|
||||
octet_iterator it;
|
||||
octet_iterator range_start;
|
||||
octet_iterator range_end;
|
||||
public:
|
||||
typedef uint32_t value_type;
|
||||
typedef uint32_t* pointer;
|
||||
typedef uint32_t& reference;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
iterator () {}
|
||||
explicit iterator (const octet_iterator& octet_it,
|
||||
const octet_iterator& rangestart,
|
||||
const octet_iterator& rangeend) :
|
||||
it(octet_it), range_start(rangestart), range_end(rangeend)
|
||||
{
|
||||
if (it < range_start || it > range_end)
|
||||
throw std::out_of_range("Invalid utf-8 iterator position");
|
||||
}
|
||||
// the default "big three" are OK
|
||||
octet_iterator base () const { return it; }
|
||||
uint32_t operator * () const
|
||||
{
|
||||
octet_iterator temp = it;
|
||||
return utf8::next(temp, range_end);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
if (range_start != rhs.range_start || range_end != rhs.range_end)
|
||||
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
utf8::next(it, range_end);
|
||||
return *this;
|
||||
}
|
||||
iterator operator ++ (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
utf8::next(it, range_end);
|
||||
return temp;
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
utf8::prior(it, range_start);
|
||||
return *this;
|
||||
}
|
||||
iterator operator -- (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
utf8::prior(it, range_start);
|
||||
return temp;
|
||||
}
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||
#include "cpp11.h"
|
||||
#endif // C++ 11 or later
|
||||
|
||||
#endif //header guard
|
||||
|
103
vendor/utfcpp/utf8/cpp11.h
vendored
103
vendor/utfcpp/utf8/cpp11.h
vendored
@ -1,103 +0,0 @@
|
||||
// Copyright 2018 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
||||
#define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
||||
|
||||
#include "checked.h"
|
||||
#include <string>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
|
||||
inline void append(char32_t cp, std::string& s)
|
||||
{
|
||||
append(uint32_t(cp), std::back_inserter(s));
|
||||
}
|
||||
|
||||
inline std::string utf16to8(const std::u16string& s)
|
||||
{
|
||||
std::string result;
|
||||
utf16to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u16string utf8to16(const std::string& s)
|
||||
{
|
||||
std::u16string result;
|
||||
utf8to16(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string utf32to8(const std::u32string& s)
|
||||
{
|
||||
std::string result;
|
||||
utf32to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u32string utf8to32(const std::string& s)
|
||||
{
|
||||
std::u32string result;
|
||||
utf8to32(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::size_t find_invalid(const std::string& s)
|
||||
{
|
||||
std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
|
||||
return (invalid == s.end()) ? std::string::npos : (invalid - s.begin());
|
||||
}
|
||||
|
||||
inline bool is_valid(const std::string& s)
|
||||
{
|
||||
return is_valid(s.begin(), s.end());
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(const std::string& s, char32_t replacement)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool starts_with_bom(const std::string& s)
|
||||
{
|
||||
return starts_with_bom(s.begin(), s.end());
|
||||
}
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
@ -120,7 +120,7 @@ VOID ServiceMain(DWORD argc, LPCSTR *argv)
|
||||
g_ServiceData.argc = argc;
|
||||
|
||||
// Note: since this memory is going to stay allocated for the rest of the execution,
|
||||
// it doesn't make sense to free it, as it's going to be "freed" on process termination
|
||||
// it doesn't make sense to free it, as it's going to be "freed" on process termination
|
||||
try {
|
||||
g_ServiceData.argv = new char*[argc];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user