Skip to content

Commit a5bc6a1

Browse files
pstratemMarcoFalke
authored andcommitted
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. Github-Pull: #7553 Rebased-From: 110b62f
1 parent 52c1011 commit a5bc6a1

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
@@ -1175,6 +1175,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11751175
// -proxy sets a proxy for all outgoing network traffic
11761176
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
11771177
std::string proxyArg = GetArg("-proxy", "");
1178+
SetLimited(NET_TOR);
11781179
if (proxyArg != "" && proxyArg != "0") {
11791180
proxyType addrProxy = proxyType(CService(proxyArg, 9050), proxyRandomize);
11801181
if (!addrProxy.IsValid())
@@ -1184,7 +1185,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11841185
SetProxy(NET_IPV6, addrProxy);
11851186
SetProxy(NET_TOR, addrProxy);
11861187
SetNameProxy(addrProxy);
1187-
SetReachable(NET_TOR); // by default, -proxy sets onion as reachable, unless -noonion later
1188+
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
11881189
}
11891190

11901191
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
@@ -1193,13 +1194,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11931194
std::string onionArg = GetArg("-onion", "");
11941195
if (onionArg != "") {
11951196
if (onionArg == "0") { // Handle -noonion/-onion=0
1196-
SetReachable(NET_TOR, false); // set onions as unreachable
1197+
SetLimited(NET_TOR); // set onions as unreachable
11971198
} else {
11981199
proxyType addrOnion = proxyType(CService(onionArg, 9050), proxyRandomize);
11991200
if (!addrOnion.IsValid())
12001201
return InitError(strprintf(_("Invalid -onion address: '%s'"), onionArg));
12011202
SetProxy(NET_TOR, addrOnion);
1202-
SetReachable(NET_TOR);
1203+
SetLimited(NET_TOR, false);
12031204
}
12041205
}
12051206

src/net.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ bool fListen = true;
7777
uint64_t nLocalServices = NODE_NETWORK;
7878
CCriticalSection cs_mapLocalHost;
7979
map<CNetAddr, LocalServiceInfo> mapLocalHost;
80-
static bool vfReachable[NET_MAX] = {};
8180
static bool vfLimited[NET_MAX] = {};
8281
static CNode* pnodeLocalHost = NULL;
8382
uint64_t nLocalHostNonce = 0;
@@ -224,14 +223,6 @@ void AdvertiseLocal(CNode *pnode)
224223
}
225224
}
226225

227-
void SetReachable(enum Network net, bool fFlag)
228-
{
229-
LOCK(cs_mapLocalHost);
230-
vfReachable[net] = fFlag;
231-
if (net == NET_IPV6 && fFlag)
232-
vfReachable[NET_IPV4] = true;
233-
}
234-
235226
// learn a new local address
236227
bool AddLocal(const CService& addr, int nScore)
237228
{
@@ -254,7 +245,6 @@ bool AddLocal(const CService& addr, int nScore)
254245
info.nScore = nScore + (fAlready ? 1 : 0);
255246
info.nPort = addr.GetPort();
256247
}
257-
SetReachable(addr.GetNetwork());
258248
}
259249

260250
return true;
@@ -317,7 +307,7 @@ bool IsLocal(const CService& addr)
317307
bool IsReachable(enum Network net)
318308
{
319309
LOCK(cs_mapLocalHost);
320-
return vfReachable[net] && !vfLimited[net];
310+
return !vfLimited[net];
321311
}
322312

323313
/** 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
@@ -460,7 +460,7 @@ void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& r
460460
if (GetArg("-onion", "") == "") {
461461
proxyType addrOnion = proxyType(CService("127.0.0.1", 9050), true);
462462
SetProxy(NET_TOR, addrOnion);
463-
SetReachable(NET_TOR);
463+
SetLimited(NET_TOR, false);
464464
}
465465

466466
// Finally - now create the service

0 commit comments

Comments
 (0)