Skip to content

Commit

Permalink
add front proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
esdeathlove committed May 30, 2017
1 parent 42f5658 commit 0a1f829
Show file tree
Hide file tree
Showing 20 changed files with 369 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
[submodule "src/main/jni/pcre"]
path = src/main/jni/pcre
url = https://android.googlesource.com/platform/external/pcre
[submodule "src/main/jni/proxychains"]
path = src/main/jni/proxychains
url = https://github.com/esdeathlove/proxychains-ng.git
branch = master
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ libraryDependencies ++=
"com.squareup.okhttp3" % "okhttp" % "3.5.0" ::
"com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2" ::
"dnsjava" % "dnsjava" % "2.1.7" ::
"eu.chainfire" % "libsuperuser" % "1.0.0.201608240809" ::
"eu.chainfire" % "libsuperuser" % "1.0.0.+" ::
"net.glxn.qrgen" % "android" % "2.0" ::
"com.arasthel" % "asyncjob-library" % "1.0.3" ::
Nil

lazy val nativeBuild = TaskKey[Unit]("native-build", "Build native executables")
Expand Down
9 changes: 5 additions & 4 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.github.shadowsocks"
android:versionCode="257"
android:versionName="3.3.8.3">
android:versionCode="293"
android:versionName="3.3.9">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand Down Expand Up @@ -31,7 +31,8 @@
android:backupAgent=".ShadowsocksBackupAgent"
android:label="@string/app_name"
android:theme="@style/Theme.Material"
android:banner="@drawable/ic_start_connected">
android:banner="@drawable/ic_start_connected"
android:debuggable="true">

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
Expand Down Expand Up @@ -62,7 +63,7 @@
android:name=".ShadowsocksRunnerActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:taskAffinity=""
android:taskAffinity=""
android:launchMode="singleTask">
</activity>

Expand Down
34 changes: 32 additions & 2 deletions src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c \

LOCAL_MODULE := ss-local
LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES))
LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \
LOCAL_CFLAGS := -Wall -O0 -g -fno-strict-aliasing -DMODULE_LOCAL \
-DUSE_CRYPTO_MBEDTLS -DANDROID -DHAVE_CONFIG_H \
-DCONNECT_IN_PROGRESS=EINPROGRESS \
-I$(LOCAL_PATH)/include/shadowsocks-libev \
Expand Down Expand Up @@ -518,7 +518,7 @@ TUN2SOCKS_SOURCES := \
base/DebugObject.c \
base/BLog.c \
base/BPending.c \
system/BDatagram_unix.c \
system/BDatagram_unix.c \
flowextra/PacketPassInactivityMonitor.c \
tun2socks/SocksUdpGwClient.c \
udpgw_client/UdpGwClient.c
Expand Down Expand Up @@ -586,5 +586,35 @@ LOCAL_SRC_FILES := $(addprefix pcre/, $(libpcre_src_files))

include $(BUILD_STATIC_LIBRARY)

########################################################
## libproxychains4
########################################################

include $(CLEAR_VARS)

LOCAL_MODULE:= libproxychains4

LOCAL_C_INCLUDES:= $(LOCAL_PATH)/proxychains/src

PROXYCHAINS_SOURCES := version.c core.c common.c libproxychains.c \
allocator_thread.c ip_type.c hostsreader.c \
hash.c debug.c

LOCAL_SRC_FILES := $(addprefix proxychains/src/, $(PROXYCHAINS_SOURCES))

LOCAL_CFLAGS := -fPIC -pthread -ldl -Wl,--no-as-needed -Wl,-soname=libproxychains4.so \
-DANDROID -O0 -g\
-I$(LOCAL_PATH)/include/proxychains \
-I$(LOCAL_PATH)/proxychains/src \
-I$(LOCAL_PATH)/libancillary \
-DLIB_DIR=\"/data/user/0/in.zhaoj.shadowsocksr/lib\" -DINSTALL_PREFIX=\"/data/user/0/in.zhaoj.shadowsocksr/\" \
-DDLL_NAME=\"libproxychains4.so\" -DSYSCONFDIR=\"/data/user/0/in.zhaoj.shadowsocksr/\"

LOCAL_STATIC_LIBRARIES := libancillary

LOCAL_LDLIBS := -ldl -llog

include $(BUILD_SHARED_LIBRARY)

# Import cpufeatures
$(call import-module,android/cpufeatures)
8 changes: 8 additions & 0 deletions src/main/jni/include/proxychains/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
#ifndef _CONFIG_H_
#define _CONFIG_H_

#define DLL_NAME "libproxychains4.so"

typedef in_port_t uint16_t
1 change: 1 addition & 0 deletions src/main/jni/proxychains
Submodule proxychains added at 3d74aa
2 changes: 2 additions & 0 deletions src/main/jni/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) {

if (family == ANDROID_CPU_FAMILY_X86) {
abi = "x86";
} else if (family == ANDROID_CPU_FAMILY_ARM64) {
abi = "arm64-v8a";
} else if (family == ANDROID_CPU_FAMILY_MIPS) {
abi = "mips";
} else if (family == ANDROID_CPU_FAMILY_ARM) {
Expand Down
76 changes: 76 additions & 0 deletions src/main/res/layout/layout_front_proxy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:text="@string/frontproxy_enable"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<Switch
android:id="@+id/sw_frontproxy_enable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/frontproxy_type"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<Spinner
android:id="@+id/sp_frontproxy_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="@array/frontproxy_type_entry"/>

<TextView
android:text="@string/frontproxy_addr"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<EditText
android:id="@+id/et_frontproxy_addr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/frontproxy_port"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<EditText
android:id="@+id/et_frontproxy_port"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/frontproxy_username"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<EditText
android:id="@+id/et_frontproxy_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/frontproxy_password"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<EditText
android:id="@+id/et_frontproxy_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

</LinearLayout>
8 changes: 8 additions & 0 deletions src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@
<string name="action_sort">レイテンシによる自動ソート</string>
<string name="ping">Ping</string>

<string name="frontproxy_enable">有効にする</string>
<string name="frontproxy_addr">サーバーアドレス</string>
<string name="frontproxy_port">リモートポート</string>
<string name="frontproxy_username">ユーザー名</string>
<string name="frontproxy_password">パスワード</string>
<string name="frontproxy_type">タイプ</string>
<string name="frontproxy_set">フロントエージェント</string>

<!-- status -->
<string name="sent">送信済み:</string>
<string name="received">受信済み:</string>
Expand Down
8 changes: 8 additions & 0 deletions src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@
<string name="action_sort">Автоматическая сортировка по времени ожидания</string>
<string name="ping">пинг</string>

<string name="frontproxy_enable">включить</string>
<string name="frontproxy_addr">Адрес</string>
<string name="frontproxy_port">порт</string>
<string name="frontproxy_username">имя пользователя</string>
<string name="frontproxy_password">пароль</string>
<string name="frontproxy_type">Тип</string>
<string name="frontproxy_set">фронт полномочие</string>


<string name="scan_qrcode_install_title">Сканирование подсказки кода</string>
<string name="scan_qrcode_install_text">Кажется, вы не установили сканер в соответствии с ZXing стандартами, нажмите кнопку «ОК» приведет вас в магазин приложений, где вы установили загрузку, или вы можете нажать кнопку «Загрузить», чтобы загрузить APK установлен непосредственно.</string>
Expand Down
8 changes: 8 additions & 0 deletions src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@
<string name="action_sort">基于延时自动排序</string>
<string name="ping">测试延时</string>

<string name="frontproxy_enable">启用</string>
<string name="frontproxy_addr">地址</string>
<string name="frontproxy_port">端口</string>
<string name="frontproxy_username">用户名</string>
<string name="frontproxy_password">密码</string>
<string name="frontproxy_type">类型</string>
<string name="frontproxy_set">前置代理</string>

<!-- status -->
<string name="sent">发送:</string>
<string name="received">接收:</string>
Expand Down
8 changes: 8 additions & 0 deletions src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@
<string name="action_sort">基於延時自動排序</string>
<string name="ping">測試延時</string>

<string name="frontproxy_enable">啟用</string>
<string name="frontproxy_addr">地址</string>
<string name="frontproxy_port">連接埠</string>
<string name="frontproxy_username">用戶名</string>
<string name="frontproxy_password">密碼</string>
<string name="frontproxy_type">類型</string>
<string name="frontproxy_set">前置代理</string>

<!-- status -->
<string name="sent">傳送:</string>
<string name="received">接收:</string>
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="frontproxy_type_entry">
<item>http</item>
<item>socks4</item>
<item>socks5</item>
</string-array>

<string-array name="enc_method_entry">
<item>none</item>
<item>table</item>
Expand Down
8 changes: 8 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@
<string name="action_sort">Auto sort by latency</string>
<string name="ping">Ping</string>

<string name="frontproxy_enable">Enable</string>
<string name="frontproxy_addr">Address</string>
<string name="frontproxy_port">Port</string>
<string name="frontproxy_username">Username</string>
<string name="frontproxy_password">Password</string>
<string name="frontproxy_type">Type</string>
<string name="frontproxy_set">FrontProxy</string>



<string name="scan_qrcode_install_title">Scan tips</string>
Expand Down
1 change: 1 addition & 0 deletions src/main/res/xml/pref_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
android:summary="@string/recovery_summary"/>
<Preference android:key="aclupdate" android:title="@string/aclupdate"
android:summary="@string/aclupdate_summary"/>
<Preference android:key="frontproxy" android:title="@string/frontproxy_set"/>
<Preference android:key="about" android:title="@string/about"/>

<Preference android:key="logcat" android:title="Logcat"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ShadowsocksApplication extends Application {
def crashRecovery() {
val cmd = new ArrayBuffer[String]()

for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks", "kcptun")) {
for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks", "proxychains")) {
cmd.append("killall %s".formatLocal(Locale.ENGLISH, task))
cmd.append("rm -f %1$s/%2$s-nat.conf %1$s/%2$s-vpn.conf"
.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir, task))
Expand Down
Loading

0 comments on commit 0a1f829

Please sign in to comment.