mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move 'torControlPassword' option handling to Config
This commit is contained in:
parent
d25ad0d266
commit
5966d0ddcb
@ -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<String> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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";
|
||||
|
@ -50,7 +50,7 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||
@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 ) {
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user