diff options
author | Matthew Zipkin <pinheadmz@gmail.com> | 2023-05-26 12:26:43 -0400 |
---|---|---|
committer | Matthew Zipkin <pinheadmz@gmail.com> | 2024-03-01 13:13:07 -0500 |
commit | bae86c8d318d06818aa75a9ebe3db864197f0bc6 (patch) | |
tree | 893a4fde71f37fcfab090b216a8f097ce9308fb8 /src/net.cpp | |
parent | adb3a3e51de205cc69b1a58647c65c04fa6c6362 (diff) |
netbase: refactor CreateSock() to accept sa_family_t
Also implement CService::GetSAFamily() to provide sa_family_t
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index 7c82f01d75..d40c7109c2 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -483,15 +483,16 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo addr_bind = CAddress{conn.me, NODE_NONE}; } } else if (use_proxy) { - sock = CreateSock(proxy.proxy); + sock = CreateSock(proxy.proxy.GetSAFamily()); if (!sock) { return nullptr; } + LogPrintLevel(BCLog::PROXY, BCLog::Level::Debug, "Using proxy: %s to connect to %s:%s\n", proxy.proxy.ToStringAddrPort(), addrConnect.ToStringAddr(), addrConnect.GetPort()); connected = ConnectThroughProxy(proxy, addrConnect.ToStringAddr(), addrConnect.GetPort(), *sock, nConnectTimeout, proxyConnectionFailed); } else { // no proxy needed (none set for target network) - sock = CreateSock(addrConnect); + sock = CreateSock(addrConnect.GetSAFamily()); if (!sock) { return nullptr; } @@ -504,7 +505,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo addrman.Attempt(addrConnect, fCountFailure); } } else if (pszDest && GetNameProxy(proxy)) { - sock = CreateSock(proxy.proxy); + sock = CreateSock(proxy.proxy.GetSAFamily()); if (!sock) { return nullptr; } @@ -2993,7 +2994,7 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, return false; } - std::unique_ptr<Sock> sock = CreateSock(addrBind); + std::unique_ptr<Sock> sock = CreateSock(addrBind.GetSAFamily()); if (!sock) { strError = strprintf(Untranslated("Couldn't open socket for incoming connections (socket returned error %s)"), NetworkErrorString(WSAGetLastError())); LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", strError.original); |