diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index c290c7db59..53805b7e0a 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -52,6 +52,7 @@ public class Config { public static final String TORRC_FILE = "torrcFile"; public static final String TORRC_OPTIONS = "torrcOptions"; public static final String TOR_CONTROL_PORT = "torControlPort"; + public static final String TOR_CONTROL_PASSWORD = "torControlPassword"; static final String DEFAULT_CONFIG_FILE_NAME = "bisq.properties"; @@ -94,6 +95,7 @@ public class Config { private final File torrcFile; private final String torrcOptions; private final int torControlPort; + private final String torControlPassword; // properties derived from cli options, but not exposed as cli options themselves private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state @@ -320,6 +322,11 @@ public class Config { .ofType(int.class) .describedAs("port"); + ArgumentAcceptingOptionSpec torControlPasswordOpt = + parser.accepts(TOR_CONTROL_PASSWORD, "The password for controlling the already running Tor service.") + .availableIf(TOR_CONTROL_PORT) + .withRequiredArg() + .defaultsTo(""); try { OptionSet cliOpts = parser.parse(args); @@ -373,6 +380,7 @@ public class Config { this.torrcFile = options.has(torrcFileOpt) ? options.valueOf(torrcFileOpt).toFile() : null; this.torrcOptions = options.valueOf(torrcOptionsOpt); this.torControlPort = options.has(torControlPortOpt) ? options.valueOf(torControlPortOpt) : NULL_INT; + this.torControlPassword = options.valueOf(torControlPasswordOpt); this.referralId = options.valueOf(referralIdOpt); this.useDevMode = options.valueOf(useDevModeOpt); this.useDevPrivilegeKeys = options.valueOf(useDevPrivilegeKeysOpt); @@ -589,4 +597,8 @@ public class Config { public int getTorControlPort() { return torControlPort; } + + public String getTorControlPassword() { + return torControlPassword; + } } diff --git a/core/src/main/java/bisq/core/app/BisqEnvironment.java b/core/src/main/java/bisq/core/app/BisqEnvironment.java index 43fd5b7f71..8c8f647e24 100644 --- a/core/src/main/java/bisq/core/app/BisqEnvironment.java +++ b/core/src/main/java/bisq/core/app/BisqEnvironment.java @@ -65,7 +65,7 @@ public class BisqEnvironment extends StandardEnvironment { protected final String btcNodes, useTorForBtc, rpcUser, rpcPassword, rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode, - externalTorPassword, externalTorCookieFile, + externalTorCookieFile, useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight, genesisTotalSupply, daoActivated, msgThrottlePerSec, msgThrottlePer10Sec, sendMsgThrottleTrigger, sendMsgThrottleSleep; @@ -82,7 +82,6 @@ public class BisqEnvironment extends StandardEnvironment { @SuppressWarnings("ConstantConditions") public BisqEnvironment(PropertySource commandLineProperties) { //NetworkOptionKeys - externalTorPassword = getProperty(commandLineProperties, NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, ""); externalTorCookieFile = getProperty(commandLineProperties, NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE, ""); externalTorUseSafeCookieAuthentication = commandLineProperties.containsProperty(NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE); torStreamIsolation = commandLineProperties.containsProperty(NetworkOptionKeys.TOR_STREAM_ISOLATION); @@ -133,7 +132,6 @@ public class BisqEnvironment extends StandardEnvironment { return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() { { setProperty(NetworkOptionKeys.NETWORK_ID, String.valueOf(BaseCurrencyNetwork.CURRENT_NETWORK.ordinal())); - setProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, externalTorPassword); setProperty(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE, externalTorCookieFile); if (externalTorUseSafeCookieAuthentication) setProperty(NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE, "true"); diff --git a/core/src/main/java/bisq/core/app/BisqExecutable.java b/core/src/main/java/bisq/core/app/BisqExecutable.java index 4fbbb113a3..a259f474ad 100644 --- a/core/src/main/java/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/bisq/core/app/BisqExecutable.java @@ -275,16 +275,11 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet protected void customizeOptionParsing(OptionParser parser) { //NetworkOptionKeys - parser.accepts(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, - "The password for controlling the already running Tor service.") - //.availableIf(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) - .withRequiredArg(); - parser.accepts(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE, "The cookie file for authenticating against the already running Tor service. " + "Use in conjunction with --" + NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE) //.availableIf(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) - .availableUnless(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) + //.availableUnless(Config.EXTERNAL_TOR_PASSWORD) .withRequiredArg() .withValuesConvertedBy(new PathConverter(PathProperties.FILE_EXISTING, PathProperties.READABLE)); diff --git a/p2p/src/main/java/bisq/network/NetworkOptionKeys.java b/p2p/src/main/java/bisq/network/NetworkOptionKeys.java index a399565149..d5c130fdc7 100644 --- a/p2p/src/main/java/bisq/network/NetworkOptionKeys.java +++ b/p2p/src/main/java/bisq/network/NetworkOptionKeys.java @@ -19,7 +19,6 @@ package bisq.network; public class NetworkOptionKeys { public static final String NETWORK_ID = "networkId"; - public static final String EXTERNAL_TOR_PASSWORD = "torControlPassword"; public static final String EXTERNAL_TOR_COOKIE_FILE = "torControlCookieFile"; public static final String EXTERNAL_TOR_USE_SAFECOOKIE = "torControlUseSafeCookieAuth"; public static final String TOR_STREAM_ISOLATION = "torStreamIsolation"; diff --git a/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java b/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java index 4b730bb58a..d5f64e6f8c 100644 --- a/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java +++ b/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java @@ -50,7 +50,7 @@ public class NetworkNodeProvider implements Provider { @Nullable @Named(Config.TORRC_FILE) File torrcFile, @Named(Config.TORRC_OPTIONS) String torrcOptions, @Named(Config.TOR_CONTROL_PORT) int controlPort, - @Named(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) String password, + @Named(Config.TOR_CONTROL_PASSWORD) String password, @Named(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE) String cookieFile, @Named(NetworkOptionKeys.TOR_STREAM_ISOLATION) boolean streamIsolation, @Named(NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE) boolean useSafeCookieAuthentication ) { diff --git a/p2p/src/main/java/bisq/network/p2p/P2PModule.java b/p2p/src/main/java/bisq/network/p2p/P2PModule.java index 3bb931c8ea..df3ecd7b55 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PModule.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PModule.java @@ -96,7 +96,7 @@ public class P2PModule extends AppModule { bind(File.class).annotatedWith(named(TORRC_FILE)).toProvider(of(config.getTorrcFile())); // allow null value bindConstant().annotatedWith(named(TORRC_OPTIONS)).to(config.getTorrcOptions()); bindConstant().annotatedWith(named(TOR_CONTROL_PORT)).to(config.getTorControlPort()); - bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD)).to(environment.getRequiredProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD)); + bindConstant().annotatedWith(named(TOR_CONTROL_PASSWORD)).to(config.getTorControlPassword()); bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE)).to(environment.getRequiredProperty(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE)); bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE)).to(environment.containsProperty(NetworkOptionKeys.EXTERNAL_TOR_USE_SAFECOOKIE)); bindConstant().annotatedWith(named(NetworkOptionKeys.TOR_STREAM_ISOLATION)).to(environment.containsProperty(NetworkOptionKeys.TOR_STREAM_ISOLATION));