clean up for internal/external tor changes

This commit is contained in:
woodser 2024-07-29 07:57:47 -04:00 committed by GitHub
parent 3d44f3777c
commit cf282fd930
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 14 deletions

View file

@ -123,7 +123,6 @@ public class Config {
public static final String DEFAULT_REGTEST_HOST = "none";
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";
public static final String UNSPECIFIED_HIDDENSERVICE_ADDRESS = "placeholder.onion";
// Static fields that provide access to Config properties in locations where injecting
// 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")
.withRequiredArg()
.ofType(String.class)
.defaultsTo(UNSPECIFIED_HIDDENSERVICE_ADDRESS);
.defaultsTo("");
ArgumentAcceptingOptionSpec<Integer> walletRpcBindPortOpt =
parser.accepts(WALLET_RPC_BIND_PORT, "Port to bind the wallet RPC on")

View file

@ -87,13 +87,11 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
String password,
@Nullable File cookieFile,
boolean useSafeCookieAuthentication) {
if (!hiddenServiceAddress.equals(Config.UNSPECIFIED_HIDDENSERVICE_ADDRESS)) {
if (!hiddenServiceAddress.equals("")) {
return new DirectBindTor();
}
else if (controlPort != Config.UNSPECIFIED_PORT) {
} else if (controlPort != Config.UNSPECIFIED_PORT) {
return new RunningTor(torDir, controlHost, controlPort, password, cookieFile, useSafeCookieAuthentication);
}
else {
} else {
return new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider);
}
}

View file

@ -31,7 +31,8 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
public TorNetworkNodeDirectBind(int servicePort,
NetworkProtoResolver networkProtoResolver,
@Nullable BanFilter banFilter,
int maxConnections, String hiddenServiceAddress) {
int maxConnections,
String hiddenServiceAddress) {
super(servicePort, networkProtoResolver, banFilter, maxConnections);
this.serviceAddress = hiddenServiceAddress;
}
@ -39,7 +40,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
@Override
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
super.shutDown(() -> {
log.info("TorNetworkNode shutdown already completed");
log.info("TorNetworkNodeDirectBind shutdown completed");
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
});
}
@ -53,7 +54,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
@Override
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 {
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
Socket sock = new Socket(InetAddress.getLoopbackAddress(), TOR_DATA_PORT);
@ -93,7 +94,7 @@ public class TorNetworkNodeDirectBind extends TorNetworkNode {
ServerSocket socket = new ServerSocket(servicePort);
nodeAddressProperty.set(new NodeAddress(serviceAddress + ":" + servicePort));
log.info("\n################################################################\n" +
"Tor hidden service published: {} Port: {}\n" +
"Bound to Tor hidden service: {} Port: {}\n" +
"################################################################",
serviceAddress, servicePort);
UserThread.execute(() -> setupListeners.forEach(SetupListener::onTorNodeReady));

View file

@ -64,9 +64,9 @@ public class TorNetworkNodeNetlayer extends TorNetworkNode {
@Override
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
log.info("TorNetworkNode shutdown started");
log.info("TorNetworkNodeNetlayer shutdown started");
if (shutDownComplete) {
log.info("TorNetworkNode shutdown already completed");
log.info("TorNetworkNodeNetlayer shutdown already completed");
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
return;
}
@ -93,7 +93,7 @@ public class TorNetworkNodeNetlayer extends TorNetworkNode {
}
executor.shutdownNow();
} catch (Throwable e) {
log.error("Shutdown torNetworkNode failed with exception", e);
log.error("Shutdown TorNetworkNodeNetlayer failed with exception", e);
} finally {
shutDownTimeoutTimer.stop();
shutDownComplete = true;