diff options
| author | 2022-08-11 14:20:18 +0100 | |
|---|---|---|
| committer | 2022-08-11 15:40:57 +0100 | |
| commit | f88fbaa2fe91c22f1c7280ecd96c2bcf92f73a4d (patch) | |
| tree | e35803070a6ca8e50ee2d07b2e6c0d71230d53f3 /src/modules/m_spanningtree/main.cpp | |
| parent | Clean up the sockaddrs documentation comments. (diff) | |
Move aptosa/untosa into the sockaddrs union and add from/from_ip.
The struct will also now always be zero-initialized by default which
removes the footgun which has happened previously where the union has
been accessed before being initialized leading to it containing weird
values.
Diffstat (limited to 'src/modules/m_spanningtree/main.cpp')
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index ad45a2746..520868978 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -223,7 +223,7 @@ void ModuleSpanningTree::ConnectServer(std::shared_ptr<Link> x, std::shared_ptr< irc::sockets::sockaddrs sa; if (x->IPAddr.find('/') != std::string::npos) { - if (!irc::sockets::isunix(x->IPAddr) || !irc::sockets::untosa(x->IPAddr, sa)) + if (!irc::sockets::isunix(x->IPAddr) || !sa.from_unix(x->IPAddr)) { // We don't use the family() != AF_UNSPEC check below for UNIX sockets as // that results in a DNS lookup. @@ -235,7 +235,7 @@ void ModuleSpanningTree::ConnectServer(std::shared_ptr<Link> x, std::shared_ptr< else { // If this fails then the IP sa will be AF_UNSPEC. - irc::sockets::aptosa(x->IPAddr, x->Port, sa); + sa.from_ip_port(x->IPAddr, x->Port); } /* Do we already have an IP? If so, no need to resolve it. */ @@ -259,7 +259,7 @@ void ModuleSpanningTree::ConnectServer(std::shared_ptr<Link> x, std::shared_ptr< // Guess start_type from bindip aftype DNS::QueryType start_type = DNS::QUERY_AAAA; irc::sockets::sockaddrs bind; - if ((!x->Bind.empty()) && (irc::sockets::aptosa(x->Bind, 0, bind))) + if (!x->Bind.empty() && bind.from_ip(x->Bind)) { if (bind.family() == AF_INET) start_type = DNS::QUERY_A; |
