Skip to content

Commit

Permalink
TorrcFileGenerator: Add customDirectoryAuthorities support
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Aug 20, 2023
1 parent 37f22f5 commit d64fa82
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion network/tor/tor/src/main/java/bisq/tor/TorrcFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Set;

public class TorrcFileGenerator {
private final Path torrcPath;
private final Map<String, String> torrcConfigMap;
private final Set<DirectoryAuthority> customDirectoryAuthorities;

public TorrcFileGenerator(Path torrcPath, Map<String, String> torrcConfigMap) {
public TorrcFileGenerator(Path torrcPath,
Map<String, String> torrcConfigMap,
Set<DirectoryAuthority> customDirectoryAuthorities) {
this.torrcPath = torrcPath;
this.torrcConfigMap = torrcConfigMap;
this.customDirectoryAuthorities = customDirectoryAuthorities;
}

public void generate() {
Expand All @@ -40,6 +45,14 @@ public void generate() {
.append("\n")
);

customDirectoryAuthorities.forEach(dirAuthority ->
torrcStringBuilder.append("DirAuthority ").append(dirAuthority.getNickname())
.append(" orport=").append(dirAuthority.getOrPort())
.append(" v3ident=").append(dirAuthority.getV3Ident())
.append(" 127.0.0.1:").append(dirAuthority.getDirPort())
.append(" ").append(dirAuthority.getRelayFingerprint())
.append("\n"));

try {
Files.writeString(torrcPath, torrcStringBuilder.toString());
} catch (IOException e) {
Expand Down

0 comments on commit d64fa82

Please sign in to comment.