Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 30c54d8

Browse files
authored
Merge pull request #27 from 05nelsonm/mn/feature/prep-for-gradle-maven-publish-implementation
Prep for gradle maven publish implementation
2 parents 2fbdd56 + b5b2ca7 commit 30c54d8

23 files changed

Lines changed: 165 additions & 319 deletions

.gitmodules

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
[submodule "external/AndroidPluggableTransports"]
2-
path = external/AndroidPluggableTransports
3-
url = https://github.com/guardianproject/AndroidPluggableTransports.git
4-
branch = master
5-
[submodule "external/tor-android"]
6-
path = external/tor-android
7-
url = https://github.com/guardianproject/tor-android.git
8-
ignore = all
373 KB
Loading
941 KB
Loading
904 KB
Loading

docs/get_started.md

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,97 @@
11
Get Started
22
===
33

4-
## Implementation (topl-service)
5-
- In your App Module's `build.gradle` file, add the following to the `dependencies` block"
4+
## Implementation - Step 1: Assets/Binaries
5+
- **GeoIP files**:
6+
- Your application will need geoip and geoip6 files. Due to
7+
<a href="https://lists.torproject.org/pipermail/tor-dev/2020-January/014117.html" target="_blank">this issue</a>
8+
they currently cannot be provided via a dependency that can be easily updated.
9+
Until then, you'll have to provide them.
10+
- Steps:
11+
- Download `geoip` and `geoip6` files from https://github.com/torproject/tor/tree/master/src/config
12+
- If you prefer the non-mirror repository, you can also obtain them from
13+
https://gitweb.torproject.org/tor.git/tree/src/config
14+
- In your Application module's `src/main` directory, create a new `Directory` named `assets`
15+
- Copy `geoip` and `geoip6` files into the `assets` directory (or a subdirectory within
16+
`assets`, such as `assets/common/`. File extensions not necessary).
17+
- **torrc file**:
18+
- Not needed
19+
- Your application's `torrc` file gets created for you based on what you have stored in
20+
[TorServicePrefs](./topl-service/io.matthewnelson.topl_service.prefs/-tor-service-prefs/index.md).
21+
If nothing is in `TorServicePrefs` for that particular setting, then it will fall back on
22+
your static/default [TorSettings](./topl-core-base/io.matthewnelson.topl_core_base/-tor-settings/index.md)
23+
that you supply upon initialization of `TorServiceController.Builder`.
24+
- **Tor Binaries**:
25+
- I use The GuardianProject's <a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>
26+
project to build binaries, and provided them
27+
<a href="https://github.com/05nelsonm/TOPL-Android-TorBinary" target="_blank">here</a>. The
28+
difference is in how they are packaged as a dependency, and the contents of what you are
29+
importing as a dependency. I package them in the `jniLibs` directory so that the Android OS
30+
will automatically install them into your application's `/data/app/...` directory, and include
31+
no unnecessary classes or resources; just the binaries. Android API 29+ no longer supports
32+
execution of executable files from your application's `/data/data/` directory, and must now be
33+
installed in the `context.applicationInfo.nativeLibraryDir` directory (aka, `/data/app/...`)
34+
to execute.
35+
- Nothing more is needed in terms of configuring initialization via the
36+
`TorServiceController.Builder`, as files will be installed in the correct directory, and
37+
named to match what `topl-service` looks for.
38+
- If you wish to use GuardianProject's binaries, see
39+
<a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>.
40+
- You'll need to use their `NativeResouceInstaller` to install the binaries.
41+
- You'll need to also implement `TorServiceController.Builder.useCustomTorConfigFiles`
42+
method when initializing `topl-service` and provide it with your own
43+
[TorConfigFiles](./topl-core-base/io.matthewnelson.topl_core_base/-tor-config-files/index.md).
44+
- See the sample provided in the
45+
[TorConfigFiles.Builder](./topl-core-base/io.matthewnelson.topl_core_base/-tor-config-files/-builder/index.md)
46+
documentation.
47+
- **Transport Plugin Binaries**:
48+
- Currently unsupported. Working on it!!!
49+
50+
51+
!!! Info
52+
Tor Binaries are ~8MB for each ABI (will be less after compression), so it's advised that builds
53+
are split to keep apk sizes down. For example, the `sampleapp`'s universalApk size (all ABIs)
54+
is ~16MB, where splits are ~7MB. See the `sampleapp`'s `build.gradle` file for more details.
55+
<a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/sampleapp/build.gradle" target="_blank">here</a>
56+
57+
## Implementation - Step 2: topl-service
58+
- In your Application module's `build.gradle` file, add the following to the `dependencies` block:
659
```groovy
760
def topl_android_version = "{{ topl_android.release }}"
8-
implementation 'io.matthewnelson.topl-android:topl-core-base:$topl_android_version'
9-
implementation 'io.matthewnelson.topl-android:topl-service:$topl_android_version'
61+
implementation "io.matthewnelson.topl-android:topl-core-base:$topl_android_version"
62+
implementation "io.matthewnelson.topl-android:topl-service:$topl_android_version"
1063
```
11-
12-
- TODO: geoip files and binaries
1364
1465
- Create a new class which extends [TorSettings](./topl-core-base/io.matthewnelson.topl_core_base/-tor-settings/index.md)
1566
and apply your own default settings.
67+
- See the SampleApp's
68+
<a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/sampleapp/src/main/java/io/matthewnelson/sampleapp/MyTorSettings.kt">MyTorSettings</a>
69+
class for help.
70+
- Also checkout the documentation in the `TorSettings` class for more of a breakdown and help.
1671
1772
- In your Application class' `onCreate` implement, and customize as desired, the
1873
[TorServiceController.Builder](./topl-service/io.matthewnelson.topl_service/-tor-service-controller/-builder/index.md)
1974
2075
- Call APIs provided from
2176
[TorServiceController.Companion](./topl-service/io.matthewnelson.topl_service/-tor-service-controller/index.md)
2277
23-
## Using the SNAPSHOT version
78+
### Using the SNAPSHOT version of topl-service
2479
25-
- In your Project's `build.gradle` file, add the following to the `repositories` block:
80+
- In your Application module's `build.gradle` file, add the following (*outside* the `android` block):
2681
```groovy
27-
mavenCentral()
28-
maven {
29-
url 'https://oss.sonatype.org/content/repositories/snapshots/'
82+
repositories {
83+
maven {
84+
url 'https://oss.sonatype.org/content/repositories/snapshots/'
85+
}
3086
}
3187
```
3288
33-
- In your App module's `build.gradle` file, add (or modify) the following in the `dependencies` block:
89+
- In your Application module's `build.gradle` file, add (or modify) the following in the `dependencies` block:
3490
```groovy
3591
def topl_android_version = "{{ topl_android.next_release }}-SNAPSHOT"
3692
implementation 'io.matthewnelson.topl-android:topl-core-base:$topl_android_version'
3793
implementation 'io.matthewnelson.topl-android:topl-service:$topl_android_version'
3894
```
3995
40-
!!! Warning
96+
!!! Warning
4197
SNAPSHOT versions are ever changing and may contain not yet fully fleshed out features. Do **not** ship a release.

docs/index.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
# TorOnionProxyLibrary-Android
2-
An Android Library for embedding Tor as a service into your Application
2+
An Android Library for embedding Tor as a service into your Application
33

44
**NOTE: This project exists independently of the Tor Project, & Guardian Project.**
55

6-
This is a Fork of the <a href="https://github.com/thaliproject/Tor_Onion_Proxy_Library" target="_blank">Tor_Onion_Proxy_Library</a>
6+
This is a Fork of the
7+
<a href="https://github.com/thaliproject/Tor_Onion_Proxy_Library" target="_blank">Tor_Onion_Proxy_Library</a>
8+
project.
79

8-
This fork has been re-built from the ground up and engineered specifically for Android, where
9-
it was once multi-platform. It's been re-written in Kotlin, heavily refactored, and a separate
10-
`Service` created for abstracting away the complexities into simple APIs to make embedding Tor
11-
directly into your Application, easy.
10+
<center>
11+
<img src="assets/Screenshot_SampleApp_Debug_full.png" width="250"/>
12+
<img src="assets/Screenshot_SampleApp_Debug_notification1.png" width="250"/>
13+
<img src="assets/Screenshot_SampleApp_Debug_notification2.png" width="250"/>
14+
</center>
15+
16+
It's been re-built from the ground up and engineered specifically for :material-heart-multiple:
17+
Android :material-heart-multiple:, where it was once multi-platform. It's been re-written in
18+
Kotlin, heavily refactored to improve reliability/ease of use, and an `android.app.Service`
19+
built on top as an additional module/Library for abstracting away complexities.
20+
21+
The `topl-service` module/Library has simple to use APIs for integrating Tor into your
22+
application, and customizing the notification to meet your liking.
1223

1324
## [Project Roadmap](roadmap.md)
1425

docs/releasing.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ git push
111111
- `mkdocs gh-deploy` to deploy
112112
- Ensure docs are served <a href="https://topl-android.matthewnelson.io" target="_blank">Here</a>
113113
- `exit`
114-
- Go to the <a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/releases/new" target="_blank">Draft a new release</a> page,
115-
enter the release name ({{ topl_android.next_release }}) as tag and title, and have the description
116-
point to the changelog. You can find the direct anchor URL from the
117-
<a href="https://topl-android.matthewnelson.io/changelog/" target="_blank">Change Log</a>
118-
page on the doc site.
114+
- Sign SampleApp release apks:
115+
- `scripts/sign_sampleapp_release_build.sh`
116+
- Go to the <a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/releases/new" target="_blank">Draft a new release</a>
117+
page
118+
- Enter the release name ({{ topl_android.next_release }}) as tag and title.
119+
- Have the description point to the changelog. You can find the direct anchor URL from the
120+
<a href="https://topl-android.matthewnelson.io/changelog/" target="_blank">Change Log</a>
121+
page on the doc site.
122+
- Upload the signed release apks.
Lines changed: 0 additions & 1 deletion
This file was deleted.

external/tor-android

Lines changed: 0 additions & 1 deletion
This file was deleted.

sampleapp/build.gradle

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,39 @@ android {
4545
kotlinOptions {
4646
jvmTarget = JavaVersion.VERSION_1_8
4747
}
48+
49+
// https://github.com/guardianproject/tor-android/blob/master/sampletorapp/build.gradle
50+
splits {
51+
52+
// Configures multiple APKs based on ABI. This helps keep the size
53+
// down, since PT binaries can be large.
54+
abi {
55+
56+
// Enables building multiple APKs per ABI.
57+
enable true
58+
59+
// By default all ABIs are included, so use reset() and include to specify
60+
// that we only want APKs for x86 and x86_64, armeabi-v7a, and arm64-v8a.
61+
62+
// Resets the list of ABIs that Gradle should create APKs for to none.
63+
reset()
64+
65+
// Specifies a list of ABIs that Gradle should create APKs for.
66+
include "x86", "armeabi-v7a", "arm64-v8a", "x86_64"
67+
68+
// Specify whether or not you wish to also generate a universal APK that
69+
// includes _all_ ABIs.
70+
universalApk true
71+
}
72+
}
4873
}
4974

75+
//repositories {
76+
// maven {
77+
// url 'https://oss.sonatype.org/content/repositories/snapshots/'
78+
// }
79+
//}
80+
5081
dependencies {
5182
implementation fileTree(dir: "libs", include: ["*.jar"])
5283
implementation project(':topl-core-base')
@@ -62,51 +93,12 @@ dependencies {
6293
implementation deps.kotlin.coroutinesAndroid
6394
implementation deps.kotlin.stdlib
6495

96+
implementation "io.matthewnelson.topl-android:tor-binary:0.4.3.5a"
97+
6598
testImplementation deps.junit
6699

67100
androidTestImplementation deps.androidx.test.core
68101
androidTestImplementation deps.androidx.test.espresso
69102
androidTestImplementation deps.androidx.test.junit
70103

71104
}
72-
73-
task updatePluggableTransportsSubmodule(type: Exec) {
74-
workingDir "$rootDir"
75-
commandLine "scripts/pull_latest_transports.sh"
76-
}
77-
78-
task copyPluggableTransports(type: Copy, dependsOn: updatePluggableTransportsSubmodule) {
79-
from("$rootDir/external/AndroidPluggableTransports/APTDispatchLibrary-MeekObfs4-Legacy/src/main/libs")
80-
into("src/main/jniLibs")
81-
rename { filename ->
82-
filename.replace "$filename", 'libObfs4proxy.so'
83-
}
84-
}
85-
86-
task buildTorBinaries(type: Exec) {
87-
workingDir "$rootDir"
88-
commandLine 'scripts/update_tor_binaries.sh', 'build'
89-
}
90-
91-
task copyTorBinaries(type: Copy, dependsOn: buildTorBinaries) {
92-
from("$rootDir/external/tor-android/tor-android-binary/src/main/libs")
93-
into("src/main/jniLibs")
94-
rename { filename ->
95-
filename.replace "$filename", 'libTor.so'
96-
}
97-
}
98-
99-
task updateTorBinaries(type: Exec, dependsOn: copyTorBinaries) {
100-
workingDir "$rootDir"
101-
commandLine 'scripts/update_tor_binaries.sh', 'update_versions_file'
102-
}
103-
104-
task checkForTorBinaryUpdate(type: Exec) {
105-
workingDir "$rootDir"
106-
commandLine 'scripts/update_tor_binaries.sh', 'check_for_update'
107-
}
108-
109-
gradle.projectsEvaluated {
110-
preBuild.dependsOn(checkForTorBinaryUpdate)
111-
preBuild.dependsOn(copyPluggableTransports)
112-
}

0 commit comments

Comments
 (0)