mirror of https://github.com/hykilpikonna/AquaDX
[+] AimeDB register when not found
parent
d4d3a2b36c
commit
72181e7ef7
|
@ -42,7 +42,7 @@ class AllNetClient(val dns: String, val keychip: String, val game: String, val v
|
|||
?: throw Exception("PowerOn Failed: No game URL returned")
|
||||
}
|
||||
|
||||
val userId by lazy { aime.execLookup(card) }
|
||||
val userId by lazy { aime.execLookupOrRegister(card) }
|
||||
|
||||
fun findDataBroker(log: (String) -> Unit) = when (game) {
|
||||
"SDHD" -> ChusanDataBroker(this, log)
|
||||
|
|
|
@ -36,10 +36,22 @@ abstract class DataBroker(
|
|||
throw Exception("Failed to get $this")
|
||||
}
|
||||
|
||||
fun prePull(): Pair<Map<String, Long>, MutableMap<String, Long>> {
|
||||
log("Game URL: ${allNet.gameUrl}")
|
||||
log("User ID: ${allNet.userId}")
|
||||
|
||||
val userId = mapOf("userId" to allNet.userId)
|
||||
val paged = userId + mapOf("nextIndex" to 0, "maxCount" to 10000000)
|
||||
return userId to paged
|
||||
}
|
||||
|
||||
abstract fun pull(): String
|
||||
fun push(data: String) {
|
||||
log("Pushing data")
|
||||
"UpsertUserAll".request().postZ(data).bodyMaybeZ().also { log(it) }
|
||||
"$url/UpsertUserAllApi".request().postZ(mapper.write(mapOf(
|
||||
"userId" to allNet.userId,
|
||||
"upsertUserAll" to data.jsonMap()
|
||||
))).bodyMaybeZ().also { log(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,11 +63,7 @@ class ChusanDataBroker(allNet: AllNetClient, log: (String) -> Unit): DataBroker(
|
|||
class UserMusicWrapper(var userMusicDetailList: List<UserMusicDetail>)
|
||||
|
||||
override fun pull(): String {
|
||||
log("Game URL: ${allNet.gameUrl}")
|
||||
log("User ID: ${allNet.userId}")
|
||||
|
||||
val userId = mapOf("userId" to allNet.userId)
|
||||
val paged = userId + mapOf("nextIndex" to 0, "maxCount" to 10000000)
|
||||
val (userId, paged) = prePull()
|
||||
|
||||
return mapper.write(Chu3UserAll().apply {
|
||||
userData = ls("GetUserDataApi".get("userData", userId))
|
||||
|
@ -90,11 +98,7 @@ class MaimaiDataBroker(allNet: AllNetClient, log: (String) -> Unit): DataBroker(
|
|||
class UserMusicWrapper(var userMusicDetailList: List<Mai2UserMusicDetail>)
|
||||
|
||||
override fun pull(): String {
|
||||
log("Game URL: ${allNet.gameUrl}")
|
||||
log("User ID: ${allNet.userId}")
|
||||
|
||||
val userId = mapOf("userId" to allNet.userId)
|
||||
val paged = userId + mapOf("nextIndex" to 0, "maxCount" to 10000000)
|
||||
val (userId, paged) = prePull()
|
||||
|
||||
return Mai2UserAll().apply {
|
||||
userData = ls("GetUserDataApi".get("userData", userId))
|
||||
|
|
|
@ -58,16 +58,31 @@ class AimeDbClient(val gameId: String, val keychipShort: String, val server: Str
|
|||
writeIntLE(0) // 0C 4b: Serial number
|
||||
}
|
||||
|
||||
fun sendAimePacket(buf: ByteBuf): ByteBuf =
|
||||
fun send(buf: ByteBuf): ByteBuf =
|
||||
Unpooled.wrappedBuffer(Socket(server, 22345).use {
|
||||
it.getOutputStream().write(buf.array())
|
||||
it.getInputStream().readBytes()
|
||||
}).let { AimeDbEncryption.decrypt(it) }
|
||||
|
||||
fun execLookup(card: String) =
|
||||
sendAimePacket(when (card.length) {
|
||||
send(when (card.length) {
|
||||
20 -> createReqLookupV2(card)
|
||||
16 -> createReqFelicaLookupV2(card)
|
||||
else -> throw Exception("Invalid card. Please input either 20-digit numeric access code (e.g. 5010000...0) or 16-digit hex Felica ID (e.g. 012E123456789ABC).")
|
||||
}).getLongLE(0x20)
|
||||
}).getUnsignedIntLE(0x20).let {
|
||||
if (it == 0xffffffff) -1L else it
|
||||
}
|
||||
|
||||
fun execRegister(card: String) =
|
||||
when (card.length) {
|
||||
20 -> card
|
||||
16 -> ByteBufUtil.hexDump(send(createReqFelicaLookupV2(card)).slice(0x2c, 10))
|
||||
else -> throw Exception("Invalid card. Please input a 20-digit numeric access code (e.g. 5010000...0).")
|
||||
}.let { send(createReqRegister(it)).getUnsignedIntLE(0x20) }
|
||||
|
||||
fun execLookupOrRegister(card: String) =
|
||||
execLookup(card).let {
|
||||
if (it == -1L) execRegister(card)
|
||||
else it
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue