diff --git a/xposed/src/main/java/kritor/server/KritorServer.kt b/xposed/src/main/java/kritor/server/KritorServer.kt index 7aab8e0..a568247 100644 --- a/xposed/src/main/java/kritor/server/KritorServer.kt +++ b/xposed/src/main/java/kritor/server/KritorServer.kt @@ -1,6 +1,8 @@ @file:OptIn(ExperimentalCoroutinesApi::class) package kritor.server +import io.grpc.Grpc +import io.grpc.InsecureServerCredentials import io.grpc.ServerBuilder import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -13,8 +15,7 @@ import kotlin.coroutines.CoroutineContext class KritorServer( private val port: Int ): CoroutineScope { - private val server = ServerBuilder - .forPort(port) + private val server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create()) .addService(Authentication) .build()!! diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/config/ShamrockConfig.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/config/ShamrockConfig.kt index 730a00d..ee27847 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/config/ShamrockConfig.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/config/ShamrockConfig.kt @@ -14,6 +14,7 @@ private val configFile = configDir.resolve("config.prop") private val configKeys = setOf( ActiveRPC, + AntiJvmTrace, ForceTablet, PassiveRPC, ResourceGroup, diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/xposed/actions/InitRemoteService.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/xposed/actions/InitRemoteService.kt index 6d7773d..0be7f92 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/xposed/actions/InitRemoteService.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/xposed/actions/InitRemoteService.kt @@ -11,6 +11,8 @@ import moe.fuqiuluo.shamrock.config.ActiveRPC import moe.fuqiuluo.shamrock.config.RPCPort import moe.fuqiuluo.shamrock.config.ShamrockConfig import moe.fuqiuluo.shamrock.config.get +import moe.fuqiuluo.shamrock.helper.Level +import moe.fuqiuluo.shamrock.helper.LogCenter import moe.fuqiuluo.symbols.Process import moe.fuqiuluo.symbols.XposedHook @@ -20,9 +22,19 @@ private lateinit var server: KritorServer internal class InitRemoteService : IAction { override fun invoke(ctx: Context) { GlobalScope.launch { - if (ActiveRPC.get() && !::server.isInitialized) { - server = KritorServer(RPCPort.get()) - server.start() + runCatching { + if (ActiveRPC.get()) { + if (!::server.isInitialized) { + server = KritorServer(RPCPort.get()) + server.start() + } + } else { + LogCenter.log("ActiveRPC is disabled, KritorServer will not be started.") + } + + + }.onFailure { + LogCenter.log("Start RPC failed: ${it.message}", Level.ERROR) } } } diff --git a/xposed/src/main/java/qq/service/internals/MSFHandler.kt b/xposed/src/main/java/qq/service/internals/MSFHandler.kt index a00271b..7883266 100644 --- a/xposed/src/main/java/qq/service/internals/MSFHandler.kt +++ b/xposed/src/main/java/qq/service/internals/MSFHandler.kt @@ -48,7 +48,7 @@ internal object MSFHandler { fun onResp(toServiceMsg: ToServiceMsg, fromServiceMsg: FromServiceMsg) { runCatching { - val cmd = toServiceMsg.getAttribute("__respkey") as? Int? + val cmd = toServiceMsg.getAttribute("shamrock_uid") as? Int? ?: return@runCatching val resp = mRespHandler[cmd] resp?.invoke(toServiceMsg, fromServiceMsg)