Merge branch 'broker' into v1-dev

This commit is contained in:
Azalea
2025-03-21 19:47:35 -04:00
49 changed files with 528 additions and 153 deletions

View File

@@ -5,18 +5,19 @@ import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.time.Duration
val client = HttpClient.newBuilder().build()
fun HttpRequest.Builder.send() = client.send(this.build(), HttpResponse.BodyHandlers.ofByteArray())
fun HttpRequest.Builder.header(pair: Pair<Any, Any>) = this.header(pair.first.toString(), pair.second.toString())
fun String.request() = HttpRequest.newBuilder(URI.create(this))
fun String.request() = HttpRequest.newBuilder(URI.create(this)).timeout(Duration.ofSeconds(10))
fun HttpRequest.Builder.post(body: Any? = null) = this.POST(when (body) {
is ByteArray -> HttpRequest.BodyPublishers.ofByteArray(body)
is String -> HttpRequest.BodyPublishers.ofString(body)
is HttpRequest.BodyPublisher -> body
else -> throw Exception("Unsupported body type")
else -> throw IllegalArgumentException("Unsupported body type")
}).send()

View File

@@ -3,6 +3,7 @@ package icu.samnyan.aqua.net.transfer
import ext.header
import ext.post
import ext.request
import java.net.URI
import icu.samnyan.aqua.sega.aimedb.AimeDbClient
import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder
import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder.decodeAllNetResp
@@ -23,7 +24,7 @@ class AllNetClient(val dns: String, val keychip: String, val game: String, val v
if (keychip.length == 11) keychip
else keychip.substring(0, 4) + keychip.substring(5, 12)
}
val aime by lazy { AimeDbClient(game, keychipShort, dns.substringAfter("://").substringBefore(":").substringBefore("/")) }
val aime by lazy { AimeDbClient(game, keychipShort, URI(dns).host) }
// Send AllNet PowerOn request to obtain game URL
val gameUrl by lazy {
@@ -38,9 +39,6 @@ class AllNetClient(val dns: String, val keychip: String, val game: String, val v
"ip" to "127.0.0.1", "firm_ver" to "60001", "boot_ver" to "0000",
"encode" to "UTF-8", "format_ver" to "3", "hops" to "1", "token" to "2864179931"
)))
?.also {
println(it)
}
?.decodeAllNetResp()?.get("uri")
?: throw Exception("PowerOn Failed: No game URL returned")
}