Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up for internal/external tor changes #1181

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions common/src/main/java/haveno/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -293,7 +292,7 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ private TorMode getTorMode(BridgeAddressProvider bridgeAddressProvider,
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ 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;
}

@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();
});
}
Expand All @@ -53,7 +54,7 @@ public Socks5Proxy getSocksProxy() {

@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);
Expand Down Expand Up @@ -93,7 +94,7 @@ protected void createTorAndHiddenService() {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public void start(@Nullable SetupListener setupListener) {

@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;
}
Expand All @@ -93,7 +93,7 @@ public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
}
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;
Expand Down
Loading