Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tor: Add client support #980

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public class TorNode {

public enum Type {
CLIENT,
DIRECTORY_AUTHORITY,
RELAY
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package bisq.tor.local_network.torrc;

import bisq.common.util.NetworkUtils;
import bisq.tor.local_network.TorNode;

public class ClientTorrcGenerator extends CommonTorrcGenerator{
public ClientTorrcGenerator(TorNode thisTorNode) {
super(thisTorNode);
}

@Override
public void generate() {
super.generate();
torrcStringBuilder.append("SocksPort ").append(NetworkUtils.findFreeSystemPort()).append("\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ public void generate() {
.append("Log debug file ").append(thisTorNode.getDataDir().resolve("debug.log").toAbsolutePath()).append("\n")
.append("ProtocolWarnings 1\n")
.append("SafeLogging 0\n")
.append("LogTimeGranularity 1\n")
.append("LogTimeGranularity 1\n");

.append("SocksPort 0\n")
if (thisTorNode.getType() != TorNode.Type.CLIENT) {
torrcStringBuilder.append("SocksPort 0\n");
}

torrcStringBuilder
.append("OrPort ").append(thisTorNode.getOrPort()).append("\n")
.append("Address 127.0.0.1\n")

Expand Down