aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-12-18 17:51:35 +0000
committerGravatar Sadie Powell2022-12-18 18:47:28 +0000
commit2ddb62319803f6a3f3246a52b4e009d9ae1daaed (patch)
tree96a5d23c8a38f3282f3e52346cb706d55e58658f /src/modules
parentWe actually want ADDRESS_FAMILY not SOCKET_ADDRESS for sa_family_t. (diff)
Use in_port_t instead of int/unsigned int/long.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_gateway.cpp4
-rw-r--r--src/modules/m_hostchange.cpp7
-rw-r--r--src/modules/m_ircv3_sts.cpp8
3 files changed, 11 insertions, 8 deletions
diff --git a/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp
index a43e3ee9b..4e3bdc843 100644
--- a/src/modules/m_gateway.cpp
+++ b/src/modules/m_gateway.cpp
@@ -480,7 +480,7 @@ public:
if (cport != flags->end())
{
// If we can't parse the port then just give up.
- uint16_t port = ConvToNum<uint16_t>(cport->second);
+ in_port_t port = ConvToNum<in_port_t>(cport->second);
if (port)
{
switch (user->client_sa.family())
@@ -506,7 +506,7 @@ public:
if (sport != flags->end())
{
// If we can't parse the port then just give up.
- uint16_t port = ConvToNum<uint16_t>(sport->second);
+ in_port_t port = ConvToNum<in_port_t>(sport->second);
if (port)
{
switch (user->server_sa.family())
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index fda8e7e67..bd3e2b36b 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -47,7 +47,7 @@ private:
std::string host;
std::string klass;
std::string mask;
- insp::flat_set<long> ports;
+ insp::flat_set<in_port_t> ports;
std::string prefix;
std::string suffix;
@@ -62,7 +62,10 @@ private:
{
irc::portparser portrange(portlist, false);
while (long port = portrange.GetToken())
- ports.insert(port);
+ {
+ if (port > std::numeric_limits<in_port_t>::min() && port <= std::numeric_limits<in_port_t>::max())
+ ports.insert(static_cast<in_port_t>(port));
+ }
}
}
diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp
index e199b7f34..93004f3f4 100644
--- a/src/modules/m_ircv3_sts.cpp
+++ b/src/modules/m_ircv3_sts.cpp
@@ -88,7 +88,7 @@ public:
// TODO: Send duration=0 when STS vanishes.
}
- void SetPolicy(const std::string& newhost, unsigned long duration, unsigned int port, bool preload)
+ void SetPolicy(const std::string& newhost, unsigned long duration, in_port_t port, bool preload)
{
// To enforce an STS upgrade policy, servers MUST send this key to insecurely connected clients. Servers
// MAY send this key to securely connected clients, but it will be ignored.
@@ -140,7 +140,7 @@ private:
STSCap cap;
// The IRCv3 STS specification requires that the server is listening using TLS using a valid certificate.
- static bool HasValidSSLPort(unsigned int port)
+ static bool HasValidSSLPort(in_port_t port)
{
for (const auto& ls : ServerInstance->ports)
{
@@ -149,7 +149,7 @@ private:
return true;
// Is this listener on the right port?
- unsigned int saport = ls->bind_sa.port();
+ in_port_t saport = ls->bind_sa.port();
if (saport != port)
continue;
@@ -181,7 +181,7 @@ public:
if (host.empty())
throw ModuleException(this, "<sts:host> must contain a hostname, at " + tag->source.str());
- unsigned int port = static_cast<unsigned int>(tag->getUInt("port", 0, 0, UINT16_MAX));
+ in_port_t port = static_cast<in_port_t>(tag->getUInt("port", 0, 0, UINT16_MAX));
if (!HasValidSSLPort(port))
throw ModuleException(this, "<sts:port> must be a TLS port, at " + tag->source.str());