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

chore: ship Tor binary and use custom TorHandler #2366

Merged
merged 6 commits into from
Mar 21, 2024
Merged

chore: ship Tor binary and use custom TorHandler #2366

merged 6 commits into from
Mar 21, 2024

Conversation

siepra
Copy link
Collaborator

@siepra siepra commented Mar 15, 2024

Solves #2328

Pull Request Checklist

  • I have linked this PR to a related GitHub issue.
  • I have added a description of the change (and Github issue number, if any) to the root CHANGELOG.md.

(Optional) Mobile checklist

Please ensure you completed the following checks if you did any changes to the mobile package:

  • I have run e2e tests for mobile
  • I have updated base screenshots for visual regression tests

Copy link
Contributor

@holmesworcester holmesworcester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments about how we're going to make license information clear.


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
Copy link
Contributor

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?


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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator

@leblowl leblowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need libtor.so in here twice?

@leblowl
Copy link
Collaborator

leblowl commented Mar 19, 2024

For binaries from other projects, you can see this comment where I mentioned having an external-licenses directory (https://github.com/TryQuiet/quiet/pull/2366/files#r1531120795) ... since binaries are a bit different, we can create a file external-licenses/licensing.md that mentions something like:

Binary file <path to binary> is from <link to project> and is licensed under guardian-project.txt

@leblowl leblowl mentioned this pull request Mar 21, 2024
@leblowl leblowl merged commit c8ebb00 into develop Mar 21, 2024
9 of 11 checks passed
leblowl added a commit that referenced this pull request Mar 21, 2024
Co-authored-by: Lucas Leblow <lucas@quiet.chat>
leblowl added a commit that referenced this pull request Mar 26, 2024
leblowl added a commit that referenced this pull request Apr 2, 2024
@siepra siepra deleted the fix/2328 branch April 17, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants