Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e34d5675eb | ||
|
|
94c7ffb788 | ||
|
|
0647ef4c6d | ||
|
|
97c6ff95cd | ||
|
|
971ef22186 | ||
|
|
c35a92a927 | ||
|
|
c05a63a75b | ||
|
|
6074a99eb6 | ||
|
|
e52719d1be |
+18
-28
@@ -1,38 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Target 9
|
function try () {
|
||||||
cp jni/Application.mk.9 jni/Application.mk
|
"$@" || exit -1
|
||||||
ndk-build clean
|
}
|
||||||
ndk-build
|
|
||||||
rm -rf src/main/assets/armeabi
|
# 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
|
|
||||||
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/$app src/main/assets/armeabi/
|
try mv libs/armeabi-v7a/$app src/main/assets/armeabi-v7a/
|
||||||
mv libs/armeabi-v7a/$app src/main/assets/armeabi-v7a/
|
try mv libs/x86/$app src/main/assets/x86/
|
||||||
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
|
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/
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ libraryDependencies ++= Seq(
|
|||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"net.simonvt.menudrawer" % "menudrawer" % "3.0.6",
|
"net.simonvt.menudrawer" % "menudrawer" % "3.0.6",
|
||||||
"com.google.android.gms" % "play-services" % "5.2.08",
|
"com.google.android.gms" % "play-services" % "5.0.89",
|
||||||
"com.android.support" % "support-v4" % "19.1.0"
|
"com.android.support" % "support-v4" % "19.1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"de.keyboardsurfer.android.widget" % "crouton" % "1.8.1" exclude("com.google.android", "support-v4"),
|
"de.keyboardsurfer.android.widget" % "crouton" % "1.8.4" exclude("com.google.android", "support-v4"),
|
||||||
"com.nostra13.universalimageloader" % "universal-image-loader" % "1.8.4",
|
"com.nostra13.universalimageloader" % "universal-image-loader" % "1.8.4",
|
||||||
"com.j256.ormlite" % "ormlite-core" % "4.47",
|
"com.j256.ormlite" % "ormlite-core" % "4.47",
|
||||||
"com.j256.ormlite" % "ormlite-android" % "4.47"
|
"com.j256.ormlite" % "ormlite-android" % "4.47"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
APP_ABI := armeabi armeabi-v7a x86
|
APP_ABI := armeabi-v7a x86
|
||||||
APP_PLATFORM := android-16
|
APP_PLATFORM := android-16
|
||||||
APP_STL := stlport_static
|
APP_STL := stlport_static
|
||||||
NDK_TOOLCHAIN_VERSION := 4.8
|
NDK_TOOLCHAIN_VERSION := 4.8
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
APP_ABI := armeabi armeabi-v7a x86
|
|
||||||
APP_PLATFORM := android-9
|
|
||||||
APP_STL := stlport_static
|
|
||||||
NDK_TOOLCHAIN_VERSION := 4.8
|
|
||||||
+1
-1
Submodule jni/shadowsocks updated: d37f8d3025...5d7dd372fc
+5
-5
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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="70"
|
android:versionCode="74"
|
||||||
android:versionName="2.2.2">
|
android:versionName="2.2.6">
|
||||||
|
|
||||||
<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"/>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
android:required="false"/>
|
android:required="false"/>
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="16"
|
||||||
android:targetSdkVersion="19"/>
|
android:targetSdkVersion="19"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<string name="forward_stop">后台服务已停止。</string>
|
<string name="forward_stop">后台服务已停止。</string>
|
||||||
<string name="service_failed">请检查你的网络状态后并重试。</string>
|
<string name="service_failed">请检查你的网络状态后并重试。</string>
|
||||||
<string name="stop">停止服务</string>
|
<string name="stop">停止服务</string>
|
||||||
<string name="vpn_error">无法启动 VPN 服务:\"%s\"。看来和你的设备存在兼容性问题,请使用 Root 模式。</string>
|
<string name="vpn_error">无法启动服务:\"%s\"。</string>
|
||||||
<string name="ok_iknow">确定</string>
|
<string name="ok_iknow">确定</string>
|
||||||
<string name="port_alert">端口号应大于1024</string>
|
<string name="port_alert">端口号应大于1024</string>
|
||||||
<string name="port_empty">端口号不能为空</string>
|
<string name="port_empty">端口号不能为空</string>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<string name="forward_stop">Shadowsocks stopped.</string>
|
<string name="forward_stop">Shadowsocks stopped.</string>
|
||||||
<string name="service_failed">Please check your network status and try again.</string>
|
<string name="service_failed">Please check your network status and try again.</string>
|
||||||
<string name="stop">Stop the service</string>
|
<string name="stop">Stop the service</string>
|
||||||
<string name="vpn_error">Unable to start VPN service: "%s". It seems to be a compatibility issue with your device. Please consider using ROOT mode instead.</string>
|
<string name="vpn_error">Unable to start service: "%s".</string>
|
||||||
|
|
||||||
<!-- alert category -->
|
<!-- alert category -->
|
||||||
<string name="ok_iknow">OK</string>
|
<string name="ok_iknow">OK</string>
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ class Shadowsocks
|
|||||||
setPreferenceEnabled(enabled = false)
|
setPreferenceEnabled(enabled = false)
|
||||||
}
|
}
|
||||||
state = bgService.getState
|
state = bgService.getState
|
||||||
|
// set the listener
|
||||||
|
switchButton.setOnCheckedChangeListener(Shadowsocks.this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onServiceDisconnected(name: ComponentName) {
|
override def onServiceDisconnected(name: ComponentName) {
|
||||||
@@ -746,9 +748,9 @@ class Shadowsocks
|
|||||||
changeSwitch(checked = false)
|
changeSwitch(checked = false)
|
||||||
}
|
}
|
||||||
state = bgService.getState
|
state = bgService.getState
|
||||||
|
// set the listener
|
||||||
|
switchButton.setOnCheckedChangeListener(Shadowsocks.this)
|
||||||
}
|
}
|
||||||
// set the listener
|
|
||||||
switchButton.setOnCheckedChangeListener(Shadowsocks.this)
|
|
||||||
ConfigUtils.refresh(this)
|
ConfigUtils.refresh(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,11 +825,7 @@ class Shadowsocks
|
|||||||
|
|
||||||
crash_recovery()
|
crash_recovery()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 16) {
|
copyAssets(System.getABI)
|
||||||
copyAssets("api-16/" + System.getABI)
|
|
||||||
} else {
|
|
||||||
copyAssets(System.getABI)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 20) {
|
if (Build.VERSION.SDK_INT >= 20) {
|
||||||
copyToSystem()
|
copyToSystem()
|
||||||
@@ -930,8 +928,6 @@ class Shadowsocks
|
|||||||
bgService.start(ConfigUtils.load(settings))
|
bgService.start(ConfigUtils.load(settings))
|
||||||
|
|
||||||
if (isVpnEnabled) {
|
if (isVpnEnabled) {
|
||||||
val style = new Style.Builder().setBackgroundColorValue(Style.holoBlueLight).build()
|
|
||||||
val config = new Configuration.Builder().setDuration(Configuration.DURATION_LONG).build()
|
|
||||||
changeSwitch(checked = false)
|
changeSwitch(checked = false)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
@@ -997,7 +993,6 @@ class Shadowsocks
|
|||||||
changeSwitch(checked = false)
|
changeSwitch(checked = false)
|
||||||
Crouton.cancelAllCroutons()
|
Crouton.cancelAllCroutons()
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
Crouton.cancelAllCroutons()
|
|
||||||
val style = new Style.Builder().setBackgroundColorValue(Style.holoRedLight).build()
|
val style = new Style.Builder().setBackgroundColorValue(Style.holoRedLight).build()
|
||||||
val config = new Configuration.Builder()
|
val config = new Configuration.Builder()
|
||||||
.setDuration(Configuration.DURATION_LONG)
|
.setDuration(Configuration.DURATION_LONG)
|
||||||
|
|||||||
@@ -114,25 +114,40 @@ 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)
|
if (config.isGFWList)
|
||||||
@@ -143,20 +158,15 @@ class ShadowsocksNatService extends Service with BaseService {
|
|||||||
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
|
|
||||||
} else {
|
|
||||||
Path.BASE + args
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
val cmd = if (Build.VERSION.SDK_INT >= 20) {
|
||||||
|
"/system/bin/" + args
|
||||||
if (config.isUdpDns) {
|
} else {
|
||||||
Core.sstunnel(cmd.split(" "))
|
Path.BASE + args
|
||||||
} else {
|
}
|
||||||
|
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
||||||
Console.runRootCommand(cmd)
|
Console.runRootCommand(cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,10 +235,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)
|
||||||
@@ -254,22 +260,6 @@ class ShadowsocksNatService extends Service with BaseService {
|
|||||||
startForegroundCompat(1, builder.build)
|
startForegroundCompat(1, builder.build)
|
||||||
}
|
}
|
||||||
|
|
||||||
def notifyAlert(title: String, info: String) {
|
|
||||||
val openIntent: Intent = new Intent(this, classOf[Shadowsocks])
|
|
||||||
openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
val contentIntent: PendingIntent = PendingIntent.getActivity(this, 0, openIntent, 0)
|
|
||||||
val builder: NotificationCompat.Builder = new NotificationCompat.Builder(this)
|
|
||||||
builder
|
|
||||||
.setSmallIcon(R.drawable.ic_stat_shadowsocks)
|
|
||||||
.setWhen(0)
|
|
||||||
.setTicker(title)
|
|
||||||
.setContentTitle(getString(R.string.app_name))
|
|
||||||
.setContentText(info)
|
|
||||||
.setContentIntent(contentIntent)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
notificationManager.notify(1, builder.build)
|
|
||||||
}
|
|
||||||
|
|
||||||
def onBind(intent: Intent): IBinder = {
|
def onBind(intent: Intent): IBinder = {
|
||||||
Log.d(TAG, "onBind")
|
Log.d(TAG, "onBind")
|
||||||
if (Action.SERVICE == intent.getAction) {
|
if (Action.SERVICE == intent.getAction) {
|
||||||
@@ -492,44 +482,46 @@ class ShadowsocksNatService extends Service with BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spawn {
|
spawn {
|
||||||
|
|
||||||
if (config.proxy == "198.199.101.152") {
|
if (config.proxy == "198.199.101.152") {
|
||||||
val holder = application.containerHolder
|
val holder = application.containerHolder
|
||||||
try {
|
try {
|
||||||
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
||||||
} catch {
|
} catch {
|
||||||
case ex: Exception =>
|
case ex: Exception =>
|
||||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||||
stopRunner()
|
stopRunner()
|
||||||
changeState(State.STOPPED)
|
config = null
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
killProcesses()
|
if (config != null) {
|
||||||
|
|
||||||
var resolved: Boolean = false
|
killProcesses()
|
||||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
|
||||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
var resolved: Boolean = false
|
||||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||||
case Some(a) =>
|
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||||
config.proxy = a
|
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||||
resolved = true
|
case Some(a) =>
|
||||||
case None => resolved = false
|
config.proxy = a
|
||||||
|
resolved = true
|
||||||
|
case None => resolved = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolved = true
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
resolved = true
|
|
||||||
}
|
|
||||||
|
|
||||||
hasRedirectSupport = Utils.getHasRedirectSupport
|
hasRedirectSupport = Utils.getHasRedirectSupport
|
||||||
|
|
||||||
if (resolved && handleConnection) {
|
if (resolved && handleConnection) {
|
||||||
notifyForegroundAlert(getString(R.string.forward_success),
|
notifyForegroundAlert(getString(R.string.forward_success),
|
||||||
getString(R.string.service_running).format(config.profileName))
|
getString(R.string.service_running).format(config.profileName))
|
||||||
changeState(State.CONNECTED)
|
changeState(State.CONNECTED)
|
||||||
} else {
|
} else {
|
||||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||||
stopRunner()
|
stopRunner()
|
||||||
changeState(State.STOPPED)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,6 +557,7 @@ class ShadowsocksNatService extends Service with BaseService {
|
|||||||
unregisterReceiver(receiver)
|
unregisterReceiver(receiver)
|
||||||
receiver = null
|
receiver = null
|
||||||
}
|
}
|
||||||
|
|
||||||
stopForegroundCompat(1)
|
stopForegroundCompat(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,12 +80,17 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
||||||
@@ -214,18 +219,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
def notifyAlert(title: String, info: String) {
|
|
||||||
val builder = new NotificationCompat.Builder(this)
|
|
||||||
builder
|
|
||||||
.setSmallIcon(R.drawable.ic_stat_shadowsocks)
|
|
||||||
.setWhen(0)
|
|
||||||
.setTicker(title)
|
|
||||||
.setContentTitle(getString(R.string.app_name))
|
|
||||||
.setContentText(info)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
notificationManager.notify(1, builder.build)
|
|
||||||
}
|
|
||||||
|
|
||||||
override def onBind(intent: Intent): IBinder = {
|
override def onBind(intent: Intent): IBinder = {
|
||||||
val action = intent.getAction
|
val action = intent.getAction
|
||||||
if (VpnService.SERVICE_INTERFACE == action) {
|
if (VpnService.SERVICE_INTERFACE == action) {
|
||||||
@@ -297,36 +290,37 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
|||||||
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
||||||
} catch {
|
} catch {
|
||||||
case ex: Exception =>
|
case ex: Exception =>
|
||||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||||
stopRunner()
|
stopRunner()
|
||||||
changeState(State.STOPPED)
|
config = null
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the context
|
if (config != null) {
|
||||||
killProcesses()
|
|
||||||
|
|
||||||
// Resolve the server address
|
// reset the context
|
||||||
var resolved: Boolean = false
|
killProcesses()
|
||||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
|
||||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
// Resolve the server address
|
||||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
var resolved: Boolean = false
|
||||||
case Some(addr) =>
|
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||||
config.proxy = addr
|
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||||
resolved = true
|
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||||
case None => resolved = false
|
case Some(addr) =>
|
||||||
|
config.proxy = addr
|
||||||
|
resolved = true
|
||||||
|
case None => resolved = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolved = true
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
resolved = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resolved && handleConnection) {
|
if (resolved && handleConnection) {
|
||||||
changeState(State.CONNECTED)
|
changeState(State.CONNECTED)
|
||||||
} else {
|
} else {
|
||||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||||
changeState(State.STOPPED)
|
stopRunner()
|
||||||
stopRunner()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,9 +356,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
|||||||
unregisterReceiver(receiver)
|
unregisterReceiver(receiver)
|
||||||
receiver = null
|
receiver = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset notifications
|
|
||||||
notificationManager.cancel(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override def stopBackgroundService() {
|
override def stopBackgroundService() {
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ object Console {
|
|||||||
.open(new OnCommandResultListener {
|
.open(new OnCommandResultListener {
|
||||||
override def onCommandResult(commandCode: Int, exitCode: Int,
|
override def onCommandResult(commandCode: Int, exitCode: Int,
|
||||||
output: util.List[String]) {
|
output: util.List[String]) {
|
||||||
if (exitCode < 0) shell = null
|
if (exitCode < 0) {
|
||||||
|
shell.close()
|
||||||
|
shell = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -82,8 +85,9 @@ object Console {
|
|||||||
if (shell == null) {
|
if (shell == null) {
|
||||||
openShell()
|
openShell()
|
||||||
}
|
}
|
||||||
shell.addCommand(commands)
|
val ts = shell
|
||||||
shell.waitForIdle()
|
ts.addCommand(commands)
|
||||||
|
ts.waitForIdle()
|
||||||
}
|
}
|
||||||
|
|
||||||
def runRootCommand(command: String): String = runRootCommand(Array(command))
|
def runRootCommand(command: String): String = runRootCommand(Array(command))
|
||||||
@@ -95,11 +99,13 @@ object Console {
|
|||||||
if (rootShell == null) {
|
if (rootShell == null) {
|
||||||
openRootShell()
|
openRootShell()
|
||||||
}
|
}
|
||||||
|
val ts = rootShell
|
||||||
val sb = new StringBuilder
|
val sb = new StringBuilder
|
||||||
rootShell.addCommand(commands, 0, new OnCommandResultListener {
|
ts.addCommand(commands, 0, new OnCommandResultListener {
|
||||||
override def onCommandResult(commandCode: Int, exitCode: Int,
|
override def onCommandResult(commandCode: Int, exitCode: Int,
|
||||||
output: util.List[String]) {
|
output: util.List[String]) {
|
||||||
if (exitCode < 0) {
|
if (exitCode < 0) {
|
||||||
|
rootShell.close()
|
||||||
rootShell = null
|
rootShell = null
|
||||||
} else {
|
} else {
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
@@ -107,7 +113,7 @@ object Console {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (rootShell.waitForIdle()) sb.toString()
|
if (ts.waitForIdle()) sb.toString()
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user