mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move 'torrcOptions' option handling to Config
This commit is contained in:
parent
fea3a641c0
commit
923ec69966
@ -10,6 +10,7 @@ import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
import joptsimple.util.PathConverter;
|
||||
import joptsimple.util.PathProperties;
|
||||
import joptsimple.util.RegexMatcher;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -47,6 +48,7 @@ public class Config {
|
||||
public static final String SOCKS_5_PROXY_BTC_ADDRESS = "socks5ProxyBtcAddress";
|
||||
public static final String SOCKS_5_PROXY_HTTP_ADDRESS = "socks5ProxyHttpAddress";
|
||||
public static final String TORRC_FILE = "torrcFile";
|
||||
public static final String TORRC_OPTIONS = "torrcOptions";
|
||||
|
||||
static final String DEFAULT_CONFIG_FILE_NAME = "bisq.properties";
|
||||
|
||||
@ -87,6 +89,7 @@ public class Config {
|
||||
private final String socks5ProxyBtcAddress;
|
||||
private final String socks5ProxyHttpAddress;
|
||||
private final File torrcFile;
|
||||
private final String torrcOptions;
|
||||
|
||||
// properties derived from cli options, but not exposed as cli options themselves
|
||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||
@ -296,6 +299,14 @@ public class Config {
|
||||
.withRequiredArg()
|
||||
.describedAs("File")
|
||||
.withValuesConvertedBy(new PathConverter(PathProperties.FILE_EXISTING, PathProperties.READABLE));
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> torrcOptionsOpt =
|
||||
parser.accepts(TORRC_OPTIONS, "A list of torrc-entries to amend to Bisq's torrc. Note that " +
|
||||
"torrc-entries, which are critical to Bisq's flawless operation, cannot be overwritten. " +
|
||||
"[torrc options line, torrc option, ...]")
|
||||
.withRequiredArg()
|
||||
.withValuesConvertedBy(RegexMatcher.regex("^([^\\s,]+\\s[^,]+,?\\s*)+$"))
|
||||
.defaultsTo("");
|
||||
try {
|
||||
OptionSet cliOpts = parser.parse(args);
|
||||
|
||||
@ -347,6 +358,7 @@ public class Config {
|
||||
this.fullDaoNode = options.valueOf(fullDaoNodeOpt);
|
||||
this.logLevel = options.valueOf(logLevelOpt);
|
||||
this.torrcFile = options.has(torrcFileOpt) ? options.valueOf(torrcFileOpt).toFile() : null;
|
||||
this.torrcOptions = options.valueOf(torrcOptionsOpt);
|
||||
this.referralId = options.valueOf(referralIdOpt);
|
||||
this.useDevMode = options.valueOf(useDevModeOpt);
|
||||
this.useDevPrivilegeKeys = options.valueOf(useDevPrivilegeKeysOpt);
|
||||
@ -555,4 +567,8 @@ public class Config {
|
||||
public File getTorrcFile() {
|
||||
return torrcFile;
|
||||
}
|
||||
|
||||
public String getTorrcOptions() {
|
||||
return torrcOptions;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
|
||||
protected final String btcNodes, useTorForBtc, rpcUser, rpcPassword,
|
||||
rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode,
|
||||
torRcOptions, externalTorControlPort, externalTorPassword, externalTorCookieFile,
|
||||
externalTorControlPort, externalTorPassword, 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
|
||||
torRcOptions = getProperty(commandLineProperties, NetworkOptionKeys.TORRC_OPTIONS, "");
|
||||
externalTorControlPort = getProperty(commandLineProperties, NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT, "");
|
||||
externalTorPassword = getProperty(commandLineProperties, NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, "");
|
||||
externalTorCookieFile = getProperty(commandLineProperties, NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE, "");
|
||||
@ -135,7 +134,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.TORRC_OPTIONS, torRcOptions);
|
||||
setProperty(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT, externalTorControlPort);
|
||||
setProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, externalTorPassword);
|
||||
setProperty(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE, externalTorCookieFile);
|
||||
|
@ -53,7 +53,6 @@ import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.util.PathConverter;
|
||||
import joptsimple.util.PathProperties;
|
||||
import joptsimple.util.RegexMatcher;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@ -276,13 +275,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
|
||||
protected void customizeOptionParsing(OptionParser parser) {
|
||||
//NetworkOptionKeys
|
||||
parser.accepts(NetworkOptionKeys.TORRC_OPTIONS,
|
||||
"A list of torrc-entries to amend to Bisq's torrc. Note that torrc-entries," +
|
||||
"which are critical to Bisq's flawless operation, cannot be overwritten. " +
|
||||
"[torrc options line, torrc option, ...]")
|
||||
.withRequiredArg()
|
||||
.withValuesConvertedBy(RegexMatcher.regex("^([^\\s,]+\\s[^,]+,?\\s*)+$"));
|
||||
|
||||
parser.accepts(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT,
|
||||
"The control port of an already running Tor service to be used by Bisq.")
|
||||
//.availableUnless(Config.TORRC_FILE, NetworkOptionKeys.TORRC_OPTIONS)
|
||||
|
@ -19,7 +19,6 @@ package bisq.network;
|
||||
|
||||
public class NetworkOptionKeys {
|
||||
public static final String NETWORK_ID = "networkId";
|
||||
public static final String TORRC_OPTIONS = "torrcOptions";
|
||||
public static final String EXTERNAL_TOR_CONTROL_PORT = "torControlPort";
|
||||
public static final String EXTERNAL_TOR_PASSWORD = "torControlPassword";
|
||||
public static final String EXTERNAL_TOR_COOKIE_FILE = "torControlCookieFile";
|
||||
|
@ -48,7 +48,7 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||
@Named(Config.NODE_PORT) int port,
|
||||
@Named(Config.TOR_DIR) File torDir,
|
||||
@Nullable @Named(Config.TORRC_FILE) File torrcFile,
|
||||
@Named(NetworkOptionKeys.TORRC_OPTIONS) String torrcOptions,
|
||||
@Named(Config.TORRC_OPTIONS) String torrcOptions,
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) String controlPort,
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) String password,
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE) String cookieFile,
|
||||
|
@ -94,7 +94,7 @@ public class P2PModule extends AppModule {
|
||||
bindConstant().annotatedWith(named(SOCKS_5_PROXY_BTC_ADDRESS)).to(config.getSocks5ProxyBtcAddress());
|
||||
bindConstant().annotatedWith(named(SOCKS_5_PROXY_HTTP_ADDRESS)).to(config.getSocks5ProxyHttpAddress());
|
||||
bind(File.class).annotatedWith(named(TORRC_FILE)).toProvider(of(config.getTorrcFile())); // allow null value
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.TORRC_OPTIONS)).to(environment.getRequiredProperty(NetworkOptionKeys.TORRC_OPTIONS));
|
||||
bindConstant().annotatedWith(named(TORRC_OPTIONS)).to(config.getTorrcOptions());
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT)).to(environment.getRequiredProperty(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT));
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD)).to(environment.getRequiredProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD));
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE)).to(environment.getRequiredProperty(NetworkOptionKeys.EXTERNAL_TOR_COOKIE_FILE));
|
||||
|
Loading…
Reference in New Issue
Block a user