-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
353 additions
and
115 deletions.
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
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 |
---|---|---|
@@ -1,14 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Target 9 | ||
cp jni/Application.mk.9 jni/Application.mk | ||
ndk-build clean | ||
ndk-build | ||
rm -rf src/main/assets/armeabi | ||
rm -rf src/main/assets/armeabi-v7a | ||
rm -rf src/main/assets/x86 | ||
mkdir -p src/main/assets/armeabi | ||
mkdir -p src/main/assets/armeabi-v7a | ||
mkdir -p src/main/assets/x86 | ||
for app in ip6tables iptables pdnsd redsocks ss-local ss-tunnel tun2socks | ||
for app in pdnsd redsocks | ||
do | ||
mv libs/armeabi/$app src/main/assets/armeabi/ | ||
mv libs/armeabi-v7a/$app src/main/assets/armeabi-v7a/ | ||
mv libs/x86/$app src/main/assets/x86/ | ||
done | ||
rm -rf src/main/jni | ||
mv libs src/main/jni | ||
|
||
# Target 16 | ||
cp jni/Application.mk.16 jni/Application.mk | ||
ndk-build clean | ||
ndk-build | ||
rm -rf src/main/assets/api-16/armeabi | ||
rm -rf src/main/assets/api-16/armeabi-v7a | ||
rm -rf src/main/assets/api-16/x86 | ||
mkdir -p src/main/assets/api-16/armeabi | ||
mkdir -p src/main/assets/api-16/armeabi-v7a | ||
mkdir -p src/main/assets/api-16/x86 | ||
for app in pdnsd redsocks | ||
do | ||
mv libs/armeabi/$app src/main/assets/api-16/armeabi/ | ||
mv libs/armeabi-v7a/$app src/main/assets/api-16/armeabi-v7a/ | ||
mv libs/x86/$app src/main/assets/api-16/x86/ | ||
done | ||
|
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,4 @@ | ||
APP_ABI := armeabi armeabi-v7a x86 | ||
APP_PLATFORM := android-16 | ||
APP_STL := stlport_static | ||
NDK_TOOLCHAIN_VERSION := 4.8 |
File renamed without changes.
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,84 @@ | ||
#include <jni.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
typedef unsigned short char16_t; | ||
|
||
class String8 { | ||
public: | ||
String8() { | ||
mString = 0; | ||
} | ||
|
||
~String8() { | ||
if (mString) { | ||
free(mString); | ||
} | ||
} | ||
|
||
void set(const char16_t* o, size_t numChars) { | ||
if (mString) { | ||
free(mString); | ||
} | ||
mString = (char*) malloc(numChars + 1); | ||
if (!mString) { | ||
return; | ||
} | ||
for (size_t i = 0; i < numChars; i++) { | ||
mString[i] = (char) o[i]; | ||
} | ||
mString[numChars] = '\0'; | ||
} | ||
|
||
const char* string() { | ||
return mString; | ||
} | ||
private: | ||
char* mString; | ||
}; | ||
|
||
extern "C" { | ||
|
||
int main(int argc, char* args[]); | ||
|
||
#if defined(PDNSD_JNI) | ||
jint Java_com_github_shadowsocks_Core_pdnsd(JNIEnv *env, jobject thiz, jobjectArray argv) { | ||
#elif defined(SSLOCAL_JNI) | ||
jint Java_com_github_shadowsocks_Core_sslocal(JNIEnv *env, jobject thiz, jobjectArray argv) { | ||
#elif defined(SSTUNNEL_JNI) | ||
jint Java_com_github_shadowsocks_Core_sstunnel(JNIEnv *env, jobject thiz, jobjectArray argv) { | ||
#elif defined(TUN2SOCKS_JNI) | ||
jint Java_com_github_shadowsocks_Core_tun2socks(JNIEnv *env, jobject thiz, jobjectArray argv) { | ||
#else | ||
#error "invalid header" | ||
#endif | ||
|
||
int argc = argv ? env->GetArrayLength(argv) : 0; | ||
char **args = NULL; | ||
String8 tmp_8; | ||
|
||
if (argc > 0) { | ||
args = (char **)malloc((argc+1)*sizeof(char *)); | ||
for (int i = 0; i < argc; ++i) { | ||
jstring arg = reinterpret_cast<jstring>(env->GetObjectArrayElement(argv, i)); | ||
const jchar *str = env->GetStringCritical(arg, 0); | ||
tmp_8.set(str, env->GetStringLength(arg)); | ||
env->ReleaseStringCritical(arg, str); | ||
args[i] = strdup(tmp_8.string()); | ||
} | ||
args[argc] = NULL; | ||
|
||
pid_t pid; | ||
pid = fork(); | ||
if (pid == 0) { | ||
int ret = main(argc, args); | ||
return ret; | ||
} | ||
|
||
if (args != NULL) free(args); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=0.12.3 | ||
sbt.version=0.13.5 |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
resolvers += Resolver.url("scalasbt releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns) | ||
|
||
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.2.16") | ||
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.2.20") | ||
|
||
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0") |
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,53 @@ | ||
/* Shadowsocks - A shadowsocks client for Android | ||
* Copyright (C) 2012 <max.c.lv@gmail.com> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
* ___====-_ _-====___ | ||
* _--^^^#####// \\#####^^^--_ | ||
* _-^##########// ( ) \\##########^-_ | ||
* -############// |\^^/| \\############- | ||
* _/############// (@::@) \\############\_ | ||
* /#############(( \\// ))#############\ | ||
* -###############\\ (oo) //###############- | ||
* -#################\\ / VV \ //#################- | ||
* -###################\\/ \//###################- | ||
* _#/|##########/\######( /\ )######/\##########|\#_ | ||
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \| | ||
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| ' | ||
* ` ` ` ` / | | | | \ ' ' ' ' | ||
* ( | | | | ) | ||
* __\ | | | | /__ | ||
* (vvv(VVV)(VVV)vvv) | ||
* | ||
* HERE BE DRAGONS | ||
* | ||
*/ | ||
|
||
package com.github.shadowsocks; | ||
|
||
public class Core { | ||
static { | ||
java.lang.System.loadLibrary("ss-local-jni"); | ||
java.lang.System.loadLibrary("ss-tunnel-jni"); | ||
java.lang.System.loadLibrary("tun2socks-jni"); | ||
java.lang.System.loadLibrary("pdnsd-jni"); | ||
} | ||
|
||
public static native void sslocal(String[] cmd); | ||
public static native void sstunnel(String[] cmd); | ||
public static native void tun2socks(String[] cmd); | ||
public static native void pdnsd(String[] cmd); | ||
} |
Oops, something went wrong.