Compare commits

...
8 Commits
Author SHA1 Message Date
Max Lv 55f25d3272 disable NAT mode on lollipop for now 2014-10-19 14:09:27 +08:00
Max Lv 93273cbc44 fix an issue on lollipop 2014-10-19 13:58:19 +08:00
Max Lv c0514ee169 disable bypass feature of pdnsd 2014-10-18 10:46:54 +08:00
Max Lv 06d736b22d fix all issues for lollipop 2014-10-18 09:58:40 +08:00
Max Lv e34d5675eb update shadowsocks-libev 2014-10-14 12:58:09 +08:00
Max Lv 94c7ffb788 remove large icon 2014-09-30 12:59:15 +08:00
Max Lv 0647ef4c6d fix #121 2014-09-19 14:17:45 +08:00
Max Lv 97c6ff95cd fix an issue in the build scripts 2014-09-18 08:24:39 +08:00
8 changed files with 80 additions and 78 deletions
+18 -4
View File
@@ -1,14 +1,28 @@
#!/bin/bash #!/bin/bash
ndk-build clean function try () {
ndk-build "$@" || exit -1
}
# Build
try ndk-build clean
try ndk-build
# copy executables
rm -rf src/main/assets/armeabi-v7a rm -rf src/main/assets/armeabi-v7a
rm -rf src/main/assets/x86 rm -rf src/main/assets/x86
mkdir -p src/main/assets/armeabi-v7a mkdir -p src/main/assets/armeabi-v7a
mkdir -p src/main/assets/x86 mkdir -p src/main/assets/x86
for app in pdnsd redsocks for app in pdnsd redsocks
do do
mv libs/armeabi-v7a/$app src/main/assets/armeabi-v7a/ try mv libs/armeabi-v7a/$app src/main/assets/armeabi-v7a/
mv libs/x86/$app src/main/assets/x86/ try mv libs/x86/$app src/main/assets/x86/
done done
# copy libraries
rm -rf src/main/jni/armeabi-v7a
rm -rf src/main/jni/x86
mkdir -p src/main/jni/armeabi-v7a
mkdir -p src/main/jni/x86
try mv libs/armeabi-v7a/*.so src/main/jni/armeabi-v7a/
try mv libs/x86/*.so src/main/jni/x86/
+1 -1
View File
@@ -4,7 +4,7 @@ import android.Dependencies.{apklib,aar}
android.Plugin.androidBuild android.Plugin.androidBuild
platformTarget in Android := "android-19" platformTarget in Android := "android-21"
name := "shadowsocks" name := "shadowsocks"
+5 -5
View File
@@ -21,11 +21,11 @@ jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) {
} else if (family == ANDROID_CPU_FAMILY_MIPS) { } else if (family == ANDROID_CPU_FAMILY_MIPS) {
abi = "mips"; abi = "mips";
} else if (family == ANDROID_CPU_FAMILY_ARM) { } else if (family == ANDROID_CPU_FAMILY_ARM) {
if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) { // if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
abi = "armeabi-v7a"; abi = "armeabi-v7a";
} else { // } else {
abi = "armeabi"; // abi = "armeabi";
} // }
} }
return env->NewStringUTF(abi); return env->NewStringUTF(abi);
} }
+3 -3
View File
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.shadowsocks" package="com.github.shadowsocks"
android:versionCode="71" android:versionCode="75"
android:versionName="2.2.3"> android:versionName="2.3.0">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
@@ -16,7 +16,7 @@
<uses-sdk <uses-sdk
android:minSdkVersion="16" android:minSdkVersion="16"
android:targetSdkVersion="19"/> android:targetSdkVersion="21"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
@@ -755,7 +755,6 @@ class Shadowsocks
} }
private def setPreferenceEnabled(enabled: Boolean) { private def setPreferenceEnabled(enabled: Boolean) {
val isRoot = status.getBoolean(Key.isRoot, false)
for (name <- Shadowsocks.PROXY_PREFS) { for (name <- Shadowsocks.PROXY_PREFS) {
val pref = findPreference(name) val pref = findPreference(name)
if (pref != null) { if (pref != null) {
@@ -767,7 +766,7 @@ class Shadowsocks
if (pref != null) { if (pref != null) {
if (Seq(Key.isGlobalProxy, Key.isTrafficStat, Key.proxyedApps) if (Seq(Key.isGlobalProxy, Key.isTrafficStat, Key.proxyedApps)
.contains(name)) { .contains(name)) {
pref.setEnabled(enabled && isRoot) pref.setEnabled(enabled && !isVpnEnabled)
} else { } else {
pref.setEnabled(enabled) pref.setEnabled(enabled)
} }
@@ -827,10 +826,6 @@ class Shadowsocks
copyAssets(System.getABI) copyAssets(System.getABI)
if (Build.VERSION.SDK_INT >= 20) {
copyToSystem()
}
val ab = new ArrayBuffer[String] val ab = new ArrayBuffer[String]
for (executable <- Shadowsocks.EXECUTABLES) { for (executable <- Shadowsocks.EXECUTABLES) {
ab.append("chmod 755 " + Path.BASE + executable) ab.append("chmod 755 " + Path.BASE + executable)
@@ -879,8 +874,8 @@ class Shadowsocks
def isVpnEnabled: Boolean = { def isVpnEnabled: Boolean = {
if (vpnEnabled < 0) { if (vpnEnabled < 0) {
vpnEnabled = if (Build.VERSION.SDK_INT vpnEnabled = if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
>= Build.VERSION_CODES.ICE_CREAM_SANDWICH && !status.getBoolean(Key.isRoot, false)) { || !status.getBoolean(Key.isRoot, false)) {
1 1
} else { } else {
0 0
@@ -114,49 +114,52 @@ class ShadowsocksNatService extends Service with BaseService {
}) })
} }
val raw_args = ("ss-local -b 127.0.0.1 -s %s -p %d -l %d -k %s -m %s -f " + val cmd = new ArrayBuffer[String]
Path.BASE + "ss-local.pid") cmd += ("ss-local"
.format(config.proxy, config.remotePort, config.localPort, config.sitekey, config.encMethod) , "-b" , "127.0.0.1"
val args = if (Build.VERSION.SDK_INT >= 20) { , "-s" , config.proxy
raw_args , "-p" , config.remotePort.toString
} else { , "-l" , config.localPort.toString
Path.BASE + raw_args , "-k" , config.sitekey
} , "-m" , config.encMethod
val cmd = if (config.isGFWList && isACLEnabled) args + " --acl " + Path.BASE + "chn.acl" else args , "-f" , (Path.BASE + "ss-local.pid"))
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
Core.sslocal(cmd.split(" ")) if (config.isGFWList && isACLEnabled) {
cmd += "--acl"
cmd += (Path.BASE + "chn.acl")
}
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sslocal(cmd.toArray)
} }
def startDnsDaemon() { def startDnsDaemon() {
val args = if (config.isUdpDns) { if (config.isUdpDns) {
("ss-tunnel -b 127.0.0.1 -s %s -p %d -l %d -k %s -m %s -L 8.8.8.8:53 -u -f " + val cmd = new ArrayBuffer[String]
Path.BASE + "ss-tunnel.pid") cmd += ("ss-tunnel" , "-u"
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod) , "-b" , "127.0.0.1"
, "-l" , "8153"
, "-L" , "8.8.8.8:53"
, "-s" , config.proxy
, "-p" , config.remotePort.toString
, "-k" , config.sitekey
, "-m" , config.encMethod
, "-f" , (Path.BASE + "ss-tunnel.pid"))
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sstunnel(cmd.toArray)
} else { } else {
val conf = { val conf = {
if (config.isGFWList) ConfigUtils.PDNSD.format("127.0.0.1")
ConfigUtils.PDNSD_BYPASS.format("127.0.0.1", getString(R.string.exclude))
else
ConfigUtils.PDNSD.format("127.0.0.1")
} }
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
}) })
"pdnsd -c " + Path.BASE + "pdnsd.conf"
}
val cmd = if (Build.VERSION.SDK_INT >= 20) { val args = "pdnsd -c " + Path.BASE + "pdnsd.conf"
"/system/bin/" + args val cmd = Path.BASE + args
} else {
Path.BASE + args
}
if (BuildConfig.DEBUG) Log.d(TAG, cmd) if (BuildConfig.DEBUG) Log.d(TAG, cmd)
if (config.isUdpDns) {
Core.sstunnel(cmd.split(" "))
} else {
Console.runRootCommand(cmd) Console.runRootCommand(cmd)
} }
} }
@@ -180,11 +183,7 @@ class ShadowsocksNatService extends Service with BaseService {
ConfigUtils.printToFile(new File(Path.BASE + "redsocks.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "redsocks.conf"))(p => {
p.println(conf) p.println(conf)
}) })
val cmd = if (Build.VERSION.SDK_INT >= 20) { val cmd = Path.BASE + args
"/system/bin/" + args
} else {
Path.BASE + args
}
Console.runRootCommand(cmd) Console.runRootCommand(cmd)
} }
@@ -225,10 +224,6 @@ class ShadowsocksNatService extends Service with BaseService {
val icon = getResources.getDrawable(R.drawable.ic_stat_shadowsocks) val icon = getResources.getDrawable(R.drawable.ic_stat_shadowsocks)
if (rate >= 0) { if (rate >= 0) {
val bitmap = Utils
.getBitmap(rate.toString, icon.getIntrinsicWidth * 4, icon.getIntrinsicHeight * 4,
Color.TRANSPARENT)
builder.setLargeIcon(bitmap)
if (rate < 1000) { if (rate < 1000) {
builder.setSmallIcon(R.drawable.ic_stat_speed, rate) builder.setSmallIcon(R.drawable.ic_stat_speed, rate)
@@ -327,10 +322,6 @@ class ShadowsocksNatService extends Service with BaseService {
init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-m owner --uid-owner " + myUid)) init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-m owner --uid-owner " + myUid))
if (config.isGFWList) { if (config.isGFWList) {
// Bypass DNS in China
init_sb.append(cmd_bypass.replace("-p tcp -d 0.0.0.0", "-d 114.114.114.114"))
init_sb.append(cmd_bypass.replace("-p tcp -d 0.0.0.0", "-d 114.114.115.115"))
if (!isACLEnabled) if (!isACLEnabled)
{ {
val chn_list: Array[String] = getResources.getStringArray(R.array.chn_list) val chn_list: Array[String] = getResources.getStringArray(R.array.chn_list)
@@ -76,24 +76,26 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def isByass(net: SubnetUtils): Boolean = { def isByass(net: SubnetUtils): Boolean = {
val info = net.getInfo val info = net.getInfo
info.isInRange(config.proxy) || info.isInRange("114.114.114.114") || info.isInRange("114.114.115.115") info.isInRange(config.proxy)
} }
def startShadowsocksDaemon() { def startShadowsocksDaemon() {
val cmd: String = (Path.BASE + val cmd = new ArrayBuffer[String]
"ss-local -b 127.0.0.1 -s %s -p %d -l %d -k %s -m %s -u -f " + cmd += ("ss-local" , "-u"
Path.BASE + "ss-local.pid") , "-b" , "127.0.0.1"
.format(config.proxy, config.remotePort, config.localPort, config.sitekey, config.encMethod) , "-s" , config.proxy
if (BuildConfig.DEBUG) Log.d(TAG, cmd) , "-p" , config.remotePort.toString
Core.sslocal(cmd.split(" ")) , "-l" , config.localPort.toString
, "-k" , config.sitekey
, "-m" , config.encMethod
, "-f" , (Path.BASE + "ss-local.pid"))
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sslocal(cmd.toArray)
} }
def startDnsDaemon() { def startDnsDaemon() {
val conf = { val conf = {
if (config.isGFWList) ConfigUtils.PDNSD.format("0.0.0.0")
ConfigUtils.PDNSD_BYPASS.format("0.0.0.0", getString(R.string.exclude))
else
ConfigUtils.PDNSD.format("0.0.0.0")
} }
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
@@ -142,7 +144,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
} }
}) })
} else { } else {
for (i <- 1 to 254) { for (i <- 1 to 223) {
if (i != 26 && i != 127) { if (i != 26 && i != 127) {
val addr = i.toString + ".0.0.0" val addr = i.toString + ".0.0.0"
val cidr = addr + "/8" val cidr = addr + "/8"