forked from Cookies_Github_mirror/AquaDX
[O] Reduce duplicate code
This commit is contained in:
@@ -6,7 +6,7 @@ import icu.samnyan.aqua.sega.allnet.model.response.DownloadOrderResponse;
|
||||
import icu.samnyan.aqua.sega.allnet.model.response.PowerOnResponse;
|
||||
import icu.samnyan.aqua.sega.allnet.model.response.PowerOnResponseV2;
|
||||
import icu.samnyan.aqua.sega.allnet.model.response.PowerOnResponseV3;
|
||||
import icu.samnyan.aqua.sega.allnet.util.Decoder;
|
||||
import icu.samnyan.aqua.sega.util.Decoder;
|
||||
import icu.samnyan.aqua.sega.allnet.util.KeychipChecker;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -80,7 +80,7 @@ public class AllNetController {
|
||||
public String downloadOrder(InputStream dataStream, HttpServletRequest req) throws IOException {
|
||||
|
||||
byte[] bytes = dataStream.readAllBytes();
|
||||
Map<String, String> reqMap = Decoder.decode(bytes);
|
||||
Map<String, String> reqMap = Decoder.decodeAllNet(bytes);
|
||||
|
||||
logger.info("Request: DownloadOrder, " + mapper.writeValueAsString(reqMap));
|
||||
|
||||
@@ -98,7 +98,7 @@ public class AllNetController {
|
||||
String localAddr = req.getLocalAddr();
|
||||
String localPort = Integer.toString(req.getLocalPort());
|
||||
byte[] bytes = dataStream.readAllBytes();
|
||||
Map<String, String> reqMap = Decoder.decode(bytes);
|
||||
Map<String, String> reqMap = Decoder.decodeAllNet(bytes);
|
||||
String serial = reqMap.getOrDefault("serial", "");
|
||||
logger.info("Request: PowerOn, " + mapper.writeValueAsString(reqMap));
|
||||
// TODO: Verify KeyChip id ?
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.allnet.util;
|
||||
|
||||
import icu.samnyan.aqua.sega.util.Compression;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class Decoder {
|
||||
|
||||
public static Map<String, String> decode(byte[] src) {
|
||||
byte[] bytes = Base64.getMimeDecoder().decode(src);
|
||||
|
||||
|
||||
byte[] output = Compression.decompress(bytes);
|
||||
|
||||
String outputString = new String(output, StandardCharsets.UTF_8).trim();
|
||||
String[] split = outputString.split("&");
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
for (String s :
|
||||
split) {
|
||||
String[] kv = s.split("=");
|
||||
resultMap.put(kv[0], kv[1]);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user