Skip to content

Commit 07c493f

Browse files
author
wodry
committed
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 686e97a commit 07c493f

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

src/init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ bool AppInitMain()
13581358
// -proxy sets a proxy for all outgoing network traffic
13591359
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
13601360
std::string proxyArg = gArgs.GetArg("-proxy", "");
1361-
SetLimited(NET_TOR);
1361+
SetLimited(NET_ONION);
13621362
if (proxyArg != "" && proxyArg != "0") {
13631363
CService proxyAddr;
13641364
if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) {
@@ -1371,9 +1371,9 @@ bool AppInitMain()
13711371

13721372
SetProxy(NET_IPV4, addrProxy);
13731373
SetProxy(NET_IPV6, addrProxy);
1374-
SetProxy(NET_TOR, addrProxy);
1374+
SetProxy(NET_ONION, addrProxy);
13751375
SetNameProxy(addrProxy);
1376-
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
1376+
SetLimited(NET_ONION, false); // by default, -proxy sets onion as reachable, unless -noonion later
13771377
}
13781378

13791379
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
@@ -1382,7 +1382,7 @@ bool AppInitMain()
13821382
std::string onionArg = gArgs.GetArg("-onion", "");
13831383
if (onionArg != "") {
13841384
if (onionArg == "0") { // Handle -noonion/-onion=0
1385-
SetLimited(NET_TOR); // set onions as unreachable
1385+
SetLimited(NET_ONION); // set onions as unreachable
13861386
} else {
13871387
CService onionProxy;
13881388
if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) {
@@ -1391,8 +1391,8 @@ bool AppInitMain()
13911391
proxyType addrOnion = proxyType(onionProxy, proxyRandomize);
13921392
if (!addrOnion.IsValid())
13931393
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
1394-
SetProxy(NET_TOR, addrOnion);
1395-
SetLimited(NET_TOR, false);
1394+
SetProxy(NET_ONION, addrOnion);
1395+
SetLimited(NET_ONION, false);
13961396
}
13971397
}
13981398

src/netaddress.cpp

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

248248
if (IsTor())
249-
return NET_TOR;
249+
return NET_ONION;
250250

251251
return NET_IPV6;
252252
}
@@ -355,7 +355,7 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
355355
}
356356
else if (IsTor())
357357
{
358-
nClass = NET_TOR;
358+
nClass = NET_ONION;
359359
nStartByte = 6;
360360
nBits = 4;
361361
}
@@ -433,11 +433,11 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
433433
case NET_IPV4: return REACH_IPV4;
434434
case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled
435435
}
436-
case NET_TOR:
436+
case NET_ONION:
437437
switch(ourNet) {
438438
default: return REACH_DEFAULT;
439439
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
440-
case NET_TOR: return REACH_PRIVATE;
440+
case NET_ONION: return REACH_PRIVATE;
441441
}
442442
case NET_TEREDO:
443443
switch(ourNet) {
@@ -454,7 +454,7 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
454454
case NET_TEREDO: return REACH_TEREDO;
455455
case NET_IPV6: return REACH_IPV6_WEAK;
456456
case NET_IPV4: return REACH_IPV4;
457-
case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address
457+
case NET_ONION: return REACH_PRIVATE; // either from Tor, or don't care about our address
458458
}
459459
}
460460
}

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ enum Network ParseNetwork(std::string net) {
4141
boost::to_lower(net);
4242
if (net == "ipv4") return NET_IPV4;
4343
if (net == "ipv6") return NET_IPV6;
44-
if (net == "onion") return NET_TOR;
44+
if (net == "onion") return NET_ONION;
4545
if (net == "tor") {
4646
LogPrintf("Warning: net name 'tor' is deprecated and will be removed in the future. You should use 'onion' instead.\n");
47-
return NET_TOR;
47+
return NET_ONION;
4848
}
4949
return NET_UNROUTABLE;
5050
}
@@ -54,7 +54,7 @@ std::string GetNetworkName(enum Network net) {
5454
{
5555
case NET_IPV4: return "ipv4";
5656
case NET_IPV6: return "ipv6";
57-
case NET_TOR: return "onion";
57+
case NET_ONION: return "onion";
5858
default: return "";
5959
}
6060
}

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void OptionsDialog::updateDefaultProxyNets()
331331
strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text();
332332
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv6->setChecked(true) : ui->proxyReachIPv6->setChecked(false);
333333

334-
model->node().getProxy(NET_TOR, proxy);
334+
model->node().getProxy(NET_ONION, proxy);
335335
strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort();
336336
strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text();
337337
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) : ui->proxyReachTor->setChecked(false);

src/test/netbase_tests.cpp

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

4545
}
@@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(netbase_getgroup)
293293
BOOST_CHECK(ResolveIP("64:FF9B::102:304").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC6052
294294
BOOST_CHECK(ResolveIP("2002:102:304:9999:9999:9999:9999:9999").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC3964
295295
BOOST_CHECK(ResolveIP("2001:0:9999:9999:9999:9999:FEFD:FCFB").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV4, 1, 2})); // RFC4380
296-
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_TOR, 239})); // Tor
296+
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_ONION, 239})); // Tor
297297
BOOST_CHECK(ResolveIP("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 4, 112, 175})); //he.net
298298
BOOST_CHECK(ResolveIP("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 32, 1})); //IPv6
299299

src/torcontrol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
528528
if (gArgs.GetArg("-onion", "") == "") {
529529
CService resolved(LookupNumeric("127.0.0.1", 9050));
530530
proxyType addrOnion = proxyType(resolved, true);
531-
SetProxy(NET_TOR, addrOnion);
532-
SetLimited(NET_TOR, false);
531+
SetProxy(NET_ONION, addrOnion);
532+
SetLimited(NET_ONION, false);
533533
}
534534

535535
// Finally - now create the service

0 commit comments

Comments
 (0)