updated redirect hint and fix anr for redirect port
This commit is contained in:
@@ -20,8 +20,8 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import sh.sar.textpipe.MainActivity
|
||||
import sh.sar.textpipe.TextpipeApplication
|
||||
import sh.sar.textpipe.data.repository.SmsRepository
|
||||
@@ -124,7 +124,7 @@ class TextpipeService : Service() {
|
||||
val port = getConfiguredPort(this)
|
||||
_serverPort.value = port
|
||||
|
||||
serviceScope.launch {
|
||||
serviceScope.launch(Dispatchers.IO) {
|
||||
// Setup port redirect if configured
|
||||
redirectPort = getRedirectPort(this@TextpipeService)
|
||||
if (redirectPort > 0 && redirectPort != port) {
|
||||
@@ -164,10 +164,11 @@ class TextpipeService : Service() {
|
||||
override fun onDestroy() {
|
||||
Log.i(TAG, "Service onDestroy")
|
||||
|
||||
// Clear port redirect synchronously before stopping
|
||||
// Clear port redirect asynchronously (fire and forget to avoid ANR)
|
||||
if (redirectPort > 0) {
|
||||
runBlocking {
|
||||
RootManager.clearPortRedirect(redirectPort, textpipeServer?.getPort() ?: 8080)
|
||||
val port = textpipeServer?.getPort() ?: 8080
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
RootManager.clearPortRedirect(redirectPort, port)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ private fun PortConfigCard(
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Traffic on redirect port will be forwarded to server port via iptables",
|
||||
text = "Ports below 1024 (like 80, 443) require root. Uses iptables to redirect traffic to server port.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
|
||||
Reference in New Issue
Block a user