@@ -373,7 +373,12 @@ static CService GetBindAddress(const Sock& sock)
373373 return addr_bind;
374374}
375375
376- CNode* CConnman::ConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure , ConnectionType conn_type, bool use_v2transport)
376+ CNode* CConnman::ConnectNode (CAddress addrConnect,
377+ const char * pszDest,
378+ bool fCountFailure ,
379+ ConnectionType conn_type,
380+ bool use_v2transport,
381+ const std::optional<Proxy>& proxy_override)
377382{
378383 AssertLockNotHeld (m_unused_i2p_sessions_mutex);
379384 assert (conn_type != ConnectionType::INBOUND);
@@ -439,7 +444,13 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
439444
440445 for (auto & target_addr: connect_to) {
441446 if (target_addr.IsValid ()) {
442- const bool use_proxy{GetProxy (target_addr.GetNetwork (), proxy)};
447+ bool use_proxy;
448+ if (proxy_override.has_value ()) {
449+ use_proxy = true ;
450+ proxy = proxy_override.value ();
451+ } else {
452+ use_proxy = GetProxy (target_addr.GetNetwork (), proxy);
453+ }
443454 bool proxyConnectionFailed = false ;
444455
445456 if (target_addr.IsI2P () && use_proxy) {
@@ -2858,7 +2869,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std
28582869 const bool count_failures{((int )outbound_ipv46_peer_netgroups.size () + outbound_privacy_network_peers) >= std::min (m_max_automatic_connections - 1 , 2 )};
28592870 // Use BIP324 transport when both us and them have NODE_V2_P2P set.
28602871 const bool use_v2transport (addrConnect.nServices & GetLocalServices () & NODE_P2P_V2);
2861- OpenNetworkConnection (addrConnect, count_failures, std::move (grant), /* strDest =*/ nullptr , conn_type, use_v2transport);
2872+ OpenNetworkConnection (addrConnect, count_failures, std::move (grant), /* pszDest =*/ nullptr , conn_type, use_v2transport);
28622873 }
28632874 }
28642875}
@@ -2967,7 +2978,13 @@ void CConnman::ThreadOpenAddedConnections()
29672978}
29682979
29692980// if successful, this moves the passed grant to the constructed node
2970- void CConnman::OpenNetworkConnection (const CAddress& addrConnect, bool fCountFailure , CountingSemaphoreGrant<>&& grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport)
2981+ bool CConnman::OpenNetworkConnection (const CAddress& addrConnect,
2982+ bool fCountFailure ,
2983+ CountingSemaphoreGrant<>&& grant_outbound,
2984+ const char * pszDest,
2985+ ConnectionType conn_type,
2986+ bool use_v2transport,
2987+ const std::optional<Proxy>& proxy_override)
29712988{
29722989 AssertLockNotHeld (m_unused_i2p_sessions_mutex);
29732990 assert (conn_type != ConnectionType::INBOUND);
@@ -2976,24 +2993,24 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
29762993 // Initiate outbound network connection
29772994 //
29782995 if (m_interrupt_net->interrupted ()) {
2979- return ;
2996+ return false ;
29802997 }
29812998 if (!fNetworkActive ) {
2982- return ;
2999+ return false ;
29833000 }
29843001 if (!pszDest) {
29853002 bool banned_or_discouraged = m_banman && (m_banman->IsDiscouraged (addrConnect) || m_banman->IsBanned (addrConnect));
29863003 if (IsLocal (addrConnect) || banned_or_discouraged || AlreadyConnectedToAddress (addrConnect)) {
2987- return ;
3004+ return false ;
29883005 }
29893006 } else if (AlreadyConnectedToHost (pszDest)) {
2990- return ;
3007+ return false ;
29913008 }
29923009
2993- CNode* pnode = ConnectNode (addrConnect, pszDest, fCountFailure , conn_type, use_v2transport);
3010+ CNode* pnode = ConnectNode (addrConnect, pszDest, fCountFailure , conn_type, use_v2transport, proxy_override );
29943011
29953012 if (!pnode)
2996- return ;
3013+ return false ;
29973014 pnode->grantOutbound = std::move (grant_outbound);
29983015
29993016 m_msgproc->InitializeNode (*pnode, m_local_services);
@@ -3011,6 +3028,8 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
30113028 pnode->ConnectionTypeAsString ().c_str (),
30123029 pnode->ConnectedThroughNetwork (),
30133030 GetNodeCount (ConnectionDirection::Out));
3031+
3032+ return true ;
30143033}
30153034
30163035Mutex NetEventsInterface::g_msgproc_mutex;
0 commit comments