Skip to content

Commit

Permalink
Merge pull request #2254 from alvasw/tor_controller_support_non_authe…
Browse files Browse the repository at this point in the history
…nticated_connections

TorController: Support non-authenticated connections
  • Loading branch information
djing-chan authored Jun 4, 2024
2 parents 6306941 + 0a0c02e commit 1873ee2
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public TorController(int bootstrapTimeout) {
this.bootstrapTimeout = bootstrapTimeout;
}

public void initialize(int controlPort, PasswordDigest hashedControlPassword) throws IOException {
var torControlProtocol = new TorControlProtocol(controlPort);
this.torControlProtocol = Optional.of(torControlProtocol);
public void initialize(int controlPort) throws IOException {
initialize(controlPort, Optional.empty());
}

torControlProtocol.initialize();
torControlProtocol.authenticate(hashedControlPassword);
public void initialize(int controlPort, PasswordDigest hashedControlPassword) throws IOException {
initialize(controlPort, Optional.of(hashedControlPassword));
}

public void shutdown() {
Expand Down Expand Up @@ -90,6 +90,16 @@ public void onBootstrapStatusEvent(BootstrapEvent bootstrapEvent) {
}
}

private void initialize(int controlPort, Optional<PasswordDigest> hashedControlPassword) throws IOException {
var torControlProtocol = new TorControlProtocol(controlPort);
this.torControlProtocol = Optional.of(torControlProtocol);

torControlProtocol.initialize();
if (hashedControlPassword.isPresent()) {
torControlProtocol.authenticate(hashedControlPassword.get());
}
}

private void bindToBisq() throws IOException {
TorControlProtocol torControlProtocol = getTorControlProtocol();
torControlProtocol.takeOwnership();
Expand Down

0 comments on commit 1873ee2

Please sign in to comment.