[O] Hash user ids

This commit is contained in:
Azalea
2025-01-16 15:49:16 -05:00
parent 146e4bac0f
commit b17d784d80
5 changed files with 11 additions and 8 deletions

View File

@@ -64,6 +64,7 @@ class FutariLobby(paths: PathProps) {
recruits[d.ip] = RecruitRecord(d.RecruitInfo)
if (!exists) log(d, "StartRecruit")
d.RecruitInfo.MechaInfo.UserIDs = d.RecruitInfo.MechaInfo.UserIDs.map { it.str.hashToUInt().toLong() }
}
@API("recruit/finish")

View File

@@ -11,7 +11,7 @@ data class MechaInfo(
val IpAddress: UInt,
val MusicID: Int,
val Entrys: List<Bool>,
val UserIDs: List<Long>,
var UserIDs: List<Long>,
val UserNames: List<String>,
val IconIDs: List<Int>,
val FumenDifs: List<Int>,

View File

@@ -1,6 +1,7 @@
package icu.samnyan.aqua.sega.maimai2.worldslink
import ext.logger
import ext.md5
import ext.millis
import ext.thread
import java.io.BufferedReader
@@ -10,7 +11,6 @@ import java.io.OutputStreamWriter
import java.net.ServerSocket
import java.net.Socket
import java.net.SocketTimeoutException
import java.security.MessageDigest
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.locks.ReentrantLock
import kotlin.collections.set
@@ -110,14 +110,14 @@ fun ActiveClient.handle(msg: Msg) {
}
}
fun hashStringToUInt(input: String) = MessageDigest.getInstance("MD5").digest(input.toByteArray()).let {
fun String.hashToUInt() = md5().let {
((it[0].toUInt() and 0xFFu) shl 24) or
((it[1].toUInt() and 0xFFu) shl 16) or
((it[2].toUInt() and 0xFFu) shl 8) or
(it[3].toUInt() and 0xFFu)
}
fun keychipToStubIp(keychip: String) = hashStringToUInt(keychip)
fun keychipToStubIp(keychip: String) = keychip.hashToUInt()
// Keychip ID to Socket
val clients = ConcurrentHashMap<UInt, ActiveClient>()

View File

@@ -71,7 +71,7 @@ class WaccaServer {
""""maintNoticeTime":0,"maintNotPlayableTime":0,"maintStartTime":0,"params":$paramsJson}"""
return ResponseEntity.ok().headers(
"X-Wacca-Hash" to resp.md5(),
"X-Wacca-Hash" to resp.md5().hexStr,
"Content-Type" to "application/json; charset=utf-8"
).body(resp)
}