Commit f1e1acbe authored by liusheng's avatar liusheng

Merge branch 'cc-dev' into 11a-dev

parents f7f175ee 0cd2a157
...@@ -199,6 +199,9 @@ object AcceleratorUtils { ...@@ -199,6 +199,9 @@ object AcceleratorUtils {
override fun stateChanged(state: BaseService.State, profileName: String?, msg: String?) { override fun stateChanged(state: BaseService.State, profileName: String?, msg: String?) {
AcceleratorUtils.state = state AcceleratorUtils.state = state
stateListener(state, getAccTime(), null) stateListener(state, getAccTime(), null)
if (state == BaseService.State.Stopped && !msg.isNullOrBlank()) {
ToastUtils.show(msg)
}
} }
override fun onServiceConnected(service: IShadowsocksService) { override fun onServiceConnected(service: IShadowsocksService) {
......
...@@ -21,6 +21,7 @@ import okhttp3.RequestBody.Companion.toRequestBody ...@@ -21,6 +21,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response import okhttp3.Response
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import java.io.IOException
import java.security.SecureRandom import java.security.SecureRandom
import java.security.cert.X509Certificate import java.security.cert.X509Certificate
import java.util.concurrent.Executors import java.util.concurrent.Executors
...@@ -83,6 +84,8 @@ object AuthManager { ...@@ -83,6 +84,8 @@ object AuthManager {
MMKV.defaultMMKV().putLong("LAST_ACC_TIME", last_acc_time) MMKV.defaultMMKV().putLong("LAST_ACC_TIME", last_acc_time)
} }
class AuthException(msg: String) : IOException(msg), BaseService.ExpectedException
suspend fun initAuthProfile(profile: Profile) { suspend fun initAuthProfile(profile: Profile) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
getLineConfig()?.let { getLineConfig()?.let {
......
...@@ -124,7 +124,14 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C ...@@ -124,7 +124,14 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C
) { ) {
Guard(cmdSupplier).apply { Guard(cmdSupplier).apply {
launch { launch {
try {
start() // if start fails, IOException will be thrown directly start() // if start fails, IOException will be thrown directly
} catch (ex: Throwable) {
if (ex is AuthManager.AuthException) {
onFatal(ex)
return@launch
}
}
looper(onRestartCallback) looper(onRestartCallback)
} }
} }
......
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