diff --git a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt index ef16df5..f94d168 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt @@ -22,7 +22,6 @@ import io.nekohasekai.sagernet.plugin.PluginManager import kotlinx.coroutines.* import libcore.BoxInstance import libcore.Libcore -import moe.matsuri.nb4a.net.LocalResolverImpl import moe.matsuri.nb4a.plugin.NekoPluginManager import moe.matsuri.nb4a.proxy.neko.NekoBean import moe.matsuri.nb4a.proxy.neko.NekoJSInterface @@ -112,7 +111,6 @@ abstract class BoxInstance( } } } - Libcore.registerLocalDNSTransport(LocalResolverImpl) loadConfig() } @@ -279,8 +277,6 @@ abstract class BoxInstance( if (::box.isInitialized) { box.close() } - - Libcore.registerLocalDNSTransport(null) } } \ No newline at end of file diff --git a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt index 23fd25e..293c657 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt @@ -7,6 +7,8 @@ import io.nekohasekai.sagernet.database.ProxyEntity import io.nekohasekai.sagernet.ktx.Logs import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher import kotlinx.coroutines.runBlocking +import libcore.Libcore +import moe.matsuri.nb4a.net.LocalResolverImpl import moe.matsuri.nb4a.utils.JavaUtil class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? = null) : @@ -42,6 +44,11 @@ class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? = } } + override suspend fun loadConfig() { + Libcore.registerLocalDNSTransport(LocalResolverImpl) + super.loadConfig() + } + override fun launch() { box.setAsMain() super.launch() // start box @@ -52,6 +59,7 @@ class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? = } override fun close() { + Libcore.registerLocalDNSTransport(null) super.close() runBlocking { looper?.stop()