Skip to content

Commit

Permalink
Update tor binary to 0.4.7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
napoly committed Mar 10, 2024
1 parent 82b6bcf commit f022dc6
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ configure(subprojects) {
loggingVersion = '1.2'
lombokVersion = '1.18.30'
mockitoVersion = '5.10.0'
netlayerVersion = '6797461310f077bbea4f43a3a509c077b0ed8c34' // Netlayer version 0.7.3 with Tor browser version 11.0.14 and tor binary version: 0.4.7.7
netlayerVersion = '2b459dc' // Tor browser version 11.5.2 and tor binary version: 0.4.7.10
protobufVersion = '3.19.1'
protocVersion = protobufVersion
pushyVersion = '0.13.2'
Expand Down
8 changes: 8 additions & 0 deletions common/src/main/java/haveno/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Config {
public static final String USE_TOR_FOR_XMR = "useTorForXmr";
public static final String TORRC_FILE = "torrcFile";
public static final String TORRC_OPTIONS = "torrcOptions";
public static final String TOR_CONTROL_HOST = "torControlHost";
public static final String TOR_CONTROL_PORT = "torControlPort";
public static final String TOR_CONTROL_PASSWORD = "torControlPassword";
public static final String TOR_CONTROL_COOKIE_FILE = "torControlCookieFile";
Expand Down Expand Up @@ -173,6 +174,7 @@ public enum UseTorForXmr {
public final String socks5ProxyHttpAddress;
public final File torrcFile;
public final String torrcOptions;
public final String torControlHost;
public final int torControlPort;
public final String torControlPassword;
public final File torControlCookieFile;
Expand Down Expand Up @@ -446,6 +448,11 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
.withValuesConvertedBy(RegexMatcher.regex("^([^\\s,]+\\s[^,]+,?\\s*)+$"))
.defaultsTo("");

ArgumentAcceptingOptionSpec<String> torControlHostOpt =
parser.accepts(TOR_CONTROL_HOST, "The control hostname of an already running Tor service to be used by Bisq.")
.withRequiredArg()
.defaultsTo("127.0.0.1");

ArgumentAcceptingOptionSpec<Integer> torControlPortOpt =
parser.accepts(TOR_CONTROL_PORT,
"The control port of an already running Tor service to be used by Haveno.")
Expand Down Expand Up @@ -667,6 +674,7 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
this.bitcoinRegtestHost = options.valueOf(bitcoinRegtestHostOpt);
this.torrcFile = options.has(torrcFileOpt) ? options.valueOf(torrcFileOpt).toFile() : null;
this.torrcOptions = options.valueOf(torrcOptionsOpt);
this.torControlHost = options.valueOf(torControlHostOpt);
this.torControlPort = options.valueOf(torControlPortOpt);
this.torControlPassword = options.valueOf(torControlPasswordOpt);
this.torControlCookieFile = options.has(torControlCookieFileOpt) ?
Expand Down
40 changes: 40 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@
<sha256 value="6306d89cfdb12bd0b6436390de71cef31879985da10d071a3bdad56bf287bbbb" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor" version="2b459dc">
<artifact name="tor-2b459dc.jar">
<sha256 value="d8aba69568795826bd1139b6854b479d9af9fc945eccf2b15d7f9ecb304c5cc4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor" version="6797461310f077bbea4f43a3a509c077b0ed8c34">
<artifact name="tor-6797461310f077bbea4f43a3a509c077b0ed8c34.jar">
<sha256 value="1536211d3f204059e2ad49c136978b36ebaa19e62103fcd46dcb926842fa0718" origin="Generated by Gradle"/>
Expand All @@ -260,6 +265,11 @@
<sha256 value="605e15f473aa7163c4dfa75b0fa17a96466d24c6e3d7a66925b29aadde98dfb4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor.external" version="2b459dc">
<artifact name="tor.external-2b459dc.jar">
<sha256 value="6646b6ce9312a16f6b4b61ee91512b8725b55a2f7204aec29f64974207fd5015" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor.external" version="6797461310f077bbea4f43a3a509c077b0ed8c34">
<artifact name="tor.external-6797461310f077bbea4f43a3a509c077b0ed8c34.jar">
<sha256 value="d79dee1380fcc912dd9f321e6689b99129a90c6b30085b3f86a0b81830ecee71" origin="Generated by Gradle"/>
Expand All @@ -284,6 +294,11 @@
<sha256 value="021ab6d438023653afee96c0fab1262eed6b7522fce76e114593d55e6d7d9928" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor.native" version="2b459dc">
<artifact name="tor.native-2b459dc.jar">
<sha256 value="dc5850e232f2c579d948213a3ea1ce536f56bcc49045a43d3bc63f1e065f1c94" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.netlayer" name="tor.native" version="6797461310f077bbea4f43a3a509c077b0ed8c34">
<artifact name="tor.native-6797461310f077bbea4f43a3a509c077b0ed8c34.jar">
<sha256 value="7ab70a9948fffea33da9fee161c5783a74aeb1531e3fda09995c47bb5e2de0f5" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -315,6 +330,11 @@
<sha256 value="f1ef0c2b2a1df585f057b96b62b05e2e7d7953353b64e29ac798810ff2919b42" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-geoip" version="580d31bdcf1fabccd38456aa084044064d89d5c1">
<artifact name="tor-binary-geoip-580d31bdcf1fabccd38456aa084044064d89d5c1.jar">
<sha256 value="5a1795e95128e8c6fb3381d1c31ac39f2ec4e4fc3a0262f3f9ac3c7987e0c87e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-geoip" version="6d1fd95">
<artifact name="tor-binary-geoip-6d1fd95.jar">
<sha256 value="5a55df3a5bed0aa57165e9bae9ecda8b14d5e85b97dd1a266fa77602fbdaec54" origin="Generated by Gradle"/>
Expand All @@ -339,6 +359,11 @@
<sha256 value="197d034216b332fcfaa7111442ac4a23bddc60fb71fefba1c736fe9844c1001b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-linux32" version="580d31bdcf1fabccd38456aa084044064d89d5c1">
<artifact name="tor-binary-linux32-580d31bdcf1fabccd38456aa084044064d89d5c1.jar">
<sha256 value="2516ce5549ef5687ef7f855db5940574fc9232ff3ba531fbc216275b8d51ae85" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-linux32" version="6d1fd95">
<artifact name="tor-binary-linux32-6d1fd95.jar">
<sha256 value="fe8b0ddb1c109b453adf9b055e067be04b6ca4cda9d2b33c875b99d2092f0eae" origin="Generated by Gradle"/>
Expand All @@ -363,6 +388,11 @@
<sha256 value="a01902c476556a0529413b0f3810e954a5eb8a7cdc1a9cc604ec2d24ceca91ce" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-linux64" version="580d31bdcf1fabccd38456aa084044064d89d5c1">
<artifact name="tor-binary-linux64-580d31bdcf1fabccd38456aa084044064d89d5c1.jar">
<sha256 value="afc7ad5e1bc57e73aae55d9b022ff63f41f7c73a9a7603d4c24975288432daa1" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-linux64" version="6d1fd95">
<artifact name="tor-binary-linux64-6d1fd95.jar">
<sha256 value="7f58d31dd684b2e361e2980ba23922cadd5d9d8f8dbab9b3a2c6737741b21f7e" origin="Generated by Gradle"/>
Expand All @@ -387,6 +417,11 @@
<sha256 value="ee305ee12585057bcce380710e4a5ae3a3ed43e1701f5e565f15b75854e3e715" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-macos" version="580d31bdcf1fabccd38456aa084044064d89d5c1">
<artifact name="tor-binary-macos-580d31bdcf1fabccd38456aa084044064d89d5c1.jar">
<sha256 value="5bfb2eaf7efe5d280d6b68e222c910cc6ae2a925e3d06fa35c6b5295ebf94651" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-macos" version="6d1fd95">
<artifact name="tor-binary-macos-6d1fd95.jar">
<sha256 value="a23802ff66d4ac01366ebe712879e2f51df960572dc34db269588da87453a70d" origin="Generated by Gradle"/>
Expand All @@ -411,6 +446,11 @@
<sha256 value="143a9bfc539101d8293b7d151d6a952135fa5ad76d752639d2ed72fb9c9c494d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-windows" version="580d31bdcf1fabccd38456aa084044064d89d5c1">
<artifact name="tor-binary-windows-580d31bdcf1fabccd38456aa084044064d89d5c1.jar">
<sha256 value="b5fbe9f9e2681b0cfdd0d8a26c7b216c38acfea74fe2103633fe7e81b6cc4bf7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.bisq-network.tor-binary" name="tor-binary-windows" version="6d1fd95">
<artifact name="tor-binary-windows-6d1fd95.jar">
<sha256 value="8e0dee7429228aa0c9f7a36f40f303a016ed8dfb40fea77382f7076c13fc27f1" origin="Generated by Gradle"/>
Expand Down
7 changes: 5 additions & 2 deletions p2p/src/main/java/haveno/network/p2p/NetworkNodeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public NetworkNodeProvider(NetworkProtoResolver networkProtoResolver,
@Named(Config.TOR_DIR) File torDir,
@Nullable @Named(Config.TORRC_FILE) File torrcFile,
@Named(Config.TORRC_OPTIONS) String torrcOptions,
@Named(Config.TOR_CONTROL_HOST) String controlHost,
@Named(Config.TOR_CONTROL_PORT) int controlPort,
@Named(Config.TOR_CONTROL_PASSWORD) String password,
@Nullable @Named(Config.TOR_CONTROL_COOKIE_FILE) File cookieFile,
Expand All @@ -59,24 +60,26 @@ public NetworkNodeProvider(NetworkProtoResolver networkProtoResolver,
torDir,
torrcFile,
torrcOptions,
controlHost,
controlPort,
password,
cookieFile,
useSafeCookieAuthentication);
networkNode = new TorNetworkNode(port, networkProtoResolver, streamIsolation, torMode, banFilter, maxConnections);
networkNode = new TorNetworkNode(port, networkProtoResolver, streamIsolation, torMode, banFilter, maxConnections, controlHost);
}
}

private TorMode getTorMode(BridgeAddressProvider bridgeAddressProvider,
File torDir,
@Nullable File torrcFile,
String torrcOptions,
String controlHost,
int controlPort,
String password,
@Nullable File cookieFile,
boolean useSafeCookieAuthentication) {
return controlPort != Config.UNSPECIFIED_PORT ?
new RunningTor(torDir, controlPort, password, cookieFile, useSafeCookieAuthentication) :
new RunningTor(torDir, controlHost, controlPort, password, cookieFile, useSafeCookieAuthentication) :
new NewTor(torDir, torrcFile, torrcOptions, bridgeAddressProvider);
}

Expand Down
2 changes: 2 additions & 0 deletions p2p/src/main/java/haveno/network/p2p/P2PModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.inject.TypeLiteral;
import haveno.common.app.AppModule;
import haveno.common.config.Config;
import static haveno.common.config.Config.TOR_CONTROL_HOST;
import haveno.network.Socks5ProxyProvider;
import haveno.network.http.HttpClient;
import haveno.network.http.HttpClientImpl;
Expand Down Expand Up @@ -96,6 +97,7 @@ protected void configure() {
bindConstant().annotatedWith(named(SOCKS_5_PROXY_HTTP_ADDRESS)).to(config.socks5ProxyHttpAddress);
bind(File.class).annotatedWith(named(TORRC_FILE)).toProvider(of(config.torrcFile)); // allow null value
bindConstant().annotatedWith(named(TORRC_OPTIONS)).to(config.torrcOptions);
bindConstant().annotatedWith(named(TOR_CONTROL_HOST)).to(config.torControlHost);
bindConstant().annotatedWith(named(TOR_CONTROL_PORT)).to(config.torControlPort);
bindConstant().annotatedWith(named(TOR_CONTROL_PASSWORD)).to(config.torControlPassword);
bind(File.class).annotatedWith(named(TOR_CONTROL_COOKIE_FILE)).toProvider(of(config.torControlCookieFile));
Expand Down
18 changes: 12 additions & 6 deletions p2p/src/main/java/haveno/network/p2p/network/RunningTor.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,40 @@
@Slf4j
public class RunningTor extends TorMode {

private final String controlHost;
private final int controlPort;
private final String password;
private final File cookieFile;
private final boolean useSafeCookieAuthentication;


public RunningTor(final File torDir, final int controlPort, final String password, final File cookieFile,
final boolean useSafeCookieAuthentication) {
public RunningTor(final File torDir,
final String controlHost,
final int controlPort,
final String password,
final File cookieFile,
final boolean useSafeCookieAuthentication) {
super(torDir);
this.controlHost = controlHost;
this.controlPort = controlPort;
this.password = password;
this.cookieFile = cookieFile;
this.useSafeCookieAuthentication = useSafeCookieAuthentication;
}

@Override
public Tor getTor() throws IOException, TorCtlException {
public Tor getTor() throws TorCtlException {
long ts1 = new Date().getTime();

log.info("Connecting to running tor");

Tor result;
if (!password.isEmpty())
result = new ExternalTor(controlPort, password);
result = new ExternalTor(controlHost, controlPort, password);
else if (cookieFile != null && cookieFile.exists())
result = new ExternalTor(controlPort, cookieFile, useSafeCookieAuthentication);
result = new ExternalTor(controlHost, controlPort, cookieFile, useSafeCookieAuthentication);
else
result = new ExternalTor(controlPort);
result = new ExternalTor(controlHost, controlPort);

log.info(
"\n################################################################\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
public class TorNetworkNode extends NetworkNode {
private static final long SHUT_DOWN_TIMEOUT = 2;

private final String torControlHost;

private HiddenServiceSocket hiddenServiceSocket;
private Timer shutDownTimeoutTimer;
private Tor tor;
Expand All @@ -70,10 +72,11 @@ public TorNetworkNode(int servicePort,
boolean useStreamIsolation,
TorMode torMode,
@Nullable BanFilter banFilter,
int maxConnections) {
int maxConnections, String torControlHost) {
super(servicePort, networkProtoResolver, banFilter, maxConnections);
this.torMode = torMode;
this.streamIsolation = useStreamIsolation;
this.torControlHost = torControlHost;

executor = SingleThreadExecutorUtils.getSingleThreadExecutor("StartTor");
}
Expand All @@ -97,7 +100,7 @@ protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
// If streamId is null stream isolation gets deactivated.
// Hidden services use stream isolation by default, so we pass null.
return new TorSocket(peerNodeAddress.getHostName(), peerNodeAddress.getPort(), null);
return new TorSocket(peerNodeAddress.getHostName(), peerNodeAddress.getPort(), torControlHost, null);
}

public Socks5Proxy getSocksProxy() {
Expand All @@ -111,7 +114,7 @@ public Socks5Proxy getSocksProxy() {

if (socksProxy == null || streamIsolation) {
tor = Tor.getDefault();
socksProxy = tor != null ? tor.getProxy(stream) : null;
socksProxy = tor != null ? tor.getProxy(torControlHost, stream) : null;
}
return socksProxy;
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testTorNodeBeforeSecondReady() throws InterruptedException, IOExcept
latch = new CountDownLatch(1);
int port = 9001;
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
node1.start(new SetupListener() {
@Override
public void onTorNodeReady() {
Expand All @@ -78,7 +78,7 @@ public void onRequestCustomBridges() {
latch = new CountDownLatch(1);
int port2 = 9002;
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
node2.start(new SetupListener() {
@Override
public void onTorNodeReady() {
Expand Down Expand Up @@ -136,7 +136,7 @@ public void testTorNodeAfterBothReady() throws InterruptedException, IOException
latch = new CountDownLatch(2);
int port = 9001;
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
node1.start(new SetupListener() {
@Override
public void onTorNodeReady() {
Expand All @@ -162,7 +162,7 @@ public void onRequestCustomBridges() {

int port2 = 9002;
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
node2.start(new SetupListener() {
@Override
public void onTorNodeReady() {
Expand Down

0 comments on commit f022dc6

Please sign in to comment.