From e0e50fa159649db9f02552d537b281bdbe503804 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sun, 20 Aug 2023 12:52:01 +0200 Subject: [PATCH] Remove TorrcConfigInstaller --- .../src/main/java/bisq/tor/TorBootstrap.java | 2 - .../tor/installer/TorrcConfigInstaller.java | 79 ------------------- 2 files changed, 81 deletions(-) delete mode 100644 network/tor/tor/src/main/java/bisq/tor/installer/TorrcConfigInstaller.java diff --git a/network/tor/tor/src/main/java/bisq/tor/TorBootstrap.java b/network/tor/tor/src/main/java/bisq/tor/TorBootstrap.java index 580f4a88d8..13cd0a9a7b 100644 --- a/network/tor/tor/src/main/java/bisq/tor/TorBootstrap.java +++ b/network/tor/tor/src/main/java/bisq/tor/TorBootstrap.java @@ -19,7 +19,6 @@ import bisq.tor.installer.TorInstallationFiles; import bisq.tor.installer.TorInstaller; -import bisq.tor.installer.TorrcConfigInstaller; import bisq.tor.process.TorProcessBuilder; import bisq.tor.process.TorProcessConfig; import lombok.extern.slf4j.Slf4j; @@ -41,7 +40,6 @@ class TorBootstrap { OsType osType = OsType.getOsType(); this.torInstallationFiles = new TorInstallationFiles(torDirPath, osType); - TorrcConfigInstaller torrcConfigInstaller = new TorrcConfigInstaller(torInstallationFiles); this.torInstaller = new TorInstaller(torInstallationFiles); this.osType = osType; diff --git a/network/tor/tor/src/main/java/bisq/tor/installer/TorrcConfigInstaller.java b/network/tor/tor/src/main/java/bisq/tor/installer/TorrcConfigInstaller.java deleted file mode 100644 index de8d17cd75..0000000000 --- a/network/tor/tor/src/main/java/bisq/tor/installer/TorrcConfigInstaller.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.tor.installer; - -import bisq.common.util.FileUtils; -import bisq.tor.Constants; -import bisq.tor.OsType; -import lombok.extern.slf4j.Slf4j; - -import java.io.*; -import java.util.List; - -@Slf4j -public class TorrcConfigInstaller { - private final TorInstallationFiles torInstallationFiles; - private final File torrcFile; - private final OsType osType; - - public TorrcConfigInstaller(TorInstallationFiles torInstallationFiles) { - this.torInstallationFiles = torInstallationFiles; - this.torrcFile = torInstallationFiles.getTorrcFile(); - this.osType = OsType.getOsType(); - } - - public void install() throws IOException { - FileUtils.resourceToFile(torrcFile); - extendTorrcFile(); - } - - public void addBridgesToTorrcFile(List bridgeConfig) throws IOException { - // We overwrite old file as it might contain diff. bridges - install(); - - try (FileWriter fileWriter = new FileWriter(torrcFile, true); - BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); - PrintWriter printWriter = new PrintWriter(bufferedWriter)) { - if (!bridgeConfig.isEmpty()) { - printWriter.println(""); - printWriter.println("UseBridges 1"); - } - bridgeConfig.forEach(entry -> printWriter.println("Bridge " + entry)); - } - log.info("Added bridges to torrc"); - } - - private void extendTorrcFile() throws IOException { - try (FileWriter fileWriter = new FileWriter(torrcFile, true); - BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); - PrintWriter printWriter = new PrintWriter(bufferedWriter)) { - - // Defaults are from resources - printWriter.println(""); - FileUtils.appendFromResource(printWriter, FileUtils.FILE_SEP + Constants.TORRC_DEFAULTS); - printWriter.println(""); - FileUtils.appendFromResource(printWriter, osType.getTorrcNative()); - - // Update with our newly created files - printWriter.println(""); - printWriter.println(Constants.TORRC_KEY_DATA_DIRECTORY + " " + - torInstallationFiles.getTorDir().getCanonicalPath()); - printWriter.println(""); - } - } -}