Skip to content

Commit af9d7c0

Browse files
achow101vijaydasmp
authored andcommitted
Merge bitcoin#28101: doc, refactor: changing -torcontrol help to specify that a default port is used
9a84200 doc, refactor: Changing -torcontrol help to specify that a default port is used (kevkevin) Pull request description: Right now when we get the help for -torcontrol it says that there is a default ip and port we dont specify if there is a specified ip that we would also use port 9051 as default Also I create a new const instead of using 9051 directly in the function linking this PR because this was discussed here bitcoin#28018 ACKs for top commit: jonatack: re-ACK 9a84200 achow101: ACK 9a84200 MarnixCroes: utACK 9a84200 kristapsk: utACK 9a84200 Tree-SHA512: 21d9e65f3c280a2853a9cf60d4e93e8d72caccea106206d1862c19535bde7ea6ada7f55e6ea19a1fc0f59dbe791ec6fc4084fdbe7fa6d6991fa89c62070db637
1 parent d83cee2 commit af9d7c0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ void SetupServerArgs(ArgsManager& argsman)
648648
argsman.AddArg("-socketevents=<mode>", "Socket events mode, which must be one of 'select', 'poll', 'epoll' or 'kqueue', depending on your system (default: Linux - 'epoll', FreeBSD/Apple - 'kqueue', Windows - 'select')", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
649649
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
650650
argsman.AddArg("-timeout=<n>", strprintf("Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
651-
argsman.AddArg("-torcontrol=<ip>:<port>", strprintf("Tor control port to use if onion listening enabled (default: %s)", DEFAULT_TOR_CONTROL), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
651+
argsman.AddArg("-torcontrol=<ip>:<port>", strprintf("Tor control host and port to use if onion listening enabled (default: %s). If no port is specified, the default port of %i will be used.", DEFAULT_TOR_CONTROL, DEFAULT_TOR_CONTROL_PORT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
652652
argsman.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::CONNECTION);
653653
#ifdef USE_UPNP
654654
argsman.AddArg("-upnp", strprintf("Use UPnP to map the listening port (default: %u)", DEFAULT_UPNP), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);

src/torcontrol.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#include <event2/thread.h>
4141
#include <event2/util.h>
4242

43-
/** Default control port */
44-
const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051";
43+
/** Default control ip and port */
44+
const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:" + ToString(DEFAULT_TOR_CONTROL_PORT);
4545
/** Tor cookie size (from control-spec.txt) */
4646
static const int TOR_COOKIE_SIZE = 32;
4747
/** Size of client/server nonce for SAFECOOKIE */
@@ -142,7 +142,7 @@ bool TorControlConnection::Connect(const std::string& tor_control_center, const
142142
Disconnect();
143143
}
144144

145-
const std::optional<CService> control_service{Lookup(tor_control_center, 9051, fNameLookup)};
145+
const std::optional<CService> control_service{Lookup(tor_control_center, DEFAULT_TOR_CONTROL_PORT, fNameLookup)};
146146
if (!control_service.has_value()) {
147147
LogPrintf("tor: Failed to look up control center %s\n", tor_control_center);
148148
return false;

src/torcontrol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <string>
2020
#include <vector>
2121

22+
constexpr int DEFAULT_TOR_CONTROL_PORT = 9051;
2223
extern const std::string DEFAULT_TOR_CONTROL;
2324
static const bool DEFAULT_LISTEN_ONION = true;
2425

0 commit comments

Comments
 (0)