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

Use same private_key in NewTor and RunningTor mode + Hiddenservice Fix #2009

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
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ configure(subprojects) {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://raw.githubusercontent.com/JesusMcCloud/tor-binary/8.0.3/release/' }
}

dependencies {
Expand Down Expand Up @@ -188,10 +187,10 @@ configure(project(':common')) {
configure(project(':p2p')) {
dependencies {
compile project(':common')
compile('com.github.JesusMcCloud.netlayer:tor.native:0.6') {
compile('com.github.JesusMcCloud.netlayer:tor.native:0.6.2') {
exclude(module: 'slf4j-api')
}
compile('com.github.JesusMcCloud.netlayer:tor.external:0.6') {
compile('com.github.JesusMcCloud.netlayer:tor.external:0.6.2') {
exclude(module: 'slf4j-api')
}
compile('org.apache.httpcomponents:httpclient:4.5.3') {
Expand Down
18 changes: 9 additions & 9 deletions gradle/witness/gradle-witness.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ dependencyVerification {
'com.googlecode.jcsv:jcsv:73ca7d715e90c8d2c2635cc284543b038245a34f70790660ed590e157b8714a2',
'com.github.sarxos:webcam-capture:d960b7ea8ec3ddf2df0725ef214c3fccc9699ea7772df37f544e1f8e4fd665f6',
'com.jfoenix:jfoenix:4739e37a05e67c3bc9d5b391a1b93717b5a48fa872992616b0964d3f827f8fe6',
'com.github.JesusMcCloud.netlayer:tor.native:f1bf0096f9eb6020645a65d91aa530d15aef97e69cc5a79d7b2405421f74700a',
'com.github.JesusMcCloud.netlayer:tor.external:cfba681398c191a1906d6d023a3be28a8fa9b1f4eee52e966daf7b1ae630414f',
'com.github.JesusMcCloud.netlayer:tor.native:1f44272868c8123f918f7cdc7c9a6e14cb4c11b19437058ad3d1164c03954e0a',
'com.github.JesusMcCloud.netlayer:tor.external:a01707144f3ffdb62faacec8263cda0a6e2ecfb241b6b1b54626bed7cd161a4a',
'org.apache.httpcomponents:httpclient:db3d1b6c2d6a5e5ad47577ad61854e2f0e0936199b8e05eb541ed52349263135',
'net.sf.jopt-simple:jopt-simple:6f45c00908265947c39221035250024f2caec9a15c1c8cf553ebeecee289f342',
'org.fxmisc.easybind:easybind:666af296dda6de68751668a62661571b5238ac6f1c07c8a204fc6f902b222aaf',
Expand All @@ -43,7 +43,7 @@ dependencyVerification {
'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
'com.google.guava:guava:36a666e3b71ae7f0f0dca23654b67e086e6c93d192f60ba5dfd5519db6c288c8',
'com.google.inject:guice:9b9df27a5b8c7864112b4137fd92b36c3f1395bfe57be42fedf2f520ead1a93e',
'com.github.JesusMcCloud.netlayer:tor:ac8465b7dda30ea920ec31a6bde42df7e88bee0282e805ce2797628938e3cf0b',
'com.github.JesusMcCloud.netlayer:tor:d377bd3f85a5c6d0a2123d5d9bead810ad3a6de6464775c793e8276155ec1f1d',
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:193ab7813e4d249f2ea4fc1b968fea8c2126bcbeeb5d6127050ce1b93dbaa7c2',
'io.github.microutils:kotlin-logging:4992504fd3c6ecdf9ed10874b9508e758bb908af9e9d7af19a61e9afb6b7e27a',
'org.jetbrains.kotlin:kotlin-stdlib-jdk7:877b59bbe466b24a88275a71fd06cd97359d2085420f6f1ac1d766afa8116001',
Expand All @@ -55,10 +55,10 @@ dependencyVerification {
'org.bouncycastle:bcprov-jdk15on:963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349',
'com.google.zxing:javase:0ec23e2ec12664ddd6347c8920ad647bb3b9da290f897a88516014b56cc77eb9',
'com.nativelibs4java:bridj:101bcd9b6637e6bc16e56deb3daefba62b1f5e8e9e37e1b3e56e3b5860d659cf',
'com.cedricwalter:tor-binary-macos:94f95e127c3409f870ee5c9fc642540c3ba865338cfaf3bb66d1e7e18c7fcee0',
'com.cedricwalter:tor-binary-linux32:af92b0b1ed40e3ff6c0f7b575ce44f19dfd666dfc6709e26cfb0f0bddca752eb',
'com.cedricwalter:tor-binary-linux64:f1fd937ef964e62abb13f62ddd53cd012316ecd09fecf1205e2db9f3333659c1',
'com.cedricwalter:tor-binary-windows:af7d67bc8f74b5c50f68b1aa5aa3e833470964f71882ee06ca40a32cd3dbc940',
'com.github.JesusMcCloud.tor-binary:tor-binary-macos:d143904dee93952576b12afb3c255ffce1b4eb0f8c85b0078c753b5f57fa1d07',
'com.github.JesusMcCloud.tor-binary:tor-binary-linux32:e863b9e37416890825a80f769ed507b203d0bcc3234aa9922d3f801bdf08987b',
'com.github.JesusMcCloud.tor-binary:tor-binary-linux64:936bdc1f9e145fbd625766f79d30761529303badd055e69e7bc0d27fcd771e7b',
'com.github.JesusMcCloud.tor-binary:tor-binary-windows:db2a7af40ded2ccaa12dad26cc301f082bb148322b15ec0155662510609fddfa',
'com.github.ravn:jsocks:3c71600af027b2b6d4244e4ad14d98ff2352a379410daebefff5d8cd48d742a4',
'org.apache.httpcomponents:httpcore:d7f853dee87680b07293d30855b39b9eb56c1297bd16ff1cd6f19ddb8fa745fb',
'commons-codec:commons-codec:ad19d2601c3abf0b946b5c3a4113e226a8c1e3305e395b90013b78dd94a723ce',
Expand All @@ -67,8 +67,8 @@ dependencyVerification {
'aopalliance:aopalliance:0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08',
'com.lambdaworks:scrypt:9a82d218099fb14c10c0e86e7eefeebd8c104de920acdc47b8b4b7a686fb73b4',
'com.google.zxing:core:11aae8fd974ab25faa8208be50468eb12349cd239e93e7c797377fa13e381729',
'com.cedricwalter:tor-binary-geoip:fbd7656a262607e5a73016e048d5270cbabcd4639a1795b4b4e762df8877429d',
'com.github.JesusMcCloud:jtorctl:ba71601cbe50474ccc39a17bc6f7880c1412d8d19b94d37aee69ea2917f72046',
'com.github.JesusMcCloud.tor-binary:tor-binary-geoip:7340d4a0007b822b2f149e7360cd22443a5976676754bfaad0b8c48858475d5f',
'com.github.JesusMcCloud:jtorctl:274dfe462fa24d3e0a0f21c0a2cb87f121932378c221503c730c130734b041bb',
'org.apache.commons:commons-compress:5f2df1e467825e4cac5996d44890c4201c000b43c0b23cffc0782d28a0beb9b0',
'org.tukaani:xz:a594643d73cc01928cf6ca5ce100e094ea9d73af760a5d4fb6b75fa673ecec96',
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
Expand Down
11 changes: 1 addition & 10 deletions p2p/src/main/java/bisq/network/p2p/network/NewTor.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,12 @@
@Slf4j
public class NewTor extends TorMode {

/**
* <code>Netlayer</code> stores its hidden service files in a custom
* subdirectory of <code>$torDir/hiddenservice/</code>. Note that the
* {@link HiddenServiceSocket} does add this part on its own, hence,
* {@link NewTor#getHiddenServiceDirectory()} returns only the custom
* subdirectory (which happens to be <code>""</code>)
*/
private static final String HIDDEN_SERVICE_DIRECTORY = "hiddenservice";

private final String torrcFile;
private final String torrcOptions;
private final Collection<String> bridgeEntries;

public NewTor(File torWorkingDirectory, String torrcFile, String torrcOptions, Collection<String> bridgeEntries) {
super(torWorkingDirectory, HIDDEN_SERVICE_DIRECTORY);
super(torWorkingDirectory);
this.torrcFile = torrcFile;
this.torrcOptions = torrcOptions;
this.bridgeEntries = bridgeEntries;
Expand Down
5 changes: 2 additions & 3 deletions p2p/src/main/java/bisq/network/p2p/network/RunningTor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
@Slf4j
public class RunningTor extends TorMode {

private static final String EXTERNAL_TOR_HIDDEN_SERVICE = "externalTorHiddenService";
private final int controlPort;
private final String password;
private final File cookieFile;
Expand All @@ -49,7 +48,7 @@ public class RunningTor extends TorMode {

public RunningTor(final File torDir, final int controlPort, final String password, final String cookieFile,
final boolean useSafeCookieAuthentication) {
super(torDir, EXTERNAL_TOR_HIDDEN_SERVICE);
super(torDir);
this.controlPort = controlPort;
this.password = password;
this.cookieFile = new File(cookieFile);
Expand Down Expand Up @@ -81,7 +80,7 @@ else if (cookieFile.exists())

@Override
public String getHiddenServiceDirectory() {
return new File(torDir, EXTERNAL_TOR_HIDDEN_SERVICE).getAbsolutePath();
return new File(torDir, HIDDEN_SERVICE_DIRECTORY).getAbsolutePath();
}

}
19 changes: 9 additions & 10 deletions p2p/src/main/java/bisq/network/p2p/network/TorMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
public abstract class TorMode {

/**
* The directory where the <code>private_key</code> file sits in. Kept private,
* because it is only valid for the {@link TorMode#doRollingBackup()} due to the
* inner workings of the <code>Netlayer</code> dependency.
* The sub-directory where the <code>private_key</code> file sits in. Kept
* private, because it only concerns implementations of {@link TorMode}.
*/
private final File hiddenServiceDirectory;
protected static final String HIDDEN_SERVICE_DIRECTORY = "hiddenservice";

protected final File torDir;

/**
Expand All @@ -51,9 +51,8 @@ public abstract class TorMode {
* necessarily equal
* {@link TorMode#getHiddenServiceDirectory()}.
*/
public TorMode(File torDir, String hiddenServiceDir) {
public TorMode(File torDir) {
this.torDir = torDir;
this.hiddenServiceDirectory = new File(torDir, hiddenServiceDir);
}

/**
Expand All @@ -70,9 +69,9 @@ public TorMode(File torDir, String hiddenServiceDir) {
* other stuff to the hiddenServiceDir, thus, selecting nothing (i.e.
* <code>""</code>) as a hidden service directory is fine. {@link ExternalTor},
* however, does not have a Tor installation path and thus, takes the hidden
* service path literally. Hence, we set
* <code>"torDir/externalTorHiddenService"</code> as the hidden service
* directory.
* service path literally. Hence, we set <code>"torDir/hiddenservice"</code> as
* the hidden service directory. By doing so, we use the same
* <code>private_key</code> file as in {@link NewTor} mode.
*
* @return <code>""</code> in {@link NewTor} Mode,
* <code>"torDir/externalTorHiddenService"</code> in {@link RunningTor}
Expand All @@ -84,7 +83,7 @@ public TorMode(File torDir, String hiddenServiceDir) {
* Do a rolling backup of the "private_key" file.
*/
protected void doRollingBackup() {
FileUtil.rollingBackup(hiddenServiceDirectory, "private_key", 20);
FileUtil.rollingBackup(new File(torDir, HIDDEN_SERVICE_DIRECTORY), "private_key", 20);
}

}