mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-23 06:39:58 +02:00
net: use the proxy if overriden when doing v2->v1 reconnections
`OpenNetworkConnection()` supports overriding the proxy to use for
connecting. However when v2 connection is attempted and it fails a v1
connection is tried without that proxy.
Store the override proxy in `CNode` and pass it to
`CConnman::m_reconnections` to be used for v1 retries.
Github-Pull: #35410
Rebased-From: fd230f942d
This commit is contained in:
@@ -536,6 +536,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
|
||||
network_id,
|
||||
CNodeOptions{
|
||||
.permission_flags = permission_flags,
|
||||
.proxy_override = proxy_override,
|
||||
.i2p_sam_session = std::move(i2p_transient_session),
|
||||
.recv_flood_size = nReceiveFloodSize,
|
||||
.use_v2transport = use_v2transport,
|
||||
@@ -1943,6 +1944,7 @@ void CConnman::DisconnectNodes()
|
||||
// and we don't want to hold up the socket handler thread for that long.
|
||||
if (network_active && pnode->m_transport->ShouldReconnectV1()) {
|
||||
reconnections_to_add.push_back({
|
||||
.proxy_override = pnode->m_proxy_override,
|
||||
.addr_connect = pnode->addr,
|
||||
.grant = std::move(pnode->grantOutbound),
|
||||
.destination = pnode->m_dest,
|
||||
@@ -3980,6 +3982,7 @@ CNode::CNode(NodeId idIn,
|
||||
m_permission_flags{node_opts.permission_flags},
|
||||
m_sock{sock},
|
||||
m_connected{GetTime<std::chrono::seconds>()},
|
||||
m_proxy_override{std::move(node_opts.proxy_override)},
|
||||
addr{addrIn},
|
||||
addrBind{addrBindIn},
|
||||
m_addr_name{addrNameIn.empty() ? addr.ToStringAddrPort() : addrNameIn},
|
||||
@@ -4163,7 +4166,8 @@ void CConnman::PerformReconnections()
|
||||
std::move(item.grant),
|
||||
item.destination.empty() ? nullptr : item.destination.c_str(),
|
||||
item.conn_type,
|
||||
item.use_v2transport);
|
||||
item.use_v2transport,
|
||||
item.proxy_override);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -669,6 +669,7 @@ public:
|
||||
struct CNodeOptions
|
||||
{
|
||||
NetPermissionFlags permission_flags = NetPermissionFlags::None;
|
||||
std::optional<Proxy> proxy_override = {};
|
||||
std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
|
||||
bool prefer_evict = false;
|
||||
size_t recv_flood_size{DEFAULT_MAXRECEIVEBUFFER * 1000};
|
||||
@@ -711,6 +712,10 @@ public:
|
||||
std::atomic<std::chrono::seconds> m_last_recv{0s};
|
||||
//! Unix epoch time at peer connection
|
||||
const std::chrono::seconds m_connected;
|
||||
|
||||
//! Proxy to use regardless of global proxy settings if reconnecting to this node.
|
||||
const std::optional<Proxy> m_proxy_override;
|
||||
|
||||
// Address of this peer
|
||||
const CAddress addr;
|
||||
// Bind address of our side of the connection
|
||||
@@ -1778,6 +1783,7 @@ private:
|
||||
/** Struct for entries in m_reconnections. */
|
||||
struct ReconnectionInfo
|
||||
{
|
||||
std::optional<Proxy> proxy_override;
|
||||
CAddress addr_connect;
|
||||
CountingSemaphoreGrant<> grant;
|
||||
std::string destination;
|
||||
|
||||
Reference in New Issue
Block a user