Merge branch 'insp3' into master.

This commit is contained in:
Sadie Powell 2022-12-25 22:28:12 +00:00
commit 05168e3549
15 changed files with 47 additions and 44 deletions

View File

@ -49,6 +49,7 @@ InspIRCd is licensed under [version 2 of the GNU General Public License](https:/
* [GitHub](https://github.com/inspircd)
* [Twitter](https://twitter.com/inspircdteam)
* [Mastodon](https://fosstodon.org/@inspircd)
* [Cohost](https://cohost.org/inspircd)
* Support IRC channel — \#inspircd on irc.inspircd.org
* Development IRC channel — \#inspircd.dev on irc.inspircd.org
* InspIRCd test network — testnet.inspircd.org

View File

@ -1460,7 +1460,7 @@
# mysql is more complex than described here, see the docs for more #
# info: https://docs.inspircd.org/4/modules/mysql #
#
#<database module="mysql" name="mydb" user="myuser" pass="mypass" host="localhost" id="my_database2">
#<database module="mysql" name="mydb" user="myuser" pass="mypass" host="localhost" id="my_database2" ssl="no">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Named modes module: Allows for the display and set/unset of channel

View File

@ -43,6 +43,7 @@
# - users/ignore-privdeaf: allows opers with this priv to message users with +D set.
# - users/sajoin-others: allows opers with this priv to /SAJOIN users other than themselves.
# - users/secret-whois: allows opers with this priv to /WHOIS +W users without them being notified.
# servers/ignore-blockamsg: allows opers with this priv to use /AMSG and /AME.
# - servers/ignore-shun: allows opers with this priv to ignore shuns.
# - servers/ignore-securelist: allows opers with this priv to ignore securelist.
# - servers/use-disabled-commands: allows opers with this priv to use disabled commands.

View File

@ -771,7 +771,7 @@ public:
return true;
}
void Rehash(const std::string& dnsserver, std::string sourceaddr, unsigned int sourceport)
void Rehash(const std::string& dnsserver, std::string sourceaddr, in_port_t sourceport)
{
myserver.from_ip_port(dnsserver, DNS::PORT);
@ -829,7 +829,7 @@ class ModuleDNS final
MyManager manager;
std::string DNSServer;
std::string SourceIP;
unsigned int SourcePort = 0;
in_port_t SourcePort = 0;
void FindDNSServer()
{
@ -917,8 +917,8 @@ public:
const std::string oldip = SourceIP;
SourceIP = tag->getString("sourceip");
const unsigned int oldport = SourcePort;
SourcePort = static_cast<unsigned int>(tag->getUInt("sourceport", 0, 0, UINT16_MAX));
const in_port_t oldport = SourcePort;
SourcePort = static_cast<in_port_t>(tag->getUInt("sourceport", 0, 0, 65535));
if (DNSServer.empty())
FindDNSServer();

View File

@ -115,19 +115,14 @@ void* DLLManager::GetSymbol(const char* name) const
void DLLManager::RetrieveLastError()
{
#if defined _WIN32
char errmsg[500];
DWORD dwErrorCode = GetLastError();
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)errmsg, _countof(errmsg), nullptr) == 0)
sprintf_s(errmsg, _countof(errmsg), "Error code: %u", dwErrorCode);
#ifdef _WIN32
err = GetErrorMessage(GetLastError());
SetLastError(ERROR_SUCCESS);
err = errmsg;
#else
const char* errmsg = dlerror();
err = errmsg ? errmsg : "Unknown error";
#endif
std::string::size_type p;
while ((p = err.find_last_of("\r\n")) != std::string::npos)
err.erase(p, 1);
for (size_t pos = 0; ((pos = err.find_first_of("\r\n", pos)) != std::string::npos); )
err[pos] = ' ';
}

View File

@ -323,6 +323,12 @@ public:
unsigned int timeout = static_cast<unsigned int>(config->getDuration("timeout", 5, 1, 30));
mysql_options(connection, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
// Enable SSL if requested.
#if defined LIBMYSQL_VERSION_ID && LIBMYSQL_VERSION_ID > 80000
unsigned int ssl = config->getBool("ssl") ? SSL_MODE_REQUIRED : SSL_MODE_PREFERRED;
mysql_options(connection, MYSQL_OPT_SSL_MODE, &ssl);
#endif
// Attempt to connect to the database.
const std::string host = config->getString("host");
const std::string user = config->getString("user");

View File

@ -86,6 +86,9 @@ public:
if ((validated) && (parameters.size() >= 2) && ((command == "PRIVMSG") || (command == "NOTICE")))
{
if (user->HasPrivPermission("servers/ignore-blockamsg"))
return MOD_RES_PASSTHRU;
// parameters[0] is the target list, count how many channels are there
unsigned int targets = 0;
// Is the first target a channel?

View File

@ -181,7 +181,7 @@ public:
if (host.empty())
throw ModuleException(this, "<sts:host> must contain a hostname, at " + tag->source.str());
in_port_t port = static_cast<in_port_t>(tag->getUInt("port", 0, 0, UINT16_MAX));
in_port_t port = static_cast<in_port_t>(tag->getUInt("port", 6697, 1, 65535));
if (!HasValidSSLPort(port))
throw ModuleException(this, "<sts:port> must be a TLS port, at " + tag->source.str());

View File

@ -32,7 +32,7 @@ public:
std::shared_ptr<ConfigTag> tag;
std::string Name;
std::string IPAddr;
unsigned int Port;
in_port_t Port;
std::string SendPass;
std::string RecvPass;
std::string Fingerprint;

View File

@ -363,7 +363,7 @@ ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameter
TreeServer* CheckDupe = Utils->FindServer(x->Name);
if (!CheckDupe)
{
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Connecting to server: \002%s\002 (%s:%d)", x->Name.c_str(), (x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()), x->Port));
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Connecting to server: \002%s\002 (%s:%hu)", x->Name.c_str(), (x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()), x->Port));
ConnectServer(x);
return MOD_RES_DENY;
}

View File

@ -262,7 +262,7 @@ void SpanningTreeUtilities::ReadConfiguration()
if (path.empty())
{
L->IPAddr = tag->getString("ipaddr");
L->Port = static_cast<unsigned int>(tag->getUInt("port", 0, 0, UINT16_MAX));
L->Port = static_cast<in_port_t>(tag->getUInt("port", 0, 0, 65535));
}
else
{

View File

@ -350,17 +350,10 @@ std::string SocketEngine::LastError()
#ifndef _WIN32
return strerror(errno);
#else
char szErrorString[500];
DWORD dwErrorCode = WSAGetLastError();
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), nullptr) == 0)
sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
std::string::size_type p;
std::string ret = szErrorString;
while ((p = ret.find_last_of("\r\n")) != std::string::npos)
ret.erase(p, 1);
return ret;
std::string err = GetErrorMessage(WSAGetLastError());
for (size_t pos = 0; ((pos = err.find_first_of("\r\n", pos)) != std::string::npos); )
err[pos] = ' ';
return err;
#endif
}

View File

@ -1,4 +1,4 @@
# Last updated: 2022-11-16
# Last updated: 2022-12-25
#
# Modules we can't legally ship: geo_maxmind, ssl_mbedtls, ssl_openssl
# Modules which don't apply to Windows: sslrehashsignal
@ -11,10 +11,10 @@ libmysqlclient/8.0.30
libpq/14.5
## mbedtls/3.2.1
## openssl/1.1.1s # unable to upgrade to v3 yet because of dependency issues
pcre2/10.40
pcre2/10.42
rapidjson/cci.20220822
re2/20220601
sqlite3/3.39.4
re2/20221201
sqlite3/3.40.0
[options]
argon2:shared=True

View File

@ -24,29 +24,25 @@
*/
#include "inspircd_win32wrapper.h"
#include "inspircd.h"
CWin32Exception::CWin32Exception()
{
dwErrorCode = GetLastError();
if( FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), nullptr) == 0 )
sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
for (size_t i = 0; i < _countof(szErrorString); i++)
{
if ((szErrorString[i] == '\r') || (szErrorString[i] == '\n'))
szErrorString[i] = 0;
}
szErrorString = GetErrorMessage(dwErrorCode);
for (size_t pos = 0; ((pos = szErrorString.find_first_of("\r\n", pos)) != std::string::npos); )
szErrorString[pos] = ' ';
}
CWin32Exception::CWin32Exception(const CWin32Exception& other)
: szErrorString(other.szErrorString)
{
strcpy_s(szErrorString, _countof(szErrorString), other.szErrorString);
}
const char* CWin32Exception::what() const noexcept
{
return szErrorString;
return szErrorString.c_str();
}
DWORD CWin32Exception::GetErrorCode()

View File

@ -116,7 +116,7 @@ public:
DWORD GetErrorCode();
private:
char szErrorString[500];
std::string szErrorString;
DWORD dwErrorCode;
};
@ -146,3 +146,11 @@ inline ssize_t writev(int fd, const WindowsIOVec* iov, int count)
return sent;
return -1;
}
inline std::string GetErrorMessage(DWORD dwErrorCode)
{
char szErrorString[1024];
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0)
sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
return szErrorString;
}