diff options
43 files changed, 1335 insertions, 0 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..d115cb6 --- /dev/null +++ b/app/CMakeLists.txt | |||
@@ -0,0 +1,54 @@ | |||
1 | cmake_minimum_required(VERSION 3.4.1) | ||
2 | include(ExternalProject) | ||
3 | |||
4 | set(xCONFIG | ||
5 | "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN} ${CMAKE_C_COMPILE_OPTIONS_TARGET}${CMAKE_C_COMPILER_TARGET}" | ||
6 | "LD=${CMAKE_LINKER}" | ||
7 | "AR=${CMAKE_AR}" | ||
8 | "RANLIB=${CMAKE_RANLIB}" | ||
9 | "CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}" | ||
10 | "LDFLAGS=${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}" | ||
11 | "--host=${CMAKE_C_COMPILER_TARGET}" | ||
12 | ) | ||
13 | |||
14 | if(${ANDROID_ABI} STREQUAL "mips64") | ||
15 | list(APPEND xCONFIG --disable-asm) | ||
16 | endif() | ||
17 | |||
18 | ExternalProject_Add(lzo | ||
19 | URL http://files.pacien.net/tmp/lzo-2.10.tar.gz | ||
20 | URL_HASH SHA1=4924676a9bae5db58ef129dc1cebce3baa3c4b5d | ||
21 | CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared | ||
22 | BUILD_COMMAND make -j4 | ||
23 | INSTALL_COMMAND make install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} && | ||
24 | rm -r <BINARY_DIR> | ||
25 | ) | ||
26 | |||
27 | ExternalProject_Add(libressl | ||
28 | URL http://files.pacien.net/tmp/libressl-2.5.4.tar.gz | ||
29 | URL_HASH SHA256=107a5b522fbb8318d4c3be668075e5e607296f0a9255d71674caa94571336efa | ||
30 | CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared | ||
31 | BUILD_COMMAND make -j4 -C crypto | ||
32 | INSTALL_COMMAND make -C crypto install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} && | ||
33 | make -C include install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} && | ||
34 | rm -r <BINARY_DIR> | ||
35 | ) | ||
36 | |||
37 | ExternalProject_Add(tinc | ||
38 | DEPENDS lzo libressl | ||
39 | URL http://files.pacien.net/tmp/tinc-1.1pre15-SNAPSHOT.tar.gz | ||
40 | CONFIGURE_COMMAND autoreconf -fsi <SOURCE_DIR> && | ||
41 | <SOURCE_DIR>/configure ${xCONFIG} | ||
42 | --with-openssl=${CMAKE_CURRENT_BINARY_DIR}/usr/local | ||
43 | --with-lzo=${CMAKE_CURRENT_BINARY_DIR}/usr/local | ||
44 | --disable-curses | ||
45 | --disable-readline | ||
46 | BUILD_COMMAND make -j4 -C src | ||
47 | INSTALL_COMMAND make -C src install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} && | ||
48 | ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tinc ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtinc.so && | ||
49 | ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tincd ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtincd.so && | ||
50 | rm -r <BINARY_DIR> | ||
51 | ) | ||
52 | |||
53 | add_library(exec SHARED src/main/c/exec.c) | ||
54 | add_dependencies(exec tinc) | ||
diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..33514ea --- /dev/null +++ b/app/build.gradle | |||
@@ -0,0 +1,49 @@ | |||
1 | apply plugin: 'com.android.application' | ||
2 | apply plugin: 'me.tatarka.retrolambda' | ||
3 | |||
4 | android { | ||
5 | compileSdkVersion 25 | ||
6 | buildToolsVersion '25.0.0' | ||
7 | defaultConfig { | ||
8 | applicationId "org.pacien.tincapp" | ||
9 | minSdkVersion 21 | ||
10 | targetSdkVersion 25 | ||
11 | versionCode 1 | ||
12 | versionName "0.1-preview" | ||
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
14 | } | ||
15 | buildTypes { | ||
16 | release { | ||
17 | minifyEnabled true | ||
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
19 | } | ||
20 | } | ||
21 | compileOptions { | ||
22 | sourceCompatibility JavaVersion.VERSION_1_8 | ||
23 | targetCompatibility JavaVersion.VERSION_1_8 | ||
24 | } | ||
25 | externalNativeBuild { | ||
26 | cmake { | ||
27 | path "CMakeLists.txt" | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | |||
32 | dependencies { | ||
33 | compile fileTree(dir: 'libs', include: ['*.jar']) | ||
34 | |||
35 | compile 'com.android.support:appcompat-v7:25.3.1' | ||
36 | compile 'com.android.support:design:25.3.1' | ||
37 | compile 'com.android.support:support-v4:25.3.1' | ||
38 | compile 'com.android.support:recyclerview-v7:25.3.1' | ||
39 | compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4' | ||
40 | |||
41 | compile('org.apache.commons:commons-configuration2:2.1.1') { | ||
42 | exclude group: 'commons-logging', module: 'commons-logging' | ||
43 | } | ||
44 | compile('commons-beanutils:commons-beanutils:1.9.3') { | ||
45 | exclude group: 'commons-logging', module: 'commons-logging' | ||
46 | } | ||
47 | |||
48 | compile 'com.annimon:stream:1.1.5' | ||
49 | } | ||
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f795eae --- /dev/null +++ b/app/proguard-rules.pro | |||
@@ -0,0 +1 @@ | |||
-dontwarn org.apache.commons.** | |||
diff --git a/app/src/androidTest/java/org/pacien/tincapp/.gitkeep b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep | |||
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2822d37 --- /dev/null +++ b/app/src/main/AndroidManifest.xml | |||
@@ -0,0 +1,35 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | package="org.pacien.tincapp"> | ||
4 | |||
5 | <uses-permission android:name="android.permission.INTERNET"/> | ||
6 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
7 | |||
8 | <application | ||
9 | android:allowBackup="false" | ||
10 | android:icon="@mipmap/ic_launcher" | ||
11 | android:label="@string/app_label" | ||
12 | android:supportsRtl="true" | ||
13 | android:theme="@style/AppTheme"> | ||
14 | |||
15 | <activity | ||
16 | android:name=".activities.StartActivity" | ||
17 | android:label="@string/app_label" | ||
18 | android:theme="@style/AppTheme.NoActionBar"> | ||
19 | <intent-filter> | ||
20 | <action android:name="android.intent.action.MAIN"/> | ||
21 | <category android:name="android.intent.category.LAUNCHER"/> | ||
22 | </intent-filter> | ||
23 | </activity> | ||
24 | |||
25 | <service | ||
26 | android:name="org.pacien.tincapp.service.TincVpnService" | ||
27 | android:permission="android.permission.BIND_VPN_SERVICE"> | ||
28 | <intent-filter> | ||
29 | <action android:name="android.net.VpnService"/> | ||
30 | </intent-filter> | ||
31 | </service> | ||
32 | |||
33 | </application> | ||
34 | |||
35 | </manifest> | ||
diff --git a/app/src/main/c/exec.c b/app/src/main/c/exec.c new file mode 100644 index 0000000..fdaec0f --- /dev/null +++ b/app/src/main/c/exec.c | |||
@@ -0,0 +1,34 @@ | |||
1 | #include <jni.h> | ||
2 | #include <unistd.h> | ||
3 | #include <stdlib.h> | ||
4 | |||
5 | static inline const char **to_string_array(JNIEnv *env, jobjectArray ja) { | ||
6 | const int len = (*env)->GetArrayLength(env, ja); | ||
7 | const char **ca = calloc((size_t) len + 1, sizeof(char *)); | ||
8 | |||
9 | for (int i = 0; i < len; ++i) { | ||
10 | jstring jstr = (jstring) (*env)->GetObjectArrayElement(env, ja, i); | ||
11 | ca[i] = (*env)->GetStringUTFChars(env, jstr, NULL); | ||
12 | } | ||
13 | |||
14 | ca[len] = NULL; | ||
15 | return ca; | ||
16 | } | ||
17 | |||
18 | static inline void exec(const char **argcv) { | ||
19 | execv(argcv[0], (char *const *) argcv); | ||
20 | exit(1); | ||
21 | } | ||
22 | |||
23 | JNIEXPORT jint JNICALL | ||