forked from Cookies_Github_mirror/AquaDX
[F] Fix DFI response compat
This commit is contained in:
@@ -2,7 +2,7 @@ package icu.samnyan.aqua.sega.allnet
|
||||
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaNetUserRepo
|
||||
import icu.samnyan.aqua.sega.util.AllNetBillingDecoder.decodeAllNet
|
||||
import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder.decodeAllNet
|
||||
import icu.samnyan.aqua.sega.util.AquaConst
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import jakarta.servlet.http.HttpServletResponse
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.util
|
||||
package icu.samnyan.aqua.sega.allnet
|
||||
|
||||
import ext.bodyString
|
||||
import ext.header
|
||||
import icu.samnyan.aqua.sega.util.ZLib
|
||||
import java.net.http.HttpResponse
|
||||
import java.util.*
|
||||
import kotlin.text.Charsets.UTF_8
|
||||
|
||||
object AllNetBillingDecoder {
|
||||
fun String.urlToMap() = split("&").map { it.split("=") }.filter { it.size == 2 }.associate { it[0] to it[1] }
|
||||
|
||||
/**
|
||||
* Decode the input byte array from Base64 MIME encoding and decompress the decoded byte array
|
||||
*/
|
||||
@@ -15,10 +21,7 @@ object AllNetBillingDecoder {
|
||||
val output = ZLib.decompress(bytes, nowrap).toString(UTF_8).trim()
|
||||
|
||||
// Split the string by '&' symbol to separate key-value pairs
|
||||
return output.split("&").associate {
|
||||
val (key, value) = it.split("=")
|
||||
key to value
|
||||
}
|
||||
return output.urlToMap()
|
||||
}
|
||||
|
||||
fun encode(src: Map<String, String>, base64: Boolean): ByteArray {
|
||||
@@ -29,7 +32,7 @@ object AllNetBillingDecoder {
|
||||
val bytes = ZLib.compress(output.toByteArray(UTF_8))
|
||||
|
||||
// Encode the compressed byte array to Base64 MIME encoding
|
||||
return if (!base64) bytes else Base64.getMimeEncoder().encode(bytes)
|
||||
return if (!base64) bytes else Base64.getEncoder().encode(bytes)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -38,4 +41,10 @@ object AllNetBillingDecoder {
|
||||
|
||||
@JvmStatic
|
||||
fun decodeBilling(src: ByteArray) = decode(src, base64 = false, nowrap = true)
|
||||
|
||||
fun HttpResponse<ByteArray>.decodeAllNetResp() =
|
||||
if (header("Pragma") == "DFI") decodeAllNet(body())
|
||||
else bodyString()?.urlToMap()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package icu.samnyan.aqua.sega.billing
|
||||
|
||||
import ext.logger
|
||||
import ext.toUrl
|
||||
import icu.samnyan.aqua.sega.util.AllNetBillingDecoder.decodeBilling
|
||||
import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder.decodeBilling
|
||||
import jakarta.annotation.PostConstruct
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import org.eclipse.jetty.http.HttpVersion
|
||||
|
||||
Reference in New Issue
Block a user