Skip to content

Commit

Permalink
WhonixTorController: Implement SETEVENTS command
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed May 22, 2024
1 parent 75cdfa3 commit 93f7484
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.*;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class WhonixTorController implements AutoCloseable {
private final Socket controlSocket;
Expand Down Expand Up @@ -61,6 +62,19 @@ public void resetConf(String configName) throws IOException {
}
}

public void setEvents(List<String> events) throws IOException {
var stringBuilder = new StringBuffer("SETEVENTS");
events.forEach(event -> stringBuilder.append(" ").append(event));
stringBuilder.append("\r\n");

String command = stringBuilder.toString();
sendCommand(command);
String reply = receiveReply();
if (!reply.equals("250 OK")) {
throw new ControlCommandFailedException("Couldn't set events: " + events);
}
}

public void takeOwnership() throws IOException {
String command = "TAKEOWNERSHIP\r\n";
sendCommand(command);
Expand Down

0 comments on commit 93f7484

Please sign in to comment.