Fix: failure to connect to a node if its domain resolves to an IPv6 address

This commit is contained in:
SChernykh
2025-05-21 10:34:22 +02:00
committed by GitHub
parent cf51fe5273
commit 40999f0056

View File

@@ -111,8 +111,10 @@ CurlContext::CurlContext(const std::string& address, int port, const std::string
(void)ssl_fingerprint;
#endif
const bool is_v6 = (address.find(':') != std::string::npos);
log::Stream s(buf);
s << protocol << address << ':' << port;
s << protocol << (is_v6 ? "[" : "") << address << (is_v6 ? "]:" : ":") << port;
if (!m_req.empty() && (m_req.front() == '/')) {
s << m_req.c_str() << '\0';