diff --git a/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityKeyGenerationTests.java b/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityKeyGenerationTests.java index 6cda61b46f..047a5fb16a 100644 --- a/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityKeyGenerationTests.java +++ b/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityKeyGenerationTests.java @@ -17,7 +17,6 @@ package bisq.tor.local_network; -import bisq.tor.local_network.da.DirectoryAuthority; import bisq.tor.local_network.da.keygen.process.DirectoryAuthorityKeyGenerator; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -35,7 +34,7 @@ public void generateKeys(@TempDir Path dataDir) throws IOException, InterruptedE assertThat(keysPath.toFile().mkdirs()) .isTrue(); - var directoryAuthority = DirectoryAuthority.builder() + var directoryAuthority = TorNode.builder() .nickname("Nick") .dataDir(dataDir) .controlPort(1) diff --git a/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityTests.java b/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityTests.java index a806ade0e7..06f420d9a2 100644 --- a/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityTests.java +++ b/network/tor-local-network/src/integrationTest/java/bisq/tor/local_network/DirectoryAuthorityTests.java @@ -18,7 +18,6 @@ package bisq.tor.local_network; import bisq.common.util.NetworkUtils; -import bisq.tor.local_network.da.DirectoryAuthority; import bisq.tor.local_network.da.DirectoryAuthorityFactory; import bisq.tor.local_network.torrc.DirectoryAuthorityTorrcGenerator; import bisq.tor.local_network.torrc.TorrcFileGenerator; @@ -36,7 +35,7 @@ public class DirectoryAuthorityTests { @Test public void createOneDA(@TempDir Path tempDir) throws IOException, InterruptedException { - var firstDirectoryAuthority = DirectoryAuthority.builder() + var firstDirectoryAuthority = TorNode.builder() .nickname("DA_1") .dataDir(tempDir) .controlPort(NetworkUtils.findFreeSystemPort()) @@ -54,7 +53,7 @@ public void createThreeDA(@TempDir Path tempDir) throws IOException, Interrupted var dirAuthFactory = new DirectoryAuthorityFactory(); Path firstDaDataDir = tempDir.resolve("da_1"); - var firstDirectoryAuthority = DirectoryAuthority.builder() + var firstDirectoryAuthority = TorNode.builder() .nickname("DA_1") .dataDir(firstDaDataDir) .controlPort(NetworkUtils.findFreeSystemPort()) @@ -64,7 +63,7 @@ public void createThreeDA(@TempDir Path tempDir) throws IOException, Interrupted dirAuthFactory.createDirectoryAuthority(firstDirectoryAuthority, PASSPHRASE); Path secondDaDataDir = tempDir.resolve("da_2"); - var secondDirectoryAuthority = DirectoryAuthority.builder() + var secondDirectoryAuthority = TorNode.builder() .nickname("DA_2") .dataDir(secondDaDataDir) .controlPort(NetworkUtils.findFreeSystemPort()) @@ -74,7 +73,7 @@ public void createThreeDA(@TempDir Path tempDir) throws IOException, Interrupted dirAuthFactory.createDirectoryAuthority(secondDirectoryAuthority, PASSPHRASE); Path thirdDaDataDir = tempDir.resolve("da_3"); - var thirdDirectoryAuthority = DirectoryAuthority.builder() + var thirdDirectoryAuthority = TorNode.builder() .nickname("DA_3") .dataDir(thirdDaDataDir) .controlPort(NetworkUtils.findFreeSystemPort()) @@ -83,8 +82,8 @@ public void createThreeDA(@TempDir Path tempDir) throws IOException, Interrupted .build(); dirAuthFactory.createDirectoryAuthority(thirdDirectoryAuthority, PASSPHRASE); - Set allDAs = dirAuthFactory.getAllDirectoryAuthorities(); - for (DirectoryAuthority da : allDAs) { + Set allDAs = dirAuthFactory.getAllDirectoryAuthorities(); + for (TorNode da : allDAs) { var torDaTorrcGenerator = new DirectoryAuthorityTorrcGenerator(da); var torrcFileGenerator = new TorrcFileGenerator(torDaTorrcGenerator, allDAs); torrcFileGenerator.generate(); diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthority.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/TorNode.java similarity index 92% rename from network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthority.java rename to network/tor-local-network/src/main/java/bisq/tor/local_network/TorNode.java index 01d5976fb4..fe90657a42 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthority.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/TorNode.java @@ -15,9 +15,8 @@ * along with Bisq. If not, see . */ -package bisq.tor.local_network.da; +package bisq.tor.local_network; -import bisq.tor.local_network.KeyFingerprintReader; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -29,7 +28,7 @@ import java.util.function.UnaryOperator; @Getter -public class DirectoryAuthority { +public class TorNode { private final String nickname; private final Path dataDir; @@ -48,7 +47,7 @@ public class DirectoryAuthority { private Optional relayKeyFingerprint = Optional.empty(); @Builder - public DirectoryAuthority(String nickname, Path dataDir, int controlPort, int orPort, int dirPort) { + public TorNode(String nickname, Path dataDir, int controlPort, int orPort, int dirPort) { this.nickname = nickname; this.dataDir = dataDir; this.controlPort = controlPort; diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthorityFactory.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthorityFactory.java index 5c1b7a1df7..d1ac3ada98 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthorityFactory.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/DirectoryAuthorityFactory.java @@ -17,6 +17,7 @@ package bisq.tor.local_network.da; +import bisq.tor.local_network.TorNode; import bisq.tor.local_network.da.keygen.process.DirectoryAuthorityKeyGenerator; import lombok.Getter; @@ -29,9 +30,9 @@ public class DirectoryAuthorityFactory { @Getter - private final Set allDirectoryAuthorities = new HashSet<>(); + private final Set allDirectoryAuthorities = new HashSet<>(); - public void createDirectoryAuthority(DirectoryAuthority directoryAuthority, + public void createDirectoryAuthority(TorNode directoryAuthority, String passphrase) throws IOException, InterruptedException { Path dataDir = directoryAuthority.getDataDir(); createDataDirIfNotPresent(dataDir); diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/RelayKeyGenProcess.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/RelayKeyGenProcess.java index e1d21e2f18..c23c134700 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/RelayKeyGenProcess.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/RelayKeyGenProcess.java @@ -17,15 +17,15 @@ package bisq.tor.local_network.da.keygen; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; import java.io.IOException; import java.util.concurrent.TimeUnit; public class RelayKeyGenProcess { - private final DirectoryAuthority directoryAuthority; + private final TorNode directoryAuthority; - public RelayKeyGenProcess(DirectoryAuthority directoryAuthority) { + public RelayKeyGenProcess(TorNode directoryAuthority) { this.directoryAuthority = directoryAuthority; } diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/process/DirectoryAuthorityKeyGenerator.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/process/DirectoryAuthorityKeyGenerator.java index 140b3ca4b2..51ea36d136 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/process/DirectoryAuthorityKeyGenerator.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/da/keygen/process/DirectoryAuthorityKeyGenerator.java @@ -17,13 +17,13 @@ package bisq.tor.local_network.da.keygen.process; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; import bisq.tor.local_network.da.keygen.RelayKeyGenProcess; import java.io.IOException; public class DirectoryAuthorityKeyGenerator { - public static void generate(DirectoryAuthority directoryAuthority, String passphrase) throws IOException, InterruptedException { + public static void generate(TorNode directoryAuthority, String passphrase) throws IOException, InterruptedException { var identityKeyGenProcess = new DirectoryIdentityKeyGenProcess( directoryAuthority.getKeysPath(), "127.0.0.1:" + directoryAuthority.getDirPort() diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/CommonTorrcGenerator.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/CommonTorrcGenerator.java index 66ea325e8b..eafa49e864 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/CommonTorrcGenerator.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/CommonTorrcGenerator.java @@ -17,7 +17,7 @@ package bisq.tor.local_network.torrc; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; import lombok.Getter; /** @@ -25,11 +25,11 @@ */ @Getter public abstract class CommonTorrcGenerator { - protected final DirectoryAuthority thisDirectoryAuthority; + protected final TorNode thisTorNode; protected final StringBuilder torrcStringBuilder = new StringBuilder(); - public CommonTorrcGenerator(DirectoryAuthority thisDirectoryAuthority) { - this.thisDirectoryAuthority = thisDirectoryAuthority; + public CommonTorrcGenerator(TorNode thisTorNode) { + this.thisTorNode = thisTorNode; } public void generate() { @@ -43,28 +43,28 @@ public void generate() { .append("TestingDirAuthVoteGuard *\n") .append("TestingMinExitFlagThreshold 0\n") - .append("DataDirectory ").append(thisDirectoryAuthority.getDataDir()).append("\n") + .append("DataDirectory ").append(thisTorNode.getDataDir()).append("\n") .append("RunAsDaemon 1\n") - .append("Nickname ").append(thisDirectoryAuthority.getNickname()).append("\n") + .append("Nickname ").append(thisTorNode.getNickname()).append("\n") .append("ShutdownWaitLength 2\n") .append("DisableDebuggerAttachment 0\n") - .append("ControlPort 127.0.0.1:").append(thisDirectoryAuthority.getControlPort()).append("\n") + .append("ControlPort 127.0.0.1:").append(thisTorNode.getControlPort()).append("\n") .append("CookieAuthentication 1\n") - .append("Log debug file ").append(thisDirectoryAuthority.getDataDir().resolve("debug.log").toAbsolutePath()).append("\n") + .append("Log debug file ").append(thisTorNode.getDataDir().resolve("debug.log").toAbsolutePath()).append("\n") .append("ProtocolWarnings 1\n") .append("SafeLogging 0\n") .append("LogTimeGranularity 1\n") .append("SocksPort 0\n") - .append("OrPort ").append(thisDirectoryAuthority.getOrPort()).append("\n") + .append("OrPort ").append(thisTorNode.getOrPort()).append("\n") .append("Address 127.0.0.1\n") .append("ServerDNSDetectHijacking 0\n") .append("ServerDNSTestAddresses\n") - .append("DirPort ").append(thisDirectoryAuthority.getDirPort()).append("\n"); + .append("DirPort ").append(thisTorNode.getDirPort()).append("\n"); } } diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/DirectoryAuthorityTorrcGenerator.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/DirectoryAuthorityTorrcGenerator.java index d5363d357b..7250b04b1a 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/DirectoryAuthorityTorrcGenerator.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/DirectoryAuthorityTorrcGenerator.java @@ -17,10 +17,10 @@ package bisq.tor.local_network.torrc; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; public class DirectoryAuthorityTorrcGenerator extends CommonTorrcGenerator { - public DirectoryAuthorityTorrcGenerator(DirectoryAuthority thisDirectoryAuthority) { + public DirectoryAuthorityTorrcGenerator(TorNode thisDirectoryAuthority) { super(thisDirectoryAuthority); } @@ -31,7 +31,7 @@ public void generate() { torrcStringBuilder .append("AuthoritativeDirectory 1\n") .append("V3AuthoritativeDirectory 1\n") - .append("ContactInfo auth-").append(thisDirectoryAuthority.getNickname()).append("@test.test\n") + .append("ContactInfo auth-").append(thisTorNode.getNickname()).append("@test.test\n") .append("AssumeReachable 1\n") @@ -43,6 +43,6 @@ public void generate() { .append("V3AuthVoteDelay 4\n") .append("V3AuthDistDelay 4\n") - .append(thisDirectoryAuthority.getExitPolicy()).append("\n"); + .append(thisTorNode.getExitPolicy()).append("\n"); } } diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/RelayTorrcGenerator.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/RelayTorrcGenerator.java index c3067a8b8c..60fee95609 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/RelayTorrcGenerator.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/RelayTorrcGenerator.java @@ -17,11 +17,11 @@ package bisq.tor.local_network.torrc; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; public class RelayTorrcGenerator extends CommonTorrcGenerator { - public RelayTorrcGenerator(DirectoryAuthority thisDirectoryAuthority) { - super(thisDirectoryAuthority); + public RelayTorrcGenerator(TorNode thisTorNode) { + super(thisTorNode); } @Override diff --git a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/TorrcFileGenerator.java b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/TorrcFileGenerator.java index b2ff5bee61..7158a937ca 100644 --- a/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/TorrcFileGenerator.java +++ b/network/tor-local-network/src/main/java/bisq/tor/local_network/torrc/TorrcFileGenerator.java @@ -17,7 +17,7 @@ package bisq.tor.local_network.torrc; -import bisq.tor.local_network.da.DirectoryAuthority; +import bisq.tor.local_network.TorNode; import java.io.IOException; import java.nio.file.Files; @@ -25,9 +25,9 @@ public class TorrcFileGenerator { private final CommonTorrcGenerator commonTorrcGenerator; - private final Set allDirAuthorities; + private final Set allDirAuthorities; - public TorrcFileGenerator(CommonTorrcGenerator commonTorrcGenerator, Set allDirAuthorities) { + public TorrcFileGenerator(CommonTorrcGenerator commonTorrcGenerator, Set allDirAuthorities) { this.commonTorrcGenerator = commonTorrcGenerator; this.allDirAuthorities = allDirAuthorities; } @@ -44,7 +44,7 @@ public void generate() throws IOException { .append(" ").append(dirAuthority.getRelayKeyFingerprint().orElseThrow()) .append("\n")); - DirectoryAuthority thisDirectoryAuthority = commonTorrcGenerator.getThisDirectoryAuthority(); - Files.writeString(thisDirectoryAuthority.getTorrcPath(), torrcStringBuilder.toString()); + TorNode thisTorNode = commonTorrcGenerator.getThisTorNode(); + Files.writeString(thisTorNode.getTorrcPath(), torrcStringBuilder.toString()); } } diff --git a/network/tor-local-network/src/test/java/bisq/tor/local_network/DirectoryAuthorityTorrcGeneratorTests.java b/network/tor-local-network/src/test/java/bisq/tor/local_network/DirectoryAuthorityTorrcGeneratorTests.java index 9d2d0e7fd7..c9bd9072a9 100644 --- a/network/tor-local-network/src/test/java/bisq/tor/local_network/DirectoryAuthorityTorrcGeneratorTests.java +++ b/network/tor-local-network/src/test/java/bisq/tor/local_network/DirectoryAuthorityTorrcGeneratorTests.java @@ -17,7 +17,6 @@ package bisq.tor.local_network; -import bisq.tor.local_network.da.DirectoryAuthority; import bisq.tor.local_network.torrc.DirectoryAuthorityTorrcGenerator; import bisq.tor.local_network.torrc.TorrcFileGenerator; import org.junit.jupiter.api.Test; @@ -38,8 +37,8 @@ void basicTest(@TempDir Path tempDir) throws IOException { Path daAPath = tempDir.resolve("DA_A"); assertThat(daAPath.toFile().mkdir()).isTrue(); - DirectoryAuthority firstDirAuth = spy( - DirectoryAuthority.builder() + TorNode firstDirAuth = spy( + TorNode.builder() .nickname("A") .dataDir(daAPath) @@ -58,8 +57,8 @@ void basicTest(@TempDir Path tempDir) throws IOException { .when(firstDirAuth) .getRelayKeyFingerprint(); - DirectoryAuthority secondDirAuth = spy( - DirectoryAuthority.builder() + TorNode secondDirAuth = spy( + TorNode.builder() .nickname("B") .dataDir(tempDir.resolve("DA_B")) diff --git a/network/tor-local-network/src/test/java/bisq/tor/local_network/RelayTorrcGeneratorTests.java b/network/tor-local-network/src/test/java/bisq/tor/local_network/RelayTorrcGeneratorTests.java index 013c692439..1205113e7f 100644 --- a/network/tor-local-network/src/test/java/bisq/tor/local_network/RelayTorrcGeneratorTests.java +++ b/network/tor-local-network/src/test/java/bisq/tor/local_network/RelayTorrcGeneratorTests.java @@ -17,7 +17,6 @@ package bisq.tor.local_network; -import bisq.tor.local_network.da.DirectoryAuthority; import bisq.tor.local_network.torrc.RelayTorrcGenerator; import bisq.tor.local_network.torrc.TorrcFileGenerator; import org.junit.jupiter.api.Test; @@ -38,8 +37,8 @@ void basicTest(@TempDir Path tempDir) throws IOException { Path daAPath = tempDir.resolve("DA_A"); assertThat(daAPath.toFile().mkdir()).isTrue(); - DirectoryAuthority firstDirAuth = spy( - DirectoryAuthority.builder() + TorNode firstDirAuth = spy( + TorNode.builder() .nickname("A") .dataDir(daAPath) @@ -58,8 +57,8 @@ void basicTest(@TempDir Path tempDir) throws IOException { .when(firstDirAuth) .getRelayKeyFingerprint(); - DirectoryAuthority secondDirAuth = spy( - DirectoryAuthority.builder() + TorNode secondDirAuth = spy( + TorNode.builder() .nickname("B") .dataDir(tempDir.resolve("DA_B"))