diff --git a/processor/src/main/java/moe/fuqiuluo/ksp/impl/GrpcProcessor.kt b/processor/src/main/java/moe/fuqiuluo/ksp/impl/GrpcProcessor.kt index adb69ec2..bc80b182 100644 --- a/processor/src/main/java/moe/fuqiuluo/ksp/impl/GrpcProcessor.kt +++ b/processor/src/main/java/moe/fuqiuluo/ksp/impl/GrpcProcessor.kt @@ -30,8 +30,6 @@ class GrpcProcessor( private val codeGenerator: CodeGenerator, private val logger: KSPLogger ): SymbolProcessor { - private val subPackage = arrayOf("contact", "core", "file", "friend", "group", "message", "web") - override fun process(resolver: Resolver): List { val symbols = resolver.getSymbolsWithAnnotation(Grpc::class.qualifiedName!!) val actions = (symbols as Sequence).toList() @@ -77,6 +75,7 @@ class GrpcProcessor( .addStatement("import io.kritor.file.*") .addStatement("import io.kritor.message.*") .addStatement("import io.kritor.web.*") + .addStatement("import io.kritor.developer.*") .addFunction(funcBuilder.build()) .addImport("moe.fuqiuluo.symbols", "EMPTY_BYTE_ARRAY") runCatching { diff --git a/xposed/src/main/java/kritor/server/KritorServer.kt b/xposed/src/main/java/kritor/server/KritorServer.kt index c073ea8a..990c7d4f 100644 --- a/xposed/src/main/java/kritor/server/KritorServer.kt +++ b/xposed/src/main/java/kritor/server/KritorServer.kt @@ -28,6 +28,7 @@ class KritorServer( .addService(EventService) .addService(ForwardMessageService) .addService(WebService) + .addService(DeveloperService) .build()!! fun start(block: Boolean = false) { diff --git a/xposed/src/main/java/kritor/service/Authentication.kt b/xposed/src/main/java/kritor/service/Authentication.kt index d0def442..20aac7ae 100644 --- a/xposed/src/main/java/kritor/service/Authentication.kt +++ b/xposed/src/main/java/kritor/service/Authentication.kt @@ -15,7 +15,7 @@ import moe.fuqiuluo.shamrock.config.ActiveTicket import moe.fuqiuluo.shamrock.config.ShamrockConfig import qq.service.QQInterfaces -object Authentication: AuthenticationGrpcKt.AuthenticationCoroutineImplBase() { +internal object Authentication: AuthenticationGrpcKt.AuthenticationCoroutineImplBase() { @Grpc("Authentication", "Auth") override suspend fun auth(request: AuthReq): AuthRsp { if (QQInterfaces.app.account != request.account) { diff --git a/xposed/src/main/java/kritor/service/ContactService.kt b/xposed/src/main/java/kritor/service/ContactService.kt index 267fd49c..8dc8de79 100644 --- a/xposed/src/main/java/kritor/service/ContactService.kt +++ b/xposed/src/main/java/kritor/service/ContactService.kt @@ -33,7 +33,7 @@ import qq.service.contact.ContactHelper import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine -object ContactService: ContactServiceGrpcKt.ContactServiceCoroutineImplBase() { +internal object ContactService: ContactServiceGrpcKt.ContactServiceCoroutineImplBase() { @Grpc("ContactService", "VoteUser") override suspend fun voteUser(request: VoteUserRequest): VoteUserResponse { ContactHelper.voteUser(when(request.accountCase!!) { diff --git a/xposed/src/main/java/kritor/service/DeveloperService.kt b/xposed/src/main/java/kritor/service/DeveloperService.kt new file mode 100644 index 00000000..4577fc6d --- /dev/null +++ b/xposed/src/main/java/kritor/service/DeveloperService.kt @@ -0,0 +1,50 @@ +package kritor.service + +import com.google.protobuf.ByteString +import com.tencent.mobileqq.fe.FEKit +import com.tencent.mobileqq.qsec.qsecdandelionsdk.Dandelion +import io.kritor.developer.DeveloperServiceGrpcKt +import io.kritor.developer.EnergyRequest +import io.kritor.developer.EnergyResponse +import io.kritor.developer.SendPacketRequest +import io.kritor.developer.SendPacketResponse +import io.kritor.developer.SignRequest +import io.kritor.developer.SignResponse +import io.kritor.developer.energyResponse +import io.kritor.developer.sendPacketResponse +import io.kritor.developer.signResponse +import qq.service.QQInterfaces + +internal object DeveloperService: DeveloperServiceGrpcKt.DeveloperServiceCoroutineImplBase() { + @Grpc("DeveloperService", "Sign") + override suspend fun sign(request: SignRequest): SignResponse { + return signResponse { + val result = FEKit.getInstance().getSign(request.command, request.buffer.toByteArray(), request.seq, request.uin) + this.sign = ByteString.copyFrom(result.sign) + this.token = ByteString.copyFrom(result.token) + this.extra = ByteString.copyFrom(result.extra) + } + } + + @Grpc("DeveloperService", "Energy") + override suspend fun energy(request: EnergyRequest): EnergyResponse { + return energyResponse { + this.result = ByteString.copyFrom(Dandelion.getInstance().fly(request.data, request.salt.toByteArray())) + } + } + + + @Grpc("DeveloperService", "SendPacket") + override suspend fun sendPacket(request: SendPacketRequest): SendPacketResponse { + return sendPacketResponse { + val fromServiceMsg = QQInterfaces.sendBufferAW(request.command, request.isProtobuf, request.requestBuffer.toByteArray()) + if (fromServiceMsg?.wupBuffer == null) { + this.isSuccess = false + } else { + this.isSuccess = true + this.responseBuffer = ByteString.copyFrom(fromServiceMsg.wupBuffer) + } + } + } + +} \ No newline at end of file diff --git a/xposed/src/main/java/kritor/service/EventService.kt b/xposed/src/main/java/kritor/service/EventService.kt index 826e752e..bededa2d 100644 --- a/xposed/src/main/java/kritor/service/EventService.kt +++ b/xposed/src/main/java/kritor/service/EventService.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.channelFlow import moe.fuqiuluo.shamrock.internals.GlobalEventTransmitter -object EventService: EventServiceGrpcKt.EventServiceCoroutineImplBase() { +internal object EventService: EventServiceGrpcKt.EventServiceCoroutineImplBase() { override fun registerActiveListener(request: RequestPushEvent): Flow { return channelFlow { when(request.type!!) { diff --git a/xposed/src/main/java/kritor/service/FriendService.kt b/xposed/src/main/java/kritor/service/FriendService.kt index 6a2c8625..bd45e4b8 100644 --- a/xposed/src/main/java/kritor/service/FriendService.kt +++ b/xposed/src/main/java/kritor/service/FriendService.kt @@ -11,7 +11,7 @@ import io.kritor.friend.getFriendListResponse import qq.service.contact.ContactHelper import qq.service.friend.FriendHelper -object FriendService: FriendServiceGrpcKt.FriendServiceCoroutineImplBase() { +internal object FriendService: FriendServiceGrpcKt.FriendServiceCoroutineImplBase() { @Grpc("FriendService", "GetFriendList") override suspend fun getFriendList(request: GetFriendListRequest): GetFriendListResponse { val friendList = FriendHelper.getFriendList(if(request.hasRefresh()) request.refresh else false).onFailure { diff --git a/xposed/src/main/java/kritor/service/KritorService.kt b/xposed/src/main/java/kritor/service/KritorService.kt index 2190d3c8..185bc6a7 100644 --- a/xposed/src/main/java/kritor/service/KritorService.kt +++ b/xposed/src/main/java/kritor/service/KritorService.kt @@ -35,7 +35,7 @@ import qq.service.QQInterfaces.Companion.app import qq.service.contact.ContactHelper import java.io.File -object KritorService: KritorServiceGrpcKt.KritorServiceCoroutineImplBase() { +internal object KritorService: KritorServiceGrpcKt.KritorServiceCoroutineImplBase() { @Grpc("KritorService", "GetVersion") override suspend fun getVersion(request: GetVersionRequest): GetVersionResponse { return getVersionResponse {