Add workaround for golang/go#68760

This commit is contained in:
世界 2024-12-10 10:12:30 +08:00
parent 64765ccba2
commit 72e3014ee6
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -4,6 +4,10 @@ import android.net.Network
import android.os.Build import android.os.Build
import io.nekohasekai.libbox.InterfaceUpdateListener import io.nekohasekai.libbox.InterfaceUpdateListener
import io.nekohasekai.sfa.Application import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.BuildConfig
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.net.NetworkInterface import java.net.NetworkInterface
object DefaultNetworkMonitor { object DefaultNetworkMonitor {
@ -55,12 +59,25 @@ object DefaultNetworkMonitor {
Thread.sleep(100) Thread.sleep(100)
continue continue
} }
listener.updateDefaultInterface(interfaceName, interfaceIndex) // TODO: remove launch after fixed
// https://github.com/golang/go/issues/68760
if (BuildConfig.DEBUG) {
GlobalScope.launch(Dispatchers.IO) {
listener.updateDefaultInterface(interfaceName, interfaceIndex)
}
} else {
listener.updateDefaultInterface(interfaceName, interfaceIndex)
}
} }
} else { } else {
listener.updateDefaultInterface("", -1) if (BuildConfig.DEBUG) {
GlobalScope.launch(Dispatchers.IO) {
listener.updateDefaultInterface("", -1)
}
} else {
listener.updateDefaultInterface("", -1)
}
} }
} }
} }