Commit 8657ef87 authored by Mygod's avatar Mygod

Crash recovery for NAT mode

Bugfix: when NAT process is killed, Internet access is gone. Reproduce with:

    adb shell killall com.github.shadowsocks:nat

One circumstance it cannot recover from is when updating to a new version, where both processes are killed at the same time. But a reset will be executed when the new version is launched.
parent da1b4041
...@@ -275,7 +275,7 @@ class Shadowsocks ...@@ -275,7 +275,7 @@ class Shadowsocks
} }
} }
private def crashRecovery() { def crashRecovery() {
val cmd = new ArrayBuffer[String]() val cmd = new ArrayBuffer[String]()
for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks")) { for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks")) {
...@@ -477,7 +477,9 @@ class Shadowsocks ...@@ -477,7 +477,9 @@ class Shadowsocks
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)
} }
def install() { def reset() {
crashRecovery()
copyAssets(System.getABI) copyAssets(System.getABI)
val ab = new ArrayBuffer[String] val ab = new ArrayBuffer[String]
...@@ -487,12 +489,6 @@ class Shadowsocks ...@@ -487,12 +489,6 @@ class Shadowsocks
Console.runCommand(ab.toArray) Console.runCommand(ab.toArray)
} }
def reset() {
crashRecovery()
install()
}
def recovery() { def recovery() {
serviceStop() serviceStop()
val h = showProgress(R.string.recovering) val h = showProgress(R.string.recovering)
......
...@@ -16,6 +16,7 @@ class ShadowsocksDeathRecipient(val mContext: ServiceBoundContext) ...@@ -16,6 +16,7 @@ class ShadowsocksDeathRecipient(val mContext: ServiceBoundContext)
mContext match { mContext match {
case ss: Shadowsocks => case ss: Shadowsocks =>
ss.deattachService ss.deattachService
ss.crashRecovery
ss.attachService ss.attachService
case _ => case _ =>
} }
......
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