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
7fa0672ebd
@ -27,7 +27,7 @@ Building from source on Windows is generally not recommended but [a guide is ava
|
||||
<!--
|
||||
TODO: uncomment this once we have binary packages for v4.
|
||||
|
||||
If you are running on CentOS 7, Debian 7, or Windows binary packages are available from [the downloads page](https://github.com/inspircd/inspircd/releases/latest).
|
||||
If you are running on CentOS 7/8, Debian 10/11, Ubuntu 18.04/20.04, or Windows 7+ binary packages are available from [the downloads page](https://github.com/inspircd/inspircd/releases/latest).
|
||||
|
||||
A [Docker](https://www.docker.com) image is also available. See [the inspircd-docker repository](https://github.com/inspircd/inspircd-docker) for more information.
|
||||
-->
|
||||
@ -36,7 +36,7 @@ Some distributions ship an InspIRCd package in their package managers. We genera
|
||||
|
||||
## License
|
||||
|
||||
InspIRCd is licensed under [version 2 of the GNU General Public License](https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html).
|
||||
InspIRCd is licensed under [version 2 of the GNU General Public License](https://docs.inspircd.org/license).
|
||||
|
||||
## External Links
|
||||
|
||||
|
2
configure
vendored
2
configure
vendored
@ -212,7 +212,7 @@ if (defined $opt_portable) {
|
||||
$config{LOG_DIR} = $opt_log_dir // catdir $config{BASE_DIR}, 'var/log/inspircd';
|
||||
$config{MANUAL_DIR} = $opt_manual_dir // catdir $config{BASE_DIR}, 'usr/share/man/man1';
|
||||
$config{MODULE_DIR} = $opt_module_dir // catdir $config{BASE_DIR}, 'usr/lib/inspircd';
|
||||
$config{RUNTIME_DIR} = $opt_runtime_dir // catdir $config{BASE_DIR}, 'var/run/inspircd';
|
||||
$config{RUNTIME_DIR} = $opt_runtime_dir // catdir $config{BASE_DIR}, $^O eq 'linux' ? '/run/inspircd' : '/var/run/inspircd';
|
||||
$config{SCRIPT_DIR} = $opt_script_dir // catdir $config{BASE_DIR}, 'usr/share/inspircd';
|
||||
} else {
|
||||
$config{BASE_DIR} = rel2abs $opt_prefix // $config{BASE_DIR} // catdir $RealDir, 'run';
|
||||
|
@ -122,20 +122,19 @@ Command* CommandParser::GetHandler(const std::string &commandname)
|
||||
|
||||
CmdResult CommandParser::CallHandler(const std::string& commandname, const CommandBase::Params& parameters, User* user, Command** cmd)
|
||||
{
|
||||
CommandMap::iterator n = cmdlist.find(commandname);
|
||||
|
||||
if (n != cmdlist.end())
|
||||
/* find the command, check it exists */
|
||||
Command* handler = GetHandler(commandname);
|
||||
if (handler)
|
||||
{
|
||||
if ((!parameters.empty()) && (parameters.back().empty()) && (!n->second->allow_empty_last_param))
|
||||
if ((!parameters.empty()) && (parameters.back().empty()) && (!handler->allow_empty_last_param))
|
||||
return CmdResult::INVALID;
|
||||
|
||||
if (parameters.size() >= n->second->min_params)
|
||||
if (parameters.size() >= handler->min_params)
|
||||
{
|
||||
bool bOkay = false;
|
||||
|
||||
if (IS_LOCAL(user))
|
||||
{
|
||||
switch (n->second->access_needed)
|
||||
switch (handler->access_needed)
|
||||
{
|
||||
case CmdAccess::NORMAL: // Anyone can execute.
|
||||
bOkay = true;
|
||||
@ -159,10 +158,10 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const Comma
|
||||
if (bOkay)
|
||||
{
|
||||
if (cmd)
|
||||
*cmd = n->second;
|
||||
*cmd = handler;
|
||||
|
||||
ClientProtocol::TagMap tags;
|
||||
return n->second->Handle(user, CommandBase::Params(parameters, tags));
|
||||
return handler->Handle(user, CommandBase::Params(parameters, tags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,12 +40,11 @@ CmdResult CommandOper::HandleLocal(LocalUser* user, const Params& parameters)
|
||||
bool match_pass = false;
|
||||
bool match_hosts = false;
|
||||
|
||||
const std::string userHost = user->ident + "@" + user->GetRealHost();
|
||||
const std::string userIP = user->ident + "@" + user->GetIPString();
|
||||
|
||||
ServerConfig::OperIndex::const_iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]);
|
||||
if (i != ServerInstance->Config->oper_blocks.end())
|
||||
{
|
||||
const std::string userHost = user->ident + "@" + user->GetRealHost();
|
||||
const std::string userIP = user->ident + "@" + user->GetIPString();
|
||||
std::shared_ptr<OperInfo> ifo = i->second;
|
||||
std::shared_ptr<ConfigTag> tag = ifo->oper_block;
|
||||
match_login = true;
|
||||
|
@ -49,7 +49,7 @@ class RFCSerializer : public ClientProtocol::Serializer
|
||||
|
||||
bool RFCSerializer::Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput)
|
||||
{
|
||||
size_t start = line.find_first_not_of(" ");
|
||||
size_t start = line.find_first_not_of(' ');
|
||||
if (start == std::string::npos)
|
||||
{
|
||||
// Discourage the user from flooding the server.
|
||||
|
@ -43,7 +43,6 @@ CommandNick::CommandNick(Module* parent)
|
||||
*/
|
||||
CmdResult CommandNick::HandleLocal(LocalUser* user, const Params& parameters)
|
||||
{
|
||||
std::string oldnick = user->nick;
|
||||
std::string newnick = parameters[0];
|
||||
|
||||
// anything except the initial NICK gets a flood penalty
|
||||
|
@ -93,10 +93,6 @@ void LogManager::OpenFileLogs()
|
||||
{
|
||||
loglevel = LOG_VERBOSE;
|
||||
}
|
||||
else if (stdalgo::string::equalsci(level, "default"))
|
||||
{
|
||||
loglevel = LOG_DEFAULT;
|
||||
}
|
||||
else if (stdalgo::string::equalsci(level, "sparse"))
|
||||
{
|
||||
loglevel = LOG_SPARSE;
|
||||
|
@ -184,7 +184,7 @@ class CloakUser : public ModeHandler
|
||||
* and make it match the displayed one.
|
||||
*/
|
||||
user->SetMode(this, false);
|
||||
user->ChangeDisplayedHost(user->GetRealHost().c_str());
|
||||
user->ChangeDisplayedHost(user->GetRealHost());
|
||||
return MODEACTION_ALLOW;
|
||||
}
|
||||
}
|
||||
|
@ -873,13 +873,14 @@ void ModuleFilter::ReadFilters()
|
||||
std::string reason = tag->getString("reason");
|
||||
std::string action = tag->getString("action");
|
||||
std::string flgs = tag->getString("flags", "*", 1);
|
||||
bool generated = tag->getBool("generated");
|
||||
unsigned long duration = tag->getDuration("duration", 10*60, 1);
|
||||
|
||||
FilterAction fa;
|
||||
if (!StringToFilterAction(action, fa))
|
||||
fa = FA_NONE;
|
||||
|
||||
std::pair<bool, std::string> result = static_cast<ModuleFilter*>(this)->AddFilter(pattern, fa, reason, duration, flgs, !tag->getBool("generated"));
|
||||
std::pair<bool, std::string> result = static_cast<ModuleFilter*>(this)->AddFilter(pattern, fa, reason, duration, flgs, !generated);
|
||||
if (result.first)
|
||||
removedfilters.erase(pattern);
|
||||
else
|
||||
|
@ -166,13 +166,8 @@ class ModuleIRCv3
|
||||
|
||||
void OnUserBack(User* user) override
|
||||
{
|
||||
if (!joinhook.awaycap.IsActive())
|
||||
return;
|
||||
|
||||
// Back from away: n!u@h AWAY
|
||||
AwayMessage msg(user);
|
||||
ClientProtocol::Event awayevent(joinhook.awayprotoev, msg);
|
||||
IRCv3::WriteNeighborsWithCap(user, awayevent, joinhook.awaycap);
|
||||
OnUserAway(user);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,9 +42,9 @@ class lwbNickHandler
|
||||
|
||||
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)
|
||||
char utf8checkrest(unsigned char* mb, unsigned char cnt)
|
||||
{
|
||||
for (unsigned char * tmp=mb; tmp<mb+cnt; tmp++)
|
||||
for (unsigned char* tmp=mb; tmp<mb+cnt; tmp++)
|
||||
{
|
||||
/* & is faster! -- Phoenix (char & b11000000 == b10000000) */
|
||||
if ((*tmp & 192) != 128)
|
||||
@ -89,7 +89,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
{
|
||||
/* otherwise let's take a look at the current character and the following one */
|
||||
bool found = false;
|
||||
for(unsigned char * mb = m_additionalMB; (*mb) && (mb < m_additionalMB + sizeof(m_additionalMB)); mb += 4)
|
||||
for(unsigned char* mb = m_additionalMB; (*mb) && (mb < m_additionalMB + sizeof(m_additionalMB)); mb += 4)
|
||||
{
|
||||
if ( (i[0] >= mb[0]) && (i[0] <= mb[1]) && (i[1] >= mb[2]) && (i[1] <= mb[3]) )
|
||||
{
|
||||
@ -118,19 +118,19 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
continue;
|
||||
|
||||
/* 3.1. Check against a simple UTF-8 characters enumeration */
|
||||
int cursize, cursize2, ncursize = utf8size((unsigned char *)i);
|
||||
int cursize, cursize2, ncursize = utf8size((unsigned char*)i);
|
||||
/* do check only if current multibyte character is valid UTF-8 only */
|
||||
if (ncursize != -1)
|
||||
{
|
||||
bool found = false;
|
||||
for (unsigned char * mb = m_additionalUtf8; (utf8size(mb) != -1) && (mb < m_additionalUtf8 + sizeof(m_additionalUtf8)); mb += cursize)
|
||||
for (unsigned char* mb = m_additionalUtf8; (utf8size(mb) != -1) && (mb < m_additionalUtf8 + sizeof(m_additionalUtf8)); mb += cursize)
|
||||
{
|
||||
cursize = utf8size(mb);
|
||||
/* Size differs? Pick the next! */
|
||||
if (cursize != ncursize)
|
||||
continue;
|
||||
|
||||
if (!strncmp(i, (char *)mb, cursize))
|
||||
if (!strncmp(i, (char*)mb, cursize))
|
||||
{
|
||||
i += cursize - 1;
|
||||
p += cursize - 1;
|
||||
@ -143,7 +143,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
|
||||
/* 3.2. Check against an UTF-8 ranges: <start character> and <length of the range>. */
|
||||
found = false;
|
||||
for (unsigned char * mb = m_additionalUtf8range; (utf8size(mb) != -1) && (mb < m_additionalUtf8range + sizeof(m_additionalUtf8range)); mb += cursize + 1)
|
||||
for (unsigned char* mb = m_additionalUtf8range; (utf8size(mb) != -1) && (mb < m_additionalUtf8range + sizeof(m_additionalUtf8range)); mb += cursize + 1)
|
||||
{
|
||||
cursize = utf8size(mb);
|
||||
/* Size differs (or lengthbyte is zero)? Pick the next! */
|
||||
@ -151,7 +151,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
continue;
|
||||
|
||||
unsigned char uright[5] = {0,0,0,0,0}, range = mb[cursize] - 1;
|
||||
strncpy((char* ) uright, (char *) mb, cursize);
|
||||
strncpy((char*) uright, (char*) mb, cursize);
|
||||
|
||||
for (int temp = cursize - 1; (temp >= 0) && range; --temp)
|
||||
{
|
||||
@ -175,7 +175,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
}
|
||||
}
|
||||
|
||||
if ((strncmp(i, (char *) mb, cursize) >= 0) && (strncmp(i, (char *) uright, cursize) <= 0))
|
||||
if ((strncmp(i, (char*) mb, cursize) >= 0) && (strncmp(i, (char*) uright, cursize) <= 0))
|
||||
{
|
||||
i += cursize - 1;
|
||||
p += cursize - 1;
|
||||
@ -188,7 +188,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
|
||||
/* 3.3. Check against an UTF-8 intervals: <start character> and <end character>. */
|
||||
found = false;
|
||||
for (unsigned char * mb = m_additionalUtf8interval; (utf8size(mb) != -1) && (utf8size(mb+utf8size(mb)) != -1)
|
||||
for (unsigned char* mb = m_additionalUtf8interval; (utf8size(mb) != -1) && (utf8size(mb+utf8size(mb)) != -1)
|
||||
&& (mb < m_additionalUtf8interval + sizeof(m_additionalUtf8interval)); mb += (cursize+cursize2) )
|
||||
{
|
||||
cursize = utf8size(mb);
|
||||
@ -199,7 +199,7 @@ bool lwbNickHandler::Call(const std::string& nick)
|
||||
|
||||
unsigned char* uright = mb + cursize;
|
||||
|
||||
if ((strncmp(i, (char *) mb, minlen) >= 0) && (strncmp(i, (char *) uright, minlen2) <= 0))
|
||||
if ((strncmp(i, (char*) mb, minlen) >= 0) && (strncmp(i, (char*) uright, minlen2) <= 0))
|
||||
{
|
||||
i += cursize - 1;
|
||||
p += cursize - 1;
|
||||
@ -285,7 +285,7 @@ class ModuleNationalChars : public Module
|
||||
if(charset[0] != '/')
|
||||
charset.insert(0, "../locales/");
|
||||
#endif
|
||||
unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
|
||||
unsigned char* tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
|
||||
if (!loadtables(charset, tables, 8, 5))
|
||||
throw ModuleException("The locale file failed to load. Check your log file for more information.");
|
||||
forcequit = tag->getBool("forcequit");
|
||||
@ -293,7 +293,7 @@ class ModuleNationalChars : public Module
|
||||
CheckRehash();
|
||||
}
|
||||
|
||||
void CheckForceQuit(const char * message)
|
||||
void CheckForceQuit(const char* message)
|
||||
{
|
||||
if (!forcequit)
|
||||
return;
|
||||
@ -320,15 +320,15 @@ class ModuleNationalChars : public Module
|
||||
}
|
||||
|
||||
/*make an array to check against it 8bit characters a bit faster. Whether allowed or uppercase (for your needs).*/
|
||||
void makereverse(unsigned char * from, unsigned char * to, unsigned int cnt)
|
||||
void makereverse(unsigned char* from, unsigned char* to, unsigned int cnt)
|
||||
{
|
||||
memset(to, 0, cnt);
|
||||
for(unsigned char * n=from; (*n) && ((*n)<cnt) && (n<from+cnt); n++)
|
||||
for(unsigned char* n=from; (*n) && ((*n)<cnt) && (n<from+cnt); n++)
|
||||
to[*n] = 1;
|
||||
}
|
||||
|
||||
/*so Bynets Unreal distribution stuff*/
|
||||
bool loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
|
||||
bool loadtables(const std::string& filename, unsigned char** tables, unsigned char cnt, char faillimit)
|
||||
{
|
||||
std::ifstream ifs(ServerInstance->Config->Paths.PrependConfig(filename).c_str());
|
||||
if (ifs.fail())
|
||||
@ -357,7 +357,7 @@ class ModuleNationalChars : public Module
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char symtoi(const char *t,unsigned char base)
|
||||
unsigned char symtoi(const char* t,unsigned char base)
|
||||
/* base = 16 for hexadecimal, 10 for decimal, 8 for octal ;) */
|
||||
{
|
||||
unsigned char tmp = 0, current;
|
||||
@ -375,7 +375,7 @@ class ModuleNationalChars : public Module
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int loadtable(std::ifstream &ifs , unsigned char *chartable, unsigned int maxindex)
|
||||
int loadtable(std::ifstream& ifs , unsigned char* chartable, unsigned int maxindex)
|
||||
{
|
||||
std::string buf;
|
||||
getline(ifs, buf);
|
||||
@ -383,7 +383,7 @@ class ModuleNationalChars : public Module
|
||||
unsigned long i = 0;
|
||||
int fail = 0;
|
||||
|
||||
buf.erase(buf.find_last_not_of("\n") + 1);
|
||||
buf.erase(buf.find_last_not_of('\n') + 1);
|
||||
|
||||
if (buf[0] == '.') /* simple plain-text string after dot */
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ class ModuleOverride
|
||||
|
||||
std::string tokenlist = source->oper->getConfig("override");
|
||||
// its defined or * is set, return its value as a boolean for if the token is set
|
||||
return ((tokenlist.find(token, 0) != std::string::npos) || (tokenlist.find("*", 0) != std::string::npos));
|
||||
return ((tokenlist.find(token, 0) != std::string::npos) || (tokenlist.find('*', 0) != std::string::npos));
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,7 +199,6 @@ public:
|
||||
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("permchannels"))
|
||||
{
|
||||
std::string channel = tag->getString("channel");
|
||||
std::string modes = tag->getString("modes");
|
||||
|
||||
if (!ServerInstance->Channels.IsChannel(channel))
|
||||
{
|
||||
@ -228,6 +227,7 @@ public:
|
||||
|
||||
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Added %s with topic %s", channel.c_str(), c->topic.c_str());
|
||||
|
||||
std::string modes = tag->getString("modes");
|
||||
if (modes.empty())
|
||||
continue;
|
||||
|
||||
|
@ -184,6 +184,7 @@ class SaslAuthenticator
|
||||
void SendHostIP(UserCertificateAPI& sslapi)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
params.reserve(3);
|
||||
params.push_back(user->GetRealHost());
|
||||
params.push_back(user->GetIPString());
|
||||
params.push_back(sslapi && sslapi->GetCertificate(user) ? "S" : "P");
|
||||
@ -237,13 +238,14 @@ class SaslAuthenticator
|
||||
|
||||
if (msg[2] == "C")
|
||||
{
|
||||
ClientProtocol::Message authmsg("AUTHENTICATE");
|
||||
authmsg.PushParamRef(msg[3]);
|
||||
|
||||
ClientProtocol::Event authevent(*g_protoev, authmsg);
|
||||
LocalUser* const localuser = IS_LOCAL(user);
|
||||
if (localuser)
|
||||
{
|
||||
ClientProtocol::Message authmsg("AUTHENTICATE");
|
||||
authmsg.PushParamRef(msg[3]);
|
||||
ClientProtocol::Event authevent(*g_protoev, authmsg);
|
||||
localuser->Send(authevent);
|
||||
}
|
||||
}
|
||||
else if (msg[2] == "D")
|
||||
{
|
||||
|
@ -801,8 +801,7 @@ void ModuleSpanningTree::OnUserAway(User* user)
|
||||
|
||||
void ModuleSpanningTree::OnUserBack(User* user)
|
||||
{
|
||||
if (IS_LOCAL(user))
|
||||
CommandAway::Builder(user).Broadcast();
|
||||
OnUserAway(user);
|
||||
}
|
||||
|
||||
void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags)
|
||||
|
@ -43,8 +43,8 @@ public:
|
||||
|
||||
SVSHold(time_t s_time, unsigned long d, const std::string& src, const std::string& re, const std::string& nick)
|
||||
: XLine(s_time, d, src, re, "SVSHOLD")
|
||||
, nickname(nick)
|
||||
{
|
||||
this->nickname = nick;
|
||||
}
|
||||
|
||||
bool Matches(User* u) override
|
||||
|
@ -81,8 +81,7 @@ class ModuleXLineDB
|
||||
*/
|
||||
void OnDelLine(User* source, XLine* line) override
|
||||
{
|
||||
if (!line->from_config)
|
||||
dirty = true;
|
||||
OnAddLine(source, line);
|
||||
}
|
||||
|
||||
bool Tick(time_t) override
|
||||
|
@ -1207,9 +1207,7 @@ const std::string& FakeUser::GetFullHost()
|
||||
|
||||
const std::string& FakeUser::GetFullRealHost()
|
||||
{
|
||||
if (!ServerInstance->Config->HideServer.empty())
|
||||
return ServerInstance->Config->HideServer;
|
||||
return server->GetName();
|
||||
return GetFullHost();
|
||||
}
|
||||
|
||||
ConnectClass::ConnectClass(std::shared_ptr<ConfigTag> tag, char t, const std::vector<std::string>& masks)
|
||||
|
@ -196,7 +196,7 @@ void InstallService()
|
||||
CloseServiceHandle(SCMHandle);
|
||||
std::cout << "Service installed." << std::endl;
|
||||
}
|
||||
catch(CWin32Exception e)
|
||||
catch(const CWin32Exception& e)
|
||||
{
|
||||
if(InspServiceHandle)
|
||||
CloseServiceHandle(InspServiceHandle);
|
||||
@ -232,7 +232,7 @@ void UninstallService()
|
||||
CloseServiceHandle(SCMHandle);
|
||||
std::cout << "Service removed." << std::endl;
|
||||
}
|
||||
catch(CWin32Exception e)
|
||||
catch(const CWin32Exception& e)
|
||||
{
|
||||
if(InspServiceHandle)
|
||||
CloseServiceHandle(InspServiceHandle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user