Commit 122ca599 authored by Max Lv's avatar Max Lv

Add GFWList support

parent 96fcec78
...@@ -30,3 +30,6 @@ ...@@ -30,3 +30,6 @@
[submodule "src/main/jni/mbedtls"] [submodule "src/main/jni/mbedtls"]
path = src/main/jni/mbedtls path = src/main/jni/mbedtls
url = https://github.com/ARMmbed/mbedtls url = https://github.com/ARMmbed/mbedtls
[submodule "src/main/jni/pcre"]
path = src/main/jni/pcre
url = https://android.googlesource.com/platform/external/pcre
This diff is collapsed.
...@@ -381,7 +381,9 @@ include $(BUILD_EXECUTABLE) ...@@ -381,7 +381,9 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS) include $(CLEAR_VARS)
SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c utils.c netutils.c json.c jconf.c acl.c android.c SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c \
utils.c netutils.c json.c jconf.c acl.c http.c tls.c rule.c \
android.c
LOCAL_MODULE := ss-local LOCAL_MODULE := ss-local
LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES)) LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES))
...@@ -391,6 +393,7 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \ ...@@ -391,6 +393,7 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \
-I$(LOCAL_PATH)/include \ -I$(LOCAL_PATH)/include \
-I$(LOCAL_PATH)/libancillary \ -I$(LOCAL_PATH)/libancillary \
-I$(LOCAL_PATH)/mbedtls/include \ -I$(LOCAL_PATH)/mbedtls/include \
-I$(LOCAL_PATH)/pcre \
-I$(LOCAL_PATH)/shadowsocks-libev/libudns \ -I$(LOCAL_PATH)/shadowsocks-libev/libudns \
-I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \ -I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \ -I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \
...@@ -399,7 +402,8 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \ ...@@ -399,7 +402,8 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \
-I$(LOCAL_PATH)/shadowsocks-libev/libev \ -I$(LOCAL_PATH)/shadowsocks-libev/libev \
-I$(LOCAL_PATH)/include/shadowsocks-libev -I$(LOCAL_PATH)/include/shadowsocks-libev
LOCAL_STATIC_LIBRARIES := libev libmbedtls libipset libcork libudns libsodium libancillary LOCAL_STATIC_LIBRARIES := libev libmbedtls libipset libcork libudns \
libsodium libancillary libpcre
LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -llog
...@@ -551,15 +555,55 @@ include $(BUILD_EXECUTABLE) ...@@ -551,15 +555,55 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= mbedtls LOCAL_MODULE := mbedtls
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/mbedtls/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/mbedtls/include
MBEDTLS_SOURCES := $(wildcard $(LOCAL_PATH)/mbedtls/library/*.c) MBEDTLS_SOURCES := $(wildcard $(LOCAL_PATH)/mbedtls/library/*.c)
LOCAL_SRC_FILES := $(MBEDTLS_SOURCES:$(LOCAL_PATH)/%=%) LOCAL_SRC_FILES := $(MBEDTLS_SOURCES:$(LOCAL_PATH)/%=%)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
########################################################
## pcre
########################################################
include $(CLEAR_VARS)
LOCAL_MODULE := pcre
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(LOCAL_PATH)/pcre/dist $(LOCAL_PATH)/pcre
libpcre_src_files := \
pcre_chartables.c \
dist/pcre_byte_order.c \
dist/pcre_compile.c \
dist/pcre_config.c \
dist/pcre_dfa_exec.c \
dist/pcre_exec.c \
dist/pcre_fullinfo.c \
dist/pcre_get.c \
dist/pcre_globals.c \
dist/pcre_jit_compile.c \
dist/pcre_maketables.c \
dist/pcre_newline.c \
dist/pcre_ord2utf8.c \
dist/pcre_refcount.c \
dist/pcre_string_utils.c \
dist/pcre_study.c \
dist/pcre_tables.c \
dist/pcre_ucd.c \
dist/pcre_valid_utf8.c \
dist/pcre_version.c \
dist/pcre_xclass.c
LOCAL_SRC_FILES := $(addprefix pcre/, $(libpcre_src_files))
include $(BUILD_STATIC_LIBRARY)
# Import cpufeatures # Import cpufeatures
$(call import-module,android/cpufeatures) $(call import-module,android/cpufeatures)
pcre @ 0ea98836
Subproject commit 0ea9883633b5d1fcfc777d57427bbf9b0098397e
Subproject commit d31210c21731ba9b055faccdc26c77b10773fe67 Subproject commit 42d9b68dcc1c6ccd9d766b3755e674c2d0c45a57
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<item>Bypass LAN</item> <item>Bypass LAN</item>
<item>Bypass China</item> <item>Bypass China</item>
<item>Bypass LAN &amp; China</item> <item>Bypass LAN &amp; China</item>
<item>GFW List</item>
</string-array> </string-array>
<string-array name="route_value"> <string-array name="route_value">
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
<item>bypass-lan</item> <item>bypass-lan</item>
<item>bypass-china</item> <item>bypass-china</item>
<item>bypass-lan-china</item> <item>bypass-lan-china</item>
<item>gfwlist</item>
</string-array> </string-array>
<string-array name="private_route"> <string-array name="private_route">
......
...@@ -514,6 +514,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext { ...@@ -514,6 +514,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
crashRecovery() crashRecovery()
copyAssets(System.getABI) copyAssets(System.getABI)
copyAssets("acl")
val ab = new ArrayBuffer[String] val ab = new ArrayBuffer[String]
for (executable <- EXECUTABLES) { for (executable <- EXECUTABLES) {
......
...@@ -71,7 +71,7 @@ class ShadowsocksNatService extends BaseService { ...@@ -71,7 +71,7 @@ class ShadowsocksNatService extends BaseService {
var su: Shell.Interactive = _ var su: Shell.Interactive = _
def startShadowsocksDaemon() { def startShadowsocksDaemon() {
if (profile.route != Route.ALL) { if (profile.route != Route.ALL && profile.route != Route.GFWLIST) {
val acl: Array[Array[String]] = profile.route match { val acl: Array[Array[String]] = profile.route match {
case Route.BYPASS_LAN => Array(getResources.getStringArray(R.array.private_route)) case Route.BYPASS_LAN => Array(getResources.getStringArray(R.array.private_route))
case Route.BYPASS_CHN => Array(getResources.getStringArray(R.array.chn_route)) case Route.BYPASS_CHN => Array(getResources.getStringArray(R.array.chn_route))
...@@ -108,7 +108,10 @@ class ShadowsocksNatService extends BaseService { ...@@ -108,7 +108,10 @@ class ShadowsocksNatService extends BaseService {
if (profile.route != Route.ALL) { if (profile.route != Route.ALL) {
cmd += "--acl" cmd += "--acl"
cmd += (getApplicationInfo.dataDir + "/acl.list") if (profile.route == Route.GFWLIST)
cmd += (getApplicationInfo.dataDir + "/gfwlist.acl")
else
cmd += (getApplicationInfo.dataDir + "/acl.list")
} }
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" ")) if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
...@@ -184,12 +187,15 @@ class ShadowsocksNatService extends BaseService { ...@@ -184,12 +187,15 @@ class ShadowsocksNatService extends BaseService {
def startDnsDaemon() { def startDnsDaemon() {
val conf = if (profile.route == Route.BYPASS_CHN || profile.route == Route.BYPASS_LAN_CHN) { val conf = profile.route match {
ConfigUtils.PDNSD_DIRECT.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir, case Route.BYPASS_CHN | Route.BYPASS_LAN_CHN | Route.GFWLIST => {
"127.0.0.1", profile.localPort + 53, getBlackList, profile.localPort + 63, "") ConfigUtils.PDNSD_DIRECT.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir,
} else { "127.0.0.1", profile.localPort + 53, getBlackList, profile.localPort + 63, "")
ConfigUtils.PDNSD_LOCAL.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir, }
"127.0.0.1", profile.localPort + 53, profile.localPort + 63, "") case _ => {
ConfigUtils.PDNSD_LOCAL.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir,
"127.0.0.1", profile.localPort + 53, profile.localPort + 63, "")
}
} }
Utils.printToFile(new File(getApplicationInfo.dataDir + "/pdnsd-nat.conf"))(p => { Utils.printToFile(new File(getApplicationInfo.dataDir + "/pdnsd-nat.conf"))(p => {
......
...@@ -262,7 +262,10 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -262,7 +262,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (profile.route != Route.ALL) { if (profile.route != Route.ALL) {
cmd += "--acl" cmd += "--acl"
cmd += (getApplicationInfo.dataDir + "/acl.list") if (profile.route == Route.GFWLIST)
cmd += (getApplicationInfo.dataDir + "/gfwlist.acl")
else
cmd += (getApplicationInfo.dataDir + "/acl.list")
} }
if (TcpFastOpen.sendEnabled) cmd += "--fast-open" if (TcpFastOpen.sendEnabled) cmd += "--fast-open"
...@@ -302,11 +305,12 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -302,11 +305,12 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def startDnsDaemon() { def startDnsDaemon() {
val ipv6 = if (profile.ipv6) "" else "reject = ::/0;" val ipv6 = if (profile.ipv6) "" else "reject = ::/0;"
val conf = { val conf = profile.route match {
if (profile.route == Route.BYPASS_CHN || profile.route == Route.BYPASS_LAN_CHN) { case Route.BYPASS_CHN | Route.BYPASS_LAN_CHN | Route.GFWLIST => {
ConfigUtils.PDNSD_DIRECT.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir, ConfigUtils.PDNSD_DIRECT.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir,
"0.0.0.0", profile.localPort + 53, getBlackList, profile.localPort + 63, ipv6) "0.0.0.0", profile.localPort + 53, getBlackList, profile.localPort + 63, ipv6)
} else { }
case _ => {
ConfigUtils.PDNSD_LOCAL.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir, ConfigUtils.PDNSD_LOCAL.formatLocal(Locale.ENGLISH, getApplicationInfo.dataDir,
"0.0.0.0", profile.localPort + 53, profile.localPort + 63, ipv6) "0.0.0.0", profile.localPort + 53, profile.localPort + 63, ipv6)
} }
......
...@@ -194,4 +194,5 @@ object Route { ...@@ -194,4 +194,5 @@ object Route {
val BYPASS_LAN = "bypass-lan" val BYPASS_LAN = "bypass-lan"
val BYPASS_CHN = "bypass-china" val BYPASS_CHN = "bypass-china"
val BYPASS_LAN_CHN = "bypass-lan-china" val BYPASS_LAN_CHN = "bypass-lan-china"
val GFWLIST = "gfwlist"
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment