mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Connect with PasswordAuthentication
This commit is contained in:
parent
63f8bbf8c5
commit
139ec518fc
@ -193,10 +193,9 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
protected final String btcNodes, seedNodes, ignoreDevMsg, useDevPrivilegeKeys, useDevMode, useTorForBtc, rpcUser, rpcPassword,
|
||||
rpcPort, rpcBlockNotificationPort, dumpBlockchainData, fullDaoNode,
|
||||
myAddress, banList, dumpStatistics, maxMemory, socks5ProxyBtcAddress,
|
||||
torRcFile, torRcOptions, externalTorControlPort,
|
||||
torRcFile, torRcOptions, externalTorControlPort, externalTorPassword,
|
||||
socks5ProxyHttpAddress, useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight, referralId, daoActivated;
|
||||
|
||||
|
||||
public BisqEnvironment(OptionSet options) {
|
||||
this(new JOptCommandLinePropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(
|
||||
options)));
|
||||
@ -277,6 +276,9 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
externalTorControlPort = commandLineProperties.containsProperty(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) ?
|
||||
(String) commandLineProperties.getProperty(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) :
|
||||
"";
|
||||
externalTorPassword = commandLineProperties.containsProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) ?
|
||||
(String) commandLineProperties.getProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) :
|
||||
"";
|
||||
|
||||
//RpcOptionKeys
|
||||
rpcUser = commandLineProperties.containsProperty(DaoOptionKeys.RPC_USER) ?
|
||||
@ -448,6 +450,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
setProperty(NetworkOptionKeys.TORRC_FILE, torRcFile);
|
||||
setProperty(NetworkOptionKeys.TORRC_OPTIONS, torRcOptions);
|
||||
setProperty(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT, externalTorControlPort);
|
||||
setProperty(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD, externalTorPassword);
|
||||
|
||||
setProperty(AppOptionKeys.APP_DATA_DIR_KEY, appDataDir);
|
||||
setProperty(AppOptionKeys.DESKTOP_WITH_HTTP_API, desktopWithHttpApi);
|
||||
|
@ -368,6 +368,10 @@ public abstract class BisqExecutable implements GracefulShutDownHandler {
|
||||
.availableUnless(NetworkOptionKeys.TORRC_FILE, NetworkOptionKeys.TORRC_OPTIONS)
|
||||
.withRequiredArg()
|
||||
.ofType(int.class);
|
||||
parser.accepts(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD,
|
||||
description("The password for controlling the already running Tor service.", ""))
|
||||
.availableIf(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT)
|
||||
.withRequiredArg();
|
||||
|
||||
//AppOptionKeys
|
||||
parser.accepts(AppOptionKeys.USER_DATA_DIR_KEY,
|
||||
|
@ -32,4 +32,5 @@ public class NetworkOptionKeys {
|
||||
public static final String TORRC_OPTIONS = "torrcOptions";
|
||||
public static final String TORRC_FILE = "torrcFile";
|
||||
public static final String EXTERNAL_TOR_CONTROL_PORT = "torControlPort";
|
||||
public static final String EXTERNAL_TOR_PASSWORD = "torControlPassword";
|
||||
}
|
||||
|
@ -47,12 +47,13 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||
@Named(NetworkOptionKeys.TOR_DIR) File torDir,
|
||||
@Named(NetworkOptionKeys.TORRC_FILE) String torrcFile,
|
||||
@Named(NetworkOptionKeys.TORRC_OPTIONS) String torrcOptions,
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) String controlPort) {
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) String controlPort,
|
||||
@Named(NetworkOptionKeys.EXTERNAL_TOR_PASSWORD) String password) {
|
||||
networkNode = useLocalhostForP2P ?
|
||||
new LocalhostNetworkNode(address, port, networkProtoResolver) :
|
||||
new TorNetworkNode(port, torDir, networkProtoResolver, bridgeAddressProvider,
|
||||
!controlPort.isEmpty() ?
|
||||
new RunningTor(torDir, Integer.parseInt(controlPort)) :
|
||||
new RunningTor(torDir, Integer.parseInt(controlPort), password) :
|
||||
new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider.getBridgeAddresses()));
|
||||
}
|
||||
|
||||
|
@ -91,5 +91,6 @@ public class P2PModule extends AppModule {
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.TORRC_FILE)).to(environment.getRequiredProperty(NetworkOptionKeys.TORRC_FILE));
|
||||
bindConstant().annotatedWith(named(NetworkOptionKeys.TORRC_OPTIONS)).to(environment.getRequiredProperty(NetworkOptionKeys.TORRC_OPTIONS));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,14 @@ public class RunningTor extends TorMode {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RunningTor.class);
|
||||
private final int controlPort;
|
||||
private final String password;
|
||||
private final String torDir;
|
||||
|
||||
|
||||
public RunningTor(final File torDir, final int controlPort) {
|
||||
public RunningTor(final File torDir, final int controlPort, final String password) {
|
||||
this.torDir = torDir.getAbsolutePath();
|
||||
this.controlPort = controlPort;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,7 +56,13 @@ public class RunningTor extends TorMode {
|
||||
long ts1 = new Date().getTime();
|
||||
|
||||
log.info("Connecting to running tor");
|
||||
Tor result = new ExternalTor(controlPort);
|
||||
|
||||
Tor result;
|
||||
if (!password.isEmpty())
|
||||
result = new ExternalTor(controlPort, password);
|
||||
else
|
||||
result = new ExternalTor(controlPort);
|
||||
|
||||
log.info(
|
||||
"\n################################################################\n"
|
||||
+ "Tor started after {} ms. Start publishing hidden service.\n"
|
||||
|
Loading…
Reference in New Issue
Block a user