Skip to content

Commit ce7aa15

Browse files
wodryfurszy
authored andcommitted
scripted-diff: Replace NET_TOR with NET_ONION
-BEGIN VERIFY SCRIPT- sed --in-place'' --expression='s/NET_TOR/NET_ONION/g' $(git grep -I --files-with-matches 'NET_TOR') -END VERIFY SCRIPT- The --in-place'' hack is required for sed on macOS to edit files in-place without passing a backup extension.
1 parent 4c3ae7d commit ce7aa15

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ bool AppInitMain()
13991399
// -proxy sets a proxy for all outgoing network traffic
14001400
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
14011401
std::string proxyArg = gArgs.GetArg("-proxy", "");
1402-
SetLimited(NET_TOR);
1402+
SetLimited(NET_ONION);
14031403
if (!proxyArg.empty() && proxyArg != "0") {
14041404
CService proxyAddr;
14051405
if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) {
@@ -1412,9 +1412,9 @@ bool AppInitMain()
14121412

14131413
SetProxy(NET_IPV4, addrProxy);
14141414
SetProxy(NET_IPV6, addrProxy);
1415-
SetProxy(NET_TOR, addrProxy);
1415+
SetProxy(NET_ONION, addrProxy);
14161416
SetNameProxy(addrProxy);
1417-
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
1417+
SetLimited(NET_ONION, false); // by default, -proxy sets onion as reachable, unless -noonion later
14181418
}
14191419

14201420
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
@@ -1423,7 +1423,7 @@ bool AppInitMain()
14231423
std::string onionArg = gArgs.GetArg("-onion", "");
14241424
if (!onionArg.empty()) {
14251425
if (onionArg == "0") { // Handle -noonion/-onion=0
1426-
SetLimited(NET_TOR); // set onions as unreachable
1426+
SetLimited(NET_ONION); // set onions as unreachable
14271427
} else {
14281428
CService onionProxy;
14291429
if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) {
@@ -1432,8 +1432,8 @@ bool AppInitMain()
14321432
proxyType addrOnion = proxyType(onionProxy, proxyRandomize);
14331433
if (!addrOnion.IsValid())
14341434
return UIError(strprintf(_("%s Invalid %s address or hostname: '%s'"), "isValid():", "-onion", onionArg));
1435-
SetProxy(NET_TOR, addrOnion);
1436-
SetLimited(NET_TOR, false);
1435+
SetProxy(NET_ONION, addrOnion);
1436+
SetLimited(NET_ONION, false);
14371437
}
14381438
}
14391439

src/netaddress.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ enum Network CNetAddr::GetNetwork() const
254254
return NET_IPV4;
255255

256256
if (IsTor())
257-
return NET_TOR;
257+
return NET_ONION;
258258

259259
return NET_IPV6;
260260
}
@@ -376,7 +376,7 @@ std::vector<unsigned char> CNetAddr::GetGroup(const std::vector<bool> &asmap) co
376376
}
377377
else if (IsTor())
378378
{
379-
nClass = NET_TOR;
379+
nClass = NET_ONION;
380380
nStartByte = 6;
381381
nBits = 4;
382382
}
@@ -475,11 +475,11 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
475475
case NET_IPV4: return REACH_IPV4;
476476
case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled
477477
}
478-
case NET_TOR:
478+
case NET_ONION:
479479
switch(ourNet) {
480480
default: return REACH_DEFAULT;
481481
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
482-
case NET_TOR: return REACH_PRIVATE;
482+
case NET_ONION: return REACH_PRIVATE;
483483
}
484484
case NET_TEREDO:
485485
switch(ourNet) {
@@ -496,7 +496,7 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
496496
case NET_TEREDO: return REACH_TEREDO;
497497
case NET_IPV6: return REACH_IPV6_WEAK;
498498
case NET_IPV4: return REACH_IPV4;
499-
case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address
499+
case NET_ONION: return REACH_PRIVATE; // either from Tor, or don't care about our address
500500
}
501501
}
502502
}

src/netaddress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum Network {
2222
NET_UNROUTABLE = 0,
2323
NET_IPV4,
2424
NET_IPV6,
25-
NET_TOR,
25+
NET_ONION,
2626
NET_INTERNAL,
2727

2828
NET_MAX,

src/netbase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum Network ParseNetwork(std::string net)
4141
Downcase(net);
4242
if (net == "ipv4") return NET_IPV4;
4343
if (net == "ipv6") return NET_IPV6;
44-
if (net == "tor" || net == "onion") return NET_TOR;
44+
if (net == "tor" || net == "onion") return NET_ONION;
4545
return NET_UNROUTABLE;
4646
}
4747

@@ -52,7 +52,7 @@ std::string GetNetworkName(enum Network net)
5252
return "ipv4";
5353
case NET_IPV6:
5454
return "ipv6";
55-
case NET_TOR:
55+
case NET_ONION:
5656
return "onion";
5757
default:
5858
return "";

src/test/netbase_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(netbase_networks)
4242
BOOST_CHECK(ResolveIP("::1").GetNetwork() == NET_UNROUTABLE);
4343
BOOST_CHECK(ResolveIP("8.8.8.8").GetNetwork() == NET_IPV4);
4444
BOOST_CHECK(ResolveIP("2001::8888").GetNetwork() == NET_IPV6);
45-
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR);
45+
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_ONION);
4646
BOOST_CHECK(CreateInternal("foo.com").GetNetwork() == NET_INTERNAL);
4747
}
4848

@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(netbase_getgroup)
315315
BOOST_CHECK(ResolveIP("64:FF9B::102:304").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC6052
316316
BOOST_CHECK(ResolveIP("2002:102:304:9999:9999:9999:9999:9999").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC3964
317317
BOOST_CHECK(ResolveIP("2001:0:9999:9999:9999:9999:FEFD:FCFB").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC4380
318-
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_TOR, 239})); // Tor
318+
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_ONION, 239})); // Tor
319319
BOOST_CHECK(ResolveIP("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 4, 112, 175})); //he.net
320320
BOOST_CHECK(ResolveIP("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup(asmap) == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 32, 1})); //IPv6
321321

@@ -328,13 +328,13 @@ BOOST_AUTO_TEST_CASE(netbase_parsenetwork)
328328
{
329329
BOOST_CHECK_EQUAL(ParseNetwork("ipv4"), NET_IPV4);
330330
BOOST_CHECK_EQUAL(ParseNetwork("ipv6"), NET_IPV6);
331-
BOOST_CHECK_EQUAL(ParseNetwork("onion"), NET_TOR);
332-
BOOST_CHECK_EQUAL(ParseNetwork("tor"), NET_TOR);
331+
BOOST_CHECK_EQUAL(ParseNetwork("onion"), NET_ONION);
332+
BOOST_CHECK_EQUAL(ParseNetwork("tor"), NET_ONION);
333333

334334
BOOST_CHECK_EQUAL(ParseNetwork("IPv4"), NET_IPV4);
335335
BOOST_CHECK_EQUAL(ParseNetwork("IPv6"), NET_IPV6);
336-
BOOST_CHECK_EQUAL(ParseNetwork("ONION"), NET_TOR);
337-
BOOST_CHECK_EQUAL(ParseNetwork("TOR"), NET_TOR);
336+
BOOST_CHECK_EQUAL(ParseNetwork("ONION"), NET_ONION);
337+
BOOST_CHECK_EQUAL(ParseNetwork("TOR"), NET_ONION);
338338

339339
BOOST_CHECK_EQUAL(ParseNetwork(":)"), NET_UNROUTABLE);
340340
BOOST_CHECK_EQUAL(ParseNetwork("tÖr"), NET_UNROUTABLE);

src/torcontrol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
530530
if (gArgs.GetArg("-onion", "") == "") {
531531
CService resolved(LookupNumeric("127.0.0.1", 9050));
532532
proxyType addrOnion = proxyType(resolved, true);
533-
SetProxy(NET_TOR, addrOnion);
534-
SetLimited(NET_TOR, false);
533+
SetProxy(NET_ONION, addrOnion);
534+
SetLimited(NET_ONION, false);
535535
}
536536

537537
// Finally - now create the service

0 commit comments

Comments
 (0)