diff --git a/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java b/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java index e8cf8d9238..03652b970f 100644 --- a/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java +++ b/p2p/src/main/java/bisq/network/p2p/NetworkNodeProvider.java @@ -80,7 +80,7 @@ public class NetworkNodeProvider implements Provider { boolean useSafeCookieAuthentication) { return controlPort != Config.UNSPECIFIED_PORT ? new RunningTor(torDir, controlPort, password, cookieFile, useSafeCookieAuthentication) : - new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider.getBridgeAddresses()); + new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider); } @Override diff --git a/p2p/src/main/java/bisq/network/p2p/network/NewTor.java b/p2p/src/main/java/bisq/network/p2p/network/NewTor.java index 33f6d9ca69..7cd6589cc8 100644 --- a/p2p/src/main/java/bisq/network/p2p/network/NewTor.java +++ b/p2p/src/main/java/bisq/network/p2p/network/NewTor.java @@ -51,19 +51,20 @@ public class NewTor extends TorMode { private final File torrcFile; private final String torrcOptions; - private final Collection bridgeEntries; + private final BridgeAddressProvider bridgeAddressProvider; - public NewTor(File torWorkingDirectory, @Nullable File torrcFile, String torrcOptions, Collection bridgeEntries) { + public NewTor(File torWorkingDirectory, @Nullable File torrcFile, String torrcOptions, BridgeAddressProvider bridgeAddressProvider) { super(torWorkingDirectory); this.torrcFile = torrcFile; this.torrcOptions = torrcOptions; - this.bridgeEntries = bridgeEntries; + this.bridgeAddressProvider = bridgeAddressProvider; } @Override public Tor getTor() throws IOException, TorCtlException { long ts1 = new Date().getTime(); + Collection bridgeEntries = bridgeAddressProvider.getBridgeAddresses(); if (bridgeEntries != null) log.info("Using bridges: {}", bridgeEntries.stream().collect(Collectors.joining(","))); diff --git a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java index 3b544da4e5..33bc3d7912 100644 --- a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java +++ b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java @@ -29,6 +29,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CountDownLatch; import org.slf4j.Logger; @@ -55,7 +56,7 @@ public class TorNetworkNodeTest { latch = new CountDownLatch(1); int port = 9001; TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false, - new NewTor(new File("torNode_" + port), null, "", new ArrayList()), null); + new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null); node1.start(new SetupListener() { @Override public void onTorNodeReady() { @@ -82,7 +83,7 @@ public class TorNetworkNodeTest { latch = new CountDownLatch(1); int port2 = 9002; TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false, - new NewTor(new File("torNode_" + port), null, "", new ArrayList()), null); + new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null); node2.start(new SetupListener() { @Override public void onTorNodeReady() { @@ -140,7 +141,7 @@ public class TorNetworkNodeTest { latch = new CountDownLatch(2); int port = 9001; TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false, - new NewTor(new File("torNode_" + port), null, "", new ArrayList()), null); + new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null); node1.start(new SetupListener() { @Override public void onTorNodeReady() { @@ -166,7 +167,7 @@ public class TorNetworkNodeTest { int port2 = 9002; TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false, - new NewTor(new File("torNode_" + port), null, "", new ArrayList()), null); + new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null); node2.start(new SetupListener() { @Override public void onTorNodeReady() { @@ -217,4 +218,8 @@ public class TorNetworkNodeTest { node2.shutDown(latch::countDown); latch.await(); } + + public List getBridgeAddresses() { + return new ArrayList<>(); + } }