Skip to content

Commit 9a84200

Browse files
committed
doc, refactor: Changing -torcontrol help to specify that a default port is used
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
1 parent 6ce5e8f commit 9a84200

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
@@ -509,7 +509,7 @@ void SetupServerArgs(ArgsManager& argsman)
509509
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
510510
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);
511511
argsman.AddArg("-peertimeout=<n>", strprintf("Specify a p2p connection timeout delay in seconds. After connecting to a peer, wait this amount of time before considering disconnection based on inactivity (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
512-
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);
512+
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);
513513
argsman.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::CONNECTION);
514514
#ifdef USE_UPNP
515515
#if USE_UPNP

src/torcontrol.cpp

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

45-
/** Default control port */
46-
const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051";
45+
/** Default control ip and port */
46+
const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:" + ToString(DEFAULT_TOR_CONTROL_PORT);
4747
/** Tor cookie size (from control-spec.txt) */
4848
static const int TOR_COOKIE_SIZE = 32;
4949
/** Size of client/server nonce for SAFECOOKIE */
@@ -144,7 +144,7 @@ bool TorControlConnection::Connect(const std::string& tor_control_center, const
144144
Disconnect();
145145
}
146146

147-
const std::optional<CService> control_service{Lookup(tor_control_center, 9051, fNameLookup)};
147+
const std::optional<CService> control_service{Lookup(tor_control_center, DEFAULT_TOR_CONTROL_PORT, fNameLookup)};
148148
if (!control_service.has_value()) {
149149
LogPrintf("tor: Failed to look up control center %s\n", tor_control_center);
150150
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)