Skip to content

Commit

Permalink
WhonixTorController: Implement TAKEOWNERSHIP command
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed May 29, 2024
1 parent 2807fcb commit 24928bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
package bisq.tor.controller;

public class ControlCommandFailedException extends RuntimeException {
public ControlCommandFailedException(String message) {
super(message);
}

public ControlCommandFailedException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public void addOnion(TorKeyPair torKeyPair, int onionPort, int localPort) throws
String reply = receiveReply();
}

public void takeOwnership() throws IOException {
String command = "TAKEOWNERSHIP\r\n";
sendCommand(command);
String reply = receiveReply();
if (!reply.equals("250 OK")) {
throw new ControlCommandFailedException("Couldn't take ownership");
}
}

private void sendCommand(String command) throws IOException {
byte[] commandBytes = command.getBytes(StandardCharsets.US_ASCII);
outputStream.write(commandBytes);
Expand Down

0 comments on commit 24928bc

Please sign in to comment.