mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
clean up for internal/external tor changes
Some checks failed
CI / build (macos-13) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
Codacy Coverage Reporter / Publish coverage (push) Has been cancelled
CodeQL / Analyze (java) (push) Has been cancelled
Some checks failed
CI / build (macos-13) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
Codacy Coverage Reporter / Publish coverage (push) Has been cancelled
CodeQL / Analyze (java) (push) Has been cancelled
This commit is contained in:
parent
3d44f3777c
commit
cf282fd930
4 changed files with 12 additions and 14 deletions
|
@ -123,7 +123,6 @@ public class Config {
|
||||||
public static final String DEFAULT_REGTEST_HOST = "none";
|
public static final String DEFAULT_REGTEST_HOST = "none";
|
||||||
public static final int DEFAULT_NUM_CONNECTIONS_FOR_BTC = 9; // down from BitcoinJ default of 12
|
public static final int DEFAULT_NUM_CONNECTIONS_FOR_BTC = 9; // down from BitcoinJ default of 12
|
||||||
static final String DEFAULT_CONFIG_FILE_NAME = "haveno.properties";
|
static final String DEFAULT_CONFIG_FILE_NAME = "haveno.properties";
|
||||||
public static final String UNSPECIFIED_HIDDENSERVICE_ADDRESS = "placeholder.onion";
|
|
||||||
|
|
||||||
// Static fields that provide access to Config properties in locations where injecting
|
// Static fields that provide access to Config properties in locations where injecting
|
||||||
// a Config instance is not feasible. See Javadoc for corresponding static accessors.
|
// a Config instance is not feasible. See Javadoc for corresponding static accessors.
|
||||||
|
@ -293,7 +292,7 @@ public class Config {
|
||||||
parser.accepts(HIDDEN_SERVICE_ADDRESS, "Hidden Service Address to listen on")
|
parser.accepts(HIDDEN_SERVICE_ADDRESS, "Hidden Service Address to listen on")
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.ofType(String.class)
|
.ofType(String.class)
|
||||||
.defaultsTo(UNSPECIFIED_HIDDENSERVICE_ADDRESS);
|
.defaultsTo("");
|
||||||
|
|
||||||
ArgumentAcceptingOptionSpec<Integer> walletRpcBindPortOpt =
|
ArgumentAcceptingOptionSpec<Integer> walletRpcBindPortOpt =
|
||||||
parser.accepts(WALLET_RPC_BIND_PORT, "Port to bind the wallet RPC on")
|
parser.accepts(WALLET_RPC_BIND_PORT, "Port to bind the wallet RPC on")
|
||||||
|
|
|
@ -87,13 +87,11 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||||
String password,
|
String password,
|
||||||
@Nullable File cookieFile,
|
@Nullable File cookieFile,
|
||||||
boolean useSafeCookieAuthentication) {
|
boolean useSafeCookieAuthentication) {
|
||||||
if (!hiddenServiceAddress.equals(Config.UNSPECIFIED_HIDDENSERVICE_ADDRESS)) {
|
if (!hiddenServiceAddress.equals("")) {
|
||||||
return new DirectBindTor();
|
return new DirectBindTor();
|
||||||
}
|
} else if (controlPort != Config.UNSPECIFIED_PORT) {
|
||||||
else if (controlPort != Config.UNSPECIFIED_PORT) {
|
|
||||||
return new RunningTor(torDir, controlHost, controlPort, password, cookieFile, useSafeCookieAuthentication);
|
return new RunningTor(torDir, controlHost, controlPort, password, cookieFile, useSafeCookieAuthentication);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider);
|
return new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
|
||||||
public TorNetworkNodeDirectBind(int servicePort,
|
public TorNetworkNodeDirectBind(int servicePort,
|
||||||
NetworkProtoResolver networkProtoResolver,
|
NetworkProtoResolver networkProtoResolver,
|
||||||
@Nullable BanFilter banFilter,
|
@Nullable BanFilter banFilter,
|
||||||
int maxConnections, String hiddenServiceAddress) {
|
int maxConnections,
|
||||||
|
String hiddenServiceAddress) {
|
||||||
super(servicePort, networkProtoResolver, banFilter, maxConnections);
|
super(servicePort, networkProtoResolver, banFilter, maxConnections);
|
||||||
this.serviceAddress = hiddenServiceAddress;
|
this.serviceAddress = hiddenServiceAddress;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +40,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
|
||||||
@Override
|
@Override
|
||||||
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
||||||
super.shutDown(() -> {
|
super.shutDown(() -> {
|
||||||
log.info("TorNetworkNode shutdown already completed");
|
log.info("TorNetworkNodeDirectBind shutdown completed");
|
||||||
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
|
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -53,7 +54,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
|
protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
|
||||||
// https://www.ietf.org/rfc1928.txt SOCKS5 Protocol
|
// https://datatracker.ietf.org/doc/html/rfc1928 SOCKS5 Protocol
|
||||||
try {
|
try {
|
||||||
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
|
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
|
||||||
Socket sock = new Socket(InetAddress.getLoopbackAddress(), TOR_DATA_PORT);
|
Socket sock = new Socket(InetAddress.getLoopbackAddress(), TOR_DATA_PORT);
|
||||||
|
@ -93,7 +94,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
|
||||||
ServerSocket socket = new ServerSocket(servicePort);
|
ServerSocket socket = new ServerSocket(servicePort);
|
||||||
nodeAddressProperty.set(new NodeAddress(serviceAddress + ":" + servicePort));
|
nodeAddressProperty.set(new NodeAddress(serviceAddress + ":" + servicePort));
|
||||||
log.info("\n################################################################\n" +
|
log.info("\n################################################################\n" +
|
||||||
"Tor hidden service published: {} Port: {}\n" +
|
"Bound to Tor hidden service: {} Port: {}\n" +
|
||||||
"################################################################",
|
"################################################################",
|
||||||
serviceAddress, servicePort);
|
serviceAddress, servicePort);
|
||||||
UserThread.execute(() -> setupListeners.forEach(SetupListener::onTorNodeReady));
|
UserThread.execute(() -> setupListeners.forEach(SetupListener::onTorNodeReady));
|
||||||
|
|
|
@ -64,9 +64,9 @@ public class TorNetworkNodeNetlayer extends TorNetworkNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
||||||
log.info("TorNetworkNode shutdown started");
|
log.info("TorNetworkNodeNetlayer shutdown started");
|
||||||
if (shutDownComplete) {
|
if (shutDownComplete) {
|
||||||
log.info("TorNetworkNode shutdown already completed");
|
log.info("TorNetworkNodeNetlayer shutdown already completed");
|
||||||
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
|
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class TorNetworkNodeNetlayer extends TorNetworkNode {
|
||||||
}
|
}
|
||||||
executor.shutdownNow();
|
executor.shutdownNow();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Shutdown torNetworkNode failed with exception", e);
|
log.error("Shutdown TorNetworkNodeNetlayer failed with exception", e);
|
||||||
} finally {
|
} finally {
|
||||||
shutDownTimeoutTimer.stop();
|
shutDownTimeoutTimer.stop();
|
||||||
shutDownComplete = true;
|
shutDownComplete = true;
|
||||||
|
|
Loading…
Reference in a new issue