-
Notifications
You must be signed in to change notification settings - Fork 88
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
chore: ship Tor binary and use custom TorHandler #2366
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8924a55
chore: ship Tor binary and use custom TorHandler
siepra 105081d
chore: add documentation
siepra 304f52a
fix: remove duplicated libs
siepra a1531fa
Add licensing info
61fe887
Update changelog
415d56a
Merge remote-tracking branch 'origin/develop' into fix/2328
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Guide on Android Tor | ||
|
||
Tor runs within its own thread, spawned and managed by [TorHandler](https://github.com/TryQuiet/quiet/blob/8924a5573ed11980ceeadb2f8dd1ce45169f03ee/packages/mobile/android/app/src/main/java/com/quietmobile/Backend/TorHandler.java). TorHandler is based on the Tor-Android library from the Guardian Project, specifically the [TorService](https://github.com/guardianproject/tor-android/blob/master/tor-android-binary/src/main/java/org/torproject/jni/TorService.java). | ||
|
||
We ship the binary [libtor.so](https://github.com/TryQuiet/quiet/blob/8924a5573ed11980ceeadb2f8dd1ce45169f03ee/packages/mobile/android/app/src/main/libs/arm64-v8a/libtor.so), which exposes certain native APIs through JNI. These are used to configure and run Tor. These JNI methods are directed to the official Guardian Project's library, forcing us to use our [wrapper](https://github.com/TryQuiet/quiet/blob/8924a5573ed11980ceeadb2f8dd1ce45169f03ee/packages/mobile/android/app/src/main/cpp/tor-wrapper.cpp) around it. It bridges C-level global namespace accessible libtor.so methods and exposes them through Quiet's app scope JNI interface, enabling its use without modifying the Tor source code itself. | ||
|
||
## Building the Tor Binary | ||
|
||
The Tor binary is designed to be a ready-made product and does not contain the SONAME property. This absence makes linking it to any other shared object, like our tor-wrapper, challenging. While building Tor, it is essential to remember to pass an extra linker flag to set the SONAME property for the compilation product. The entry point for building the Tor binary is [tor-droid-make.sh](https://github.com/guardianproject/tor-android/blob/master/tor-droid-make.sh), with a crucial step being `build_external_dependencies()`. It is advisable to modify the script and skip the `./gradlew` command build assembling, as it is not essential for acquiring the Tor binary. The script is important as it sets flags to enable the Android API in Tor. The prerequisites for building are listed [here](https://raw.githubusercontent.com/guardianproject/tor-android/master/BUILD). The output Tor binary will be located in `external/tor/lib/{ABI}/`. | ||
|
||
### Build Command | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be useful to automate building of Tor directly from their repository on each release for a given Tor version? If so, how hard would this be? |
||
```bash | ||
LDFLAGS='-Wl,-soname,libtor.so' ./tor-droid-make.sh externals -a arm64-v8a | ||
``` | ||
|
||
### Verify Build | ||
To check for the presence of the SONAME property, run: | ||
```bash | ||
readelf -d libtor.so | ||
``` | ||
|
||
To verify the API presence, run: | ||
```bash | ||
nm -D libtor.so | grep "Java_org_torproject_jni_TorService_createTorConfiguration" | ||
``` | ||
|
||
## Post Mortem | ||
|
||
#### Missing Tor Binary ([Issue #2328](https://github.com/TryQuiet/quiet/issues/2328)) | ||
The issue was caused by the removal of the deprecated Gradle flag `enableUncompressedNativeLibs`, which resulted in the deletion of the binary from the location to which we were pointing. We had to alter the method we use the binary, as now described in the previous sections of this document. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The follow is licensing information for code and binaries from external projects: | ||
|
||
- [packages/mobile/android/app/libtor/bin/libtor.so](packages/mobile/android/app/libtor/bin/libtor.so) is built from https://github.com/guardianproject/tor-android and licensed under [tor-android.license.txt](tor-android.license.txt) | ||
|
||
- [packages/mobile/android/app/libnode/bin/libnode.so](packages/mobile/android/app/libnode/bin/libnode.so) is built from https://github.com/nodejs-mobile/nodejs-mobile and licensed under [nodejs-mobile.license.txt](nodejs-mobile.license.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Janea Systems, Inc. and Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we currently using the most recent release of Tor?
Are there any other notes it would be good to include for someone updating Tor in the future, about how to proceed?