This commit is contained in:
arm64v8a 2023-07-06 18:23:05 +09:00
parent 060853a204
commit 9454d074ce
2 changed files with 8 additions and 4 deletions

View File

@ -22,7 +22,6 @@ import io.nekohasekai.sagernet.plugin.PluginManager
import kotlinx.coroutines.* import kotlinx.coroutines.*
import libcore.BoxInstance import libcore.BoxInstance
import libcore.Libcore import libcore.Libcore
import moe.matsuri.nb4a.net.LocalResolverImpl
import moe.matsuri.nb4a.plugin.NekoPluginManager import moe.matsuri.nb4a.plugin.NekoPluginManager
import moe.matsuri.nb4a.proxy.neko.NekoBean import moe.matsuri.nb4a.proxy.neko.NekoBean
import moe.matsuri.nb4a.proxy.neko.NekoJSInterface import moe.matsuri.nb4a.proxy.neko.NekoJSInterface
@ -112,7 +111,6 @@ abstract class BoxInstance(
} }
} }
} }
Libcore.registerLocalDNSTransport(LocalResolverImpl)
loadConfig() loadConfig()
} }
@ -279,8 +277,6 @@ abstract class BoxInstance(
if (::box.isInitialized) { if (::box.isInitialized) {
box.close() box.close()
} }
Libcore.registerLocalDNSTransport(null)
} }
} }

View File

@ -7,6 +7,8 @@ import io.nekohasekai.sagernet.database.ProxyEntity
import io.nekohasekai.sagernet.ktx.Logs import io.nekohasekai.sagernet.ktx.Logs
import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import libcore.Libcore
import moe.matsuri.nb4a.net.LocalResolverImpl
import moe.matsuri.nb4a.utils.JavaUtil import moe.matsuri.nb4a.utils.JavaUtil
class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? = null) : 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() { override fun launch() {
box.setAsMain() box.setAsMain()
super.launch() // start box super.launch() // start box
@ -52,6 +59,7 @@ class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? =
} }
override fun close() { override fun close() {
Libcore.registerLocalDNSTransport(null)
super.close() super.close()
runBlocking { runBlocking {
looper?.stop() looper?.stop()