summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/main.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-02-07 15:34:41 +0000
committerPeter Powell <petpow@saberuk.com>2019-04-15 12:21:12 +0100
commitc2c4de7267db9835e36132364f422ba7d93f25d6 (patch)
treec165dda97b90d713cf25ddd7ddd000839c2e3405 /src/modules/m_spanningtree/main.cpp
parente7b65ef5355d75dd32ea387da716a765090aff0e (diff)
Fix linking servers with UNIX sockets.
- Remove the address/port overloads of BeginConnect. - Change DoConnect to take a sockaddrs instead of an address/port.
Diffstat (limited to 'src/modules/m_spanningtree/main.cpp')
-rw-r--r--src/modules/m_spanningtree/main.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 920840f9b..8b24b1e22 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -198,40 +198,38 @@ void ModuleSpanningTree::ConnectServer(Autoconnect* a, bool on_timer)
void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
{
- bool ipvalid = true;
-
if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map))
{
ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
return;
}
+ irc::sockets::sockaddrs sa;
#ifndef _WIN32
if (x->IPAddr.find('/') != std::string::npos)
{
struct stat sb;
- if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode))
- ipvalid = false;
- }
-#endif
- if (x->IPAddr.find(':') != std::string::npos)
- {
- in6_addr n;
- if (inet_pton(AF_INET6, x->IPAddr.c_str(), &n) < 1)
- ipvalid = false;
+ if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode) || !irc::sockets::untosa(x->IPAddr, sa))
+ {
+ // We don't use the family() != AF_UNSPEC check below for UNIX sockets as
+ // that results in a DNS lookup.
+ ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s is not a UNIX socket!",
+ x->Name.c_str(), x->IPAddr.c_str());
+ return;
+ }
}
else
+#endif
{
- in_addr n;
- if (inet_pton(AF_INET, x->IPAddr.c_str(),&n) < 1)
- ipvalid = false;
+ // If this fails then the IP sa will be AF_UNSPEC.
+ irc::sockets::aptosa(x->IPAddr, x->Port, sa);
}
-
+
/* Do we already have an IP? If so, no need to resolve it. */
- if (ipvalid)
+ if (sa.family() != AF_UNSPEC)
{
// Create a TreeServer object that will start connecting immediately in the background
- TreeSocket* newsocket = new TreeSocket(x, y, x->IPAddr);
+ TreeSocket* newsocket = new TreeSocket(x, y, sa);
if (newsocket->GetFd() > -1)
{
/* Handled automatically on success */