Commit 5b3d472d authored by Mygod's avatar Mygod

Refine code style

parent 56fc89f1
...@@ -92,6 +92,7 @@ class GuardedProcessPool(private val onFatal: (IOException) -> Unit) : Coroutine ...@@ -92,6 +92,7 @@ class GuardedProcessPool(private val onFatal: (IOException) -> Unit) : Coroutine
GlobalScope.launch(Dispatchers.Main) { onFatal(e) } GlobalScope.launch(Dispatchers.Main) { onFatal(e) }
} finally { } finally {
abortChannel.close() abortChannel.close()
}
if (!running) return // process already exited, nothing to be done if (!running) return // process already exited, nothing to be done
if (Build.VERSION.SDK_INT < 24) { if (Build.VERSION.SDK_INT < 24) {
try { try {
...@@ -109,7 +110,6 @@ class GuardedProcessPool(private val onFatal: (IOException) -> Unit) : Coroutine ...@@ -109,7 +110,6 @@ class GuardedProcessPool(private val onFatal: (IOException) -> Unit) : Coroutine
exitChannel.receive() exitChannel.receive()
} }
} }
}
private val supervisor = SupervisorJob() private val supervisor = SupervisorJob()
override val coroutineContext get() = Dispatchers.Main + supervisor override val coroutineContext get() = Dispatchers.Main + supervisor
......
...@@ -64,7 +64,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro ...@@ -64,7 +64,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
withTimeout(30_000) { withTimeout(30_000) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
conn.outputStream.bufferedWriter().use { conn.outputStream.bufferedWriter().use {
it.write("sig=" + String(Base64.encode(mdg.digest(), Base64.DEFAULT))) it.write("sig=" + Base64.encodeToString(mdg.digest(), Base64.DEFAULT))
} }
conn.inputStream.bufferedReader().readText() conn.inputStream.bufferedReader().readText()
} }
......
...@@ -238,7 +238,7 @@ class Profile : Serializable { ...@@ -238,7 +238,7 @@ class Profile : Serializable {
val builder = Uri.Builder() val builder = Uri.Builder()
.scheme("ss") .scheme("ss")
.encodedAuthority("%s@%s:%d".format(Locale.ENGLISH, .encodedAuthority("%s@%s:%d".format(Locale.ENGLISH,
Base64.encodeToString("%s:%s".format(Locale.ENGLISH, method, password).toByteArray(), Base64.encodeToString("$method:$password".toByteArray(),
Base64.NO_PADDING or Base64.NO_WRAP or Base64.URL_SAFE), Base64.NO_PADDING or Base64.NO_WRAP or Base64.URL_SAFE),
if (host.contains(':')) "[$host]" else host, remotePort)) if (host.contains(':')) "[$host]" else host, remotePort))
val configuration = PluginConfiguration(plugin ?: "") val configuration = PluginConfiguration(plugin ?: "")
......
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