@@ -1674,15 +1674,15 @@ void CConnman::ProcessOneShot()
16741674 }
16751675}
16761676
1677- void CConnman::ThreadOpenConnections ()
1677+ void CConnman::ThreadOpenConnections (const std::vector<std::string> connect )
16781678{
16791679 // Connect to specific addresses
1680- if (gArgs . IsArgSet ( " -connect " ))
1680+ if (!connect. empty ( ))
16811681 {
16821682 for (int64_t nLoop = 0 ;; nLoop++)
16831683 {
16841684 ProcessOneShot ();
1685- for (const std::string& strAddr : gArgs . GetArgs ( " - connect" ) )
1685+ for (const std::string& strAddr : connect)
16861686 {
16871687 CAddress addr (CService (), NODE_NONE);
16881688 OpenNetworkConnection (addr, false , NULL , strAddr.c_str ());
@@ -2360,9 +2360,16 @@ bool CConnman::Start(CScheduler& scheduler, Options connOptions)
23602360 // Initiate outbound connections from -addnode
23612361 threadOpenAddedConnections = std::thread (&TraceThread<std::function<void ()> >, " addcon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenAddedConnections, this )));
23622362
2363- // Initiate outbound connections unless connect=0
2364- if (!gArgs .IsArgSet (" -connect" ) || gArgs .GetArgs (" -connect" ).size () != 1 || gArgs .GetArgs (" -connect" )[0 ] != " 0" )
2365- threadOpenConnections = std::thread (&TraceThread<std::function<void ()> >, " opencon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenConnections, this )));
2363+ if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing .empty ()) {
2364+ if (clientInterface) {
2365+ clientInterface->ThreadSafeMessageBox (
2366+ _ (" Cannot provide specific connections and have addrman find outgoing connections at the same." ),
2367+ " " , CClientUIInterface::MSG_ERROR);
2368+ }
2369+ return false ;
2370+ }
2371+ if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing .empty ())
2372+ threadOpenConnections = std::thread (&TraceThread<std::function<void ()> >, " opencon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenConnections, this , connOptions.m_specified_outgoing )));
23662373
23672374 // Process messages
23682375 threadMessageHandler = std::thread (&TraceThread<std::function<void ()> >, " msghand" , std::function<void ()>(std::bind (&CConnman::ThreadMessageHandler, this )));
0 commit comments