@@ -48,6 +48,7 @@ uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
48
48
static CCriticalSection cs_mapLocalHost;
49
49
static map<CNetAddr, int > mapLocalHost;
50
50
static bool vfReachable[NET_MAX] = {};
51
+ static bool vfLimited[NET_MAX] = {};
51
52
static CNode* pnodeLocalHost = NULL ;
52
53
uint64 nLocalHostNonce = 0 ;
53
54
array<int , THREAD_MAX> vnThreadsRunning;
@@ -225,7 +226,20 @@ bool AddLocal(const CNetAddr& addr, int nScore)
225
226
return true ;
226
227
}
227
228
228
- // vote for a local address
229
+ /* * Make a particular network entirely off-limits (no automatic connects to it) */
230
+ void SetLimited (enum Network net, bool fLimited )
231
+ {
232
+ LOCK (cs_mapLocalHost);
233
+ vfLimited[net] = fLimited ;
234
+ }
235
+
236
+ bool IsLimited (const CNetAddr& addr)
237
+ {
238
+ LOCK (cs_mapLocalHost);
239
+ return vfLimited[addr.GetNetwork ()];
240
+ }
241
+
242
+ /* * vote for a local address */
229
243
bool SeenLocal (const CNetAddr& addr)
230
244
{
231
245
{
@@ -240,18 +254,19 @@ bool SeenLocal(const CNetAddr& addr)
240
254
return true ;
241
255
}
242
256
243
- // check whether a given address is potentially local
257
+ /* * check whether a given address is potentially local */
244
258
bool IsLocal (const CNetAddr& addr)
245
259
{
246
260
LOCK (cs_mapLocalHost);
247
261
return mapLocalHost.count (addr) > 0 ;
248
262
}
249
263
250
- // check whether a given address is in a network we can probably connect to
264
+ /* * check whether a given address is in a network we can probably connect to */
251
265
bool IsReachable (const CNetAddr& addr)
252
266
{
253
267
LOCK (cs_mapLocalHost);
254
- return vfReachable[addr.GetNetwork ()];
268
+ enum Network net = addr.GetNetwork ();
269
+ return vfReachable[net] && !vfLimited[net];
255
270
}
256
271
257
272
bool GetMyExternalIP2 (const CService& addrConnect, const char * pszGet, const char * pszKeyword, CNetAddr& ipRet)
@@ -1409,6 +1424,9 @@ void ThreadOpenConnections2(void* parg)
1409
1424
1410
1425
nTries++;
1411
1426
1427
+ if (IsLimited (addr))
1428
+ continue ;
1429
+
1412
1430
// only consider very recently tried nodes after 30 failed attempts
1413
1431
if (nANow - addr.nLastTry < 600 && nTries < 30 )
1414
1432
continue ;
0 commit comments