From f99193174c7398622a84b57e41619b37f56ce1e9 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 7 Jun 2024 16:13:34 +0000 Subject: [PATCH 1/7] TorControlProtocol: Merge MidReplyLine and DataReplyLine --- .../main/java/bisq/tor/controller/TorControlProtocol.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java index a177b2ea99..224a6b9b0a 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java @@ -20,9 +20,8 @@ public class TorControlProtocol implements AutoCloseable { private final OutputStream outputStream; // MidReplyLine = StatusCode "-" ReplyLine - private final Pattern midReplyLinePattern = Pattern.compile("^\\d+-.+"); // DataReplyLine = StatusCode "+" ReplyLine CmdData - private final Pattern dataReplyLinePattern = Pattern.compile("^\\d+\\+.+"); + private final Pattern multiLineReplyPattern = Pattern.compile("^\\d+[-+].+"); public TorControlProtocol(int port) throws IOException { controlSocket = new Socket("127.0.0.1", port); @@ -148,7 +147,7 @@ private String tryReadNextReply() { } private boolean isMultilineReply(String reply) { - return midReplyLinePattern.matcher(reply).matches() || dataReplyLinePattern.matcher(reply).matches(); + return multiLineReplyPattern.matcher(reply).matches(); } private String assertTwoLineOkReply(Stream replyStream, String commandName) { From afc6e05f9b9229bac841dab322d76f99f3770928 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 7 Jun 2024 16:15:14 +0000 Subject: [PATCH 2/7] tor: Implement HsDescEventParser --- .../tor/controller/HsDescEventParser.java | 48 +++++++++++++++++++ .../events/events/HsDescCreatedEvent.java | 13 +++++ .../controller/events/events/HsDescEvent.java | 34 +++++++++++++ .../events/events/HsDescUploadEvent.java | 12 +++++ .../events/events/HsDescUploadedEventV2.java | 11 +++++ 5 files changed, 118 insertions(+) create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/HsDescEventParser.java create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescCreatedEvent.java create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescEvent.java create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadEvent.java create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadedEventV2.java diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/HsDescEventParser.java b/network/tor/tor/src/main/java/bisq/tor/controller/HsDescEventParser.java new file mode 100644 index 0000000000..d38637ccca --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/HsDescEventParser.java @@ -0,0 +1,48 @@ +package bisq.tor.controller; + +import bisq.tor.controller.events.events.HsDescCreatedEvent; +import bisq.tor.controller.events.events.HsDescEvent; +import bisq.tor.controller.events.events.HsDescUploadEvent; +import bisq.tor.controller.events.events.HsDescUploadedEventV2; + +import java.util.Optional; + +public class HsDescEventParser { + public static Optional tryParse(String[] parts) { + if (HsDescEvent.Action.CREATED.isAction(parts)) { + // 650 HS_DESC CREATED UNKNOWN UNKNOWN + HsDescCreatedEvent hsDescEvent = HsDescCreatedEvent.builder() + .action(HsDescEvent.Action.CREATED) + .hsAddress(parts[3]) + .authType(parts[4]) + .hsDir(parts[5]) + .descriptorId(parts[6]) + .build(); + return Optional.of(hsDescEvent); + + } else if (HsDescEvent.Action.UPLOAD.isAction(parts)) { + // 650 HS_DESC UPLOAD UNKNOWN HSDIR_INDEX= + HsDescUploadEvent hsDescEvent = HsDescUploadEvent.builder() + .action(HsDescEvent.Action.UPLOAD) + .hsAddress(parts[3]) + .authType(parts[4]) + .hsDir(parts[5]) + .descriptorId(parts[6]) + .hsDirIndex(parts[7]) + .build(); + return Optional.of(hsDescEvent); + + } else if (HsDescEvent.Action.UPLOADED.isAction(parts)) { + // 650 HS_DESC UPLOADED UNKNOWN + HsDescUploadedEventV2 hsDescEvent = HsDescUploadedEventV2.builder() + .action(HsDescEvent.Action.UPLOADED) + .hsAddress(parts[3]) + .authType(parts[4]) + .hsDir(parts[5]) + .build(); + return Optional.of(hsDescEvent); + } else { + return Optional.empty(); + } + } +} diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescCreatedEvent.java b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescCreatedEvent.java new file mode 100644 index 0000000000..ca1d31c63c --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescCreatedEvent.java @@ -0,0 +1,13 @@ +package bisq.tor.controller.events.events; + +import lombok.Getter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + + +@SuperBuilder +@Getter +@ToString(callSuper = true) +public class HsDescCreatedEvent extends HsDescEvent { + private final String descriptorId; +} diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescEvent.java b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescEvent.java new file mode 100644 index 0000000000..68ab216faf --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescEvent.java @@ -0,0 +1,34 @@ +package bisq.tor.controller.events.events; + +import lombok.Getter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@SuperBuilder +@Getter +@ToString +public abstract class HsDescEvent { + + @Getter + public enum Action { + CREATED(7), + UPLOAD(8), + UPLOADED(6); + + private final int numberOfArgs; + + Action(int numberOfArgs) { + this.numberOfArgs = numberOfArgs; + } + + public boolean isAction(String[] parts) { + // Example: 650 HS_DESC CREATED UNKNOWN UNKNOWN + return parts[2].equals(this.toString()) && parts.length == numberOfArgs; + } + } + + protected final Action action; + protected final String hsAddress; + protected final String authType; + protected final String hsDir; +} diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadEvent.java b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadEvent.java new file mode 100644 index 0000000000..4b3ff8abba --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadEvent.java @@ -0,0 +1,12 @@ +package bisq.tor.controller.events.events; + +import lombok.Getter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@SuperBuilder +@Getter +@ToString(callSuper = true) +public class HsDescUploadEvent extends HsDescCreatedEvent { + private final String hsDirIndex; +} diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadedEventV2.java b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadedEventV2.java new file mode 100644 index 0000000000..fcc0ea4d1c --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/events/events/HsDescUploadedEventV2.java @@ -0,0 +1,11 @@ +package bisq.tor.controller.events.events; + +import lombok.Getter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@SuperBuilder +@Getter +@ToString(callSuper = true) +public class HsDescUploadedEventV2 extends HsDescEvent { +} From 4250b7624063751ad26cdb7e2d4a8d341ac167e6 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 7 Jun 2024 16:16:17 +0000 Subject: [PATCH 3/7] tor: Implement HsDescEventListener --- .../tor/controller/BootstrapEventParser.java | 17 ++----- .../tor/controller/TorControlProtocol.java | 9 ++++ .../controller/WhonixTorControlReader.java | 51 +++++++++++++++++-- .../events/listener/HsDescEventListener.java | 7 +++ 4 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 network/tor/tor/src/main/java/bisq/tor/controller/events/listener/HsDescEventListener.java diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/BootstrapEventParser.java b/network/tor/tor/src/main/java/bisq/tor/controller/BootstrapEventParser.java index 10fa81402c..3f5df74936 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/BootstrapEventParser.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/BootstrapEventParser.java @@ -5,25 +5,16 @@ import java.util.Optional; public class BootstrapEventParser { - public static Optional tryParse(String line) { + public static Optional tryParse(String[] parts) { // 650 STATUS_CLIENT NOTICE BOOTSTRAP PROGRESS=50 TAG=loading_descriptors SUMMARY="Loading relay descriptors" - if (isStatusClientEvent(line)) { - String[] parts = line.split(" "); - - if (isBootstrapEvent(parts)) { - BootstrapEvent bootstrapEvent = parseBootstrapEvent(parts); - return Optional.of(bootstrapEvent); - } + if (isBootstrapEvent(parts)) { + BootstrapEvent bootstrapEvent = parseBootstrapEvent(parts); + return Optional.of(bootstrapEvent); } return Optional.empty(); } - private static boolean isStatusClientEvent(String line) { - // 650 STATUS_CLIENT NOTICE CIRCUIT_ESTABLISHED - return line.startsWith("650 STATUS_CLIENT"); - } - private static boolean isBootstrapEvent(String[] parts) { // 650 STATUS_CLIENT NOTICE BOOTSTRAP PROGRESS=50 TAG=loading_descriptors SUMMARY="Loading relay descriptors" return parts.length >= 7 && parts[3].equals("BOOTSTRAP"); diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java index 224a6b9b0a..1c18e6efba 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java @@ -3,6 +3,7 @@ import bisq.common.encoding.Hex; import bisq.security.keys.TorKeyPair; import bisq.tor.controller.events.listener.BootstrapEventListener; +import bisq.tor.controller.events.listener.HsDescEventListener; import net.freehaven.tor.control.PasswordDigest; import java.io.IOException; @@ -119,6 +120,14 @@ public void removeBootstrapEventListener(BootstrapEventListener listener) { whonixTorControlReader.removeBootstrapEventListener(listener); } + public void addHsDescEventListener(HsDescEventListener listener) { + whonixTorControlReader.addHsDescEventListener(listener); + } + + public void removeHsDescEventListener(HsDescEventListener listener) { + whonixTorControlReader.removeHsDescEventListener(listener); + } + private void sendCommand(String command) throws IOException { byte[] commandBytes = command.getBytes(StandardCharsets.US_ASCII); outputStream.write(commandBytes); diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/WhonixTorControlReader.java b/network/tor/tor/src/main/java/bisq/tor/controller/WhonixTorControlReader.java index 76da07a56a..8899ff6747 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/WhonixTorControlReader.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/WhonixTorControlReader.java @@ -1,7 +1,9 @@ package bisq.tor.controller; import bisq.tor.controller.events.events.BootstrapEvent; +import bisq.tor.controller.events.events.HsDescEvent; import bisq.tor.controller.events.listener.BootstrapEventListener; +import bisq.tor.controller.events.listener.HsDescEventListener; import lombok.extern.slf4j.Slf4j; import java.io.BufferedReader; @@ -20,6 +22,7 @@ public class WhonixTorControlReader implements AutoCloseable { private final BufferedReader bufferedReader; private final BlockingQueue replies = new LinkedBlockingQueue<>(); private final List bootstrapEventListeners = new CopyOnWriteArrayList<>(); + private final List hsDescEventListeners = new CopyOnWriteArrayList<>(); private Optional workerThread = Optional.empty(); @@ -34,11 +37,31 @@ public void start() { while ((line = bufferedReader.readLine()) != null) { if (isEvent(line)) { - Optional bootstrapEventOptional = BootstrapEventParser.tryParse(line); - if (bootstrapEventOptional.isPresent()) { - BootstrapEvent bootstrapEvent = bootstrapEventOptional.get(); - bootstrapEventListeners.forEach(listener -> listener.onBootstrapStatusEvent(bootstrapEvent)); - } else { + String[] parts = line.split(" "); + + boolean parsedEvent = false; + if (parts.length > 2) { + String eventType = parts[1]; + + if (isStatusClientEvent(eventType)) { + Optional bootstrapEventOptional = BootstrapEventParser.tryParse(parts); + if (bootstrapEventOptional.isPresent()) { + parsedEvent = true; + BootstrapEvent bootstrapEvent = bootstrapEventOptional.get(); + bootstrapEventListeners.forEach(listener -> listener.onBootstrapStatusEvent(bootstrapEvent)); + } + + } else if (isHsDescEvent(eventType)) { + Optional hsDescEventOptional = HsDescEventParser.tryParse(parts); + if (hsDescEventOptional.isPresent()) { + parsedEvent = true; + HsDescEvent hsDescEvent = hsDescEventOptional.get(); + hsDescEventListeners.forEach(listener -> listener.onHsDescEvent(hsDescEvent)); + } + } + } + + if (!parsedEvent) { log.info("Unknown Tor event: {}", line); } @@ -80,8 +103,26 @@ public void removeBootstrapEventListener(BootstrapEventListener listener) { bootstrapEventListeners.remove(listener); } + public void addHsDescEventListener(HsDescEventListener listener) { + hsDescEventListeners.add(listener); + } + + public void removeHsDescEventListener(HsDescEventListener listener) { + hsDescEventListeners.remove(listener); + } + private boolean isEvent(String line) { // 650 STATUS_CLIENT NOTICE CIRCUIT_ESTABLISHED return line.startsWith("650"); } + + private static boolean isStatusClientEvent(String eventType) { + // 650 STATUS_CLIENT NOTICE CIRCUIT_ESTABLISHED + return eventType.equals("STATUS_CLIENT"); + } + + private static boolean isHsDescEvent(String eventType) { + // 650 HS_DESC CREATED UNKNOWN UNKNOWN + return eventType.equals("HS_DESC"); + } } diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/events/listener/HsDescEventListener.java b/network/tor/tor/src/main/java/bisq/tor/controller/events/listener/HsDescEventListener.java new file mode 100644 index 0000000000..5ed9ef83b9 --- /dev/null +++ b/network/tor/tor/src/main/java/bisq/tor/controller/events/listener/HsDescEventListener.java @@ -0,0 +1,7 @@ +package bisq.tor.controller.events.listener; + +import bisq.tor.controller.events.events.HsDescEvent; + +public interface HsDescEventListener { + void onHsDescEvent(HsDescEvent hsDescEvent); +} From f8835659b7c8eae268f75a4eba1d5af79e2296dc Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 7 Jun 2024 16:17:07 +0000 Subject: [PATCH 4/7] TorController: Add duration comment to bootstrapTimeout --- .../tor/src/main/java/bisq/tor/controller/TorController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index dc53bfca0c..e7b845a989 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -21,7 +21,7 @@ @Slf4j public class TorController implements BootstrapEventListener { - private final int bootstrapTimeout; + private final int bootstrapTimeout; // in ms private final CountDownLatch isBootstrappedCountdownLatch = new CountDownLatch(1); @Getter private final Observable bootstrapEvent = new Observable<>(); From f9e9b21ff9a6c0844a78f9f6584c45930d48a3cb Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 7 Jun 2024 16:18:05 +0000 Subject: [PATCH 5/7] TorController: Support onion service creation --- .../bisq/tor/controller/TorController.java | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index e7b845a989..31a625d772 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -1,9 +1,13 @@ package bisq.tor.controller; import bisq.common.observable.Observable; +import bisq.security.keys.TorKeyPair; import bisq.tor.TorrcClientConfigFactory; import bisq.tor.controller.events.events.BootstrapEvent; +import bisq.tor.controller.events.events.HsDescEvent; import bisq.tor.controller.events.listener.BootstrapEventListener; +import bisq.tor.controller.events.listener.HsDescEventListener; +import bisq.tor.controller.exceptions.HsDescUploadFailedException; import bisq.tor.controller.exceptions.TorBootstrapFailedException; import bisq.tor.process.NativeTorProcess; import lombok.Getter; @@ -15,21 +19,27 @@ import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @Slf4j -public class TorController implements BootstrapEventListener { +public class TorController implements BootstrapEventListener, HsDescEventListener { private final int bootstrapTimeout; // in ms + private final int hsUploadTimeout; // in ms private final CountDownLatch isBootstrappedCountdownLatch = new CountDownLatch(1); @Getter private final Observable bootstrapEvent = new Observable<>(); + private final Map onionServicePublishedLatchMap = new ConcurrentHashMap<>(); + private Optional torControlProtocol = Optional.empty(); - public TorController(int bootstrapTimeout) { + public TorController(int bootstrapTimeout, int hsUploadTimeout) { this.bootstrapTimeout = bootstrapTimeout; + this.hsUploadTimeout = hsUploadTimeout; } public void initialize(int controlPort) throws IOException { @@ -57,6 +67,24 @@ public void bootstrapTor() throws IOException { waitUntilBootstrapped(); } + public void publish(TorKeyPair torKeyPair, int onionServicePort, int localPort) throws IOException, InterruptedException { + String onionAddress = torKeyPair.getOnionAddress(); + var onionServicePublishedLatch = new CountDownLatch(1); + onionServicePublishedLatchMap.put(onionAddress, onionServicePublishedLatch); + + subscribeToHsDescEvents(); + TorControlProtocol torControlProtocol = getTorControlProtocol(); + torControlProtocol.addOnion(torKeyPair, onionServicePort, localPort); + + boolean isSuccess = onionServicePublishedLatch.await(hsUploadTimeout, TimeUnit.MILLISECONDS); + if (!isSuccess) { + throw new HsDescUploadFailedException("HS_DESC upload timer triggered."); + } + + torControlProtocol.removeHsDescEventListener(this); + torControlProtocol.setEvents(Collections.emptyList()); + } + public Optional getSocksPort() { try { TorControlProtocol torControlProtocol = getTorControlProtocol(); @@ -90,6 +118,16 @@ public void onBootstrapStatusEvent(BootstrapEvent bootstrapEvent) { } } + @Override + public void onHsDescEvent(HsDescEvent hsDescEvent) { + log.info("Tor HS_DESC event: {}", hsDescEvent); + if (hsDescEvent.getAction() == HsDescEvent.Action.UPLOADED) { + String onionAddress = hsDescEvent.getHsAddress() + ".onion"; + CountDownLatch countDownLatch = onionServicePublishedLatchMap.get(onionAddress); + countDownLatch.countDown(); + } + } + private void initialize(int controlPort, Optional hashedControlPassword) throws IOException { var torControlProtocol = new TorControlProtocol(controlPort); this.torControlProtocol = Optional.of(torControlProtocol); @@ -112,6 +150,12 @@ private void subscribeToBootstrapEvents() throws IOException { torControlProtocol.setEvents(List.of("STATUS_CLIENT")); } + private void subscribeToHsDescEvents() throws IOException { + TorControlProtocol torControlProtocol = getTorControlProtocol(); + torControlProtocol.addHsDescEventListener(this); + torControlProtocol.setEvents(List.of("HS_DESC")); + } + private void enableNetworking() throws IOException { TorControlProtocol torControlProtocol = getTorControlProtocol(); torControlProtocol.setConfig(TorrcClientConfigFactory.DISABLE_NETWORK_CONFIG_KEY, "0"); From c362f47a21948bad145b25829946e9057642b562 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sat, 8 Jun 2024 16:34:09 +0000 Subject: [PATCH 6/7] TorController: Rename onionServicePublishedLatchMap to pendingOnionServicePublishLatchMap --- .../main/java/bisq/tor/controller/TorController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index 31a625d772..fae516887c 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -33,7 +33,7 @@ public class TorController implements BootstrapEventListener, HsDescEventListene @Getter private final Observable bootstrapEvent = new Observable<>(); - private final Map onionServicePublishedLatchMap = new ConcurrentHashMap<>(); + private final Map pendingOnionServicePublishLatchMap = new ConcurrentHashMap<>(); private Optional torControlProtocol = Optional.empty(); @@ -70,7 +70,7 @@ public void bootstrapTor() throws IOException { public void publish(TorKeyPair torKeyPair, int onionServicePort, int localPort) throws IOException, InterruptedException { String onionAddress = torKeyPair.getOnionAddress(); var onionServicePublishedLatch = new CountDownLatch(1); - onionServicePublishedLatchMap.put(onionAddress, onionServicePublishedLatch); + pendingOnionServicePublishLatchMap.put(onionAddress, onionServicePublishedLatch); subscribeToHsDescEvents(); TorControlProtocol torControlProtocol = getTorControlProtocol(); @@ -123,8 +123,11 @@ public void onHsDescEvent(HsDescEvent hsDescEvent) { log.info("Tor HS_DESC event: {}", hsDescEvent); if (hsDescEvent.getAction() == HsDescEvent.Action.UPLOADED) { String onionAddress = hsDescEvent.getHsAddress() + ".onion"; - CountDownLatch countDownLatch = onionServicePublishedLatchMap.get(onionAddress); - countDownLatch.countDown(); + CountDownLatch countDownLatch = pendingOnionServicePublishLatchMap.get(onionAddress); + if (countDownLatch != null) { + countDownLatch.countDown(); + pendingOnionServicePublishLatchMap.remove(onionAddress); + } } } From c59720544de9024fd0ebd90f627d87dbe19efec0 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sat, 8 Jun 2024 16:35:25 +0000 Subject: [PATCH 7/7] TorControlProtocol: Implement HSFETCH --- .../java/bisq/tor/controller/TorControlProtocol.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java index 1c18e6efba..5b33d0011c 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorControlProtocol.java @@ -72,6 +72,15 @@ public String getInfo(String keyword) throws IOException { return assertTwoLineOkReply(replyStream, "GETINFO"); } + public void hsFetch(String hsAddress) throws IOException { + String command = "HSFETCH " + hsAddress + "\r\n"; + sendCommand(command); + String reply = receiveReply().findFirst().orElseThrow(); + if (!reply.equals("250 OK")) { + throw new ControlCommandFailedException("Couldn't initiate HSFETCH for : " + hsAddress); + } + } + public void resetConf(String configName) throws IOException { String command = "RESETCONF " + configName + "\r\n"; sendCommand(command);