Skip to content

Commit

Permalink
TorControlProtocol: Merge MidReplyLine and DataReplyLine
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Jun 7, 2024
1 parent b3996ae commit f991931
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<String> replyStream, String commandName) {
Expand Down

0 comments on commit f991931

Please sign in to comment.