Skip to content

Commit 110b62f

Browse files
committed
Remove vfReachable and modify IsReachable to only use vfLimited.
We do not know that a class of Network is reachable, only that it is not.
1 parent 8b70a64 commit 110b62f

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

src/init.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11991199
// -proxy sets a proxy for all outgoing network traffic
12001200
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
12011201
std::string proxyArg = GetArg("-proxy", "");
1202+
SetLimited(NET_TOR);
12021203
if (proxyArg != "" && proxyArg != "0") {
12031204
proxyType addrProxy = proxyType(CService(proxyArg, 9050), proxyRandomize);
12041205
if (!addrProxy.IsValid())
@@ -1208,7 +1209,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12081209
SetProxy(NET_IPV6, addrProxy);
12091210
SetProxy(NET_TOR, addrProxy);
12101211
SetNameProxy(addrProxy);
1211-
SetReachable(NET_TOR); // by default, -proxy sets onion as reachable, unless -noonion later
1212+
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
12121213
}
12131214

12141215
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
@@ -1217,13 +1218,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12171218
std::string onionArg = GetArg("-onion", "");
12181219
if (onionArg != "") {
12191220
if (onionArg == "0") { // Handle -noonion/-onion=0
1220-
SetReachable(NET_TOR, false); // set onions as unreachable
1221+
SetLimited(NET_TOR); // set onions as unreachable
12211222
} else {
12221223
proxyType addrOnion = proxyType(CService(onionArg, 9050), proxyRandomize);
12231224
if (!addrOnion.IsValid())
12241225
return InitError(strprintf(_("Invalid -onion address: '%s'"), onionArg));
12251226
SetProxy(NET_TOR, addrOnion);
1226-
SetReachable(NET_TOR);
1227+
SetLimited(NET_TOR, false);
12271228
}
12281229
}
12291230

src/net.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ bool fListen = true;
7979
uint64_t nLocalServices = NODE_NETWORK;
8080
CCriticalSection cs_mapLocalHost;
8181
map<CNetAddr, LocalServiceInfo> mapLocalHost;
82-
static bool vfReachable[NET_MAX] = {};
8382
static bool vfLimited[NET_MAX] = {};
8483
static CNode* pnodeLocalHost = NULL;
8584
uint64_t nLocalHostNonce = 0;
@@ -226,14 +225,6 @@ void AdvertiseLocal(CNode *pnode)
226225
}
227226
}
228227

229-
void SetReachable(enum Network net, bool fFlag)
230-
{
231-
LOCK(cs_mapLocalHost);
232-
vfReachable[net] = fFlag;
233-
if (net == NET_IPV6 && fFlag)
234-
vfReachable[NET_IPV4] = true;
235-
}
236-
237228
// learn a new local address
238229
bool AddLocal(const CService& addr, int nScore)
239230
{
@@ -256,7 +247,6 @@ bool AddLocal(const CService& addr, int nScore)
256247
info.nScore = nScore + (fAlready ? 1 : 0);
257248
info.nPort = addr.GetPort();
258249
}
259-
SetReachable(addr.GetNetwork());
260250
}
261251

262252
return true;
@@ -319,7 +309,7 @@ bool IsLocal(const CService& addr)
319309
bool IsReachable(enum Network net)
320310
{
321311
LOCK(cs_mapLocalHost);
322-
return vfReachable[net] && !vfLimited[net];
312+
return !vfLimited[net];
323313
}
324314

325315
/** check whether a given address is in a network we can probably connect to */

src/net.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ bool IsLocal(const CService& addr);
146146
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
147147
bool IsReachable(enum Network net);
148148
bool IsReachable(const CNetAddr &addr);
149-
void SetReachable(enum Network net, bool fFlag = true);
150149
CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
151150

152151

src/torcontrol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& r
459459
if (GetArg("-onion", "") == "") {
460460
proxyType addrOnion = proxyType(CService("127.0.0.1", 9050), true);
461461
SetProxy(NET_TOR, addrOnion);
462-
SetReachable(NET_TOR);
462+
SetLimited(NET_TOR, false);
463463
}
464464

465465
// Finally - now create the service

0 commit comments

Comments
 (0)