mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Починка автообновления лаунчера.
This commit is contained in:
parent
abc990bded
commit
af421c3e96
2 changed files with 25 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import pro.gravit.launcher.serialize.signed.DigestBytesHolder;
|
import pro.gravit.launcher.serialize.signed.DigestBytesHolder;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
|
@ -40,9 +41,17 @@ public void init() {
|
||||||
|
|
||||||
public final boolean sync() throws IOException {
|
public final boolean sync() throws IOException {
|
||||||
boolean exists = exists();
|
boolean exists = exists();
|
||||||
|
if (sign != null)
|
||||||
|
CommonHelper.removeExc(sign);
|
||||||
|
if (binary != null) {
|
||||||
|
CommonHelper.removeExc(binary.getBytes());
|
||||||
|
CommonHelper.removeExc(binary.getDigest());
|
||||||
|
}
|
||||||
binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null;
|
binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null;
|
||||||
sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null;
|
sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null;
|
||||||
|
CommonHelper.addExc(sign);
|
||||||
|
CommonHelper.addExc(binary.getBytes());
|
||||||
|
CommonHelper.addExc(binary.getDigest());
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -140,10 +142,21 @@ public static GsonBuilder newBuilder() {
|
||||||
ByteArrayToBase64TypeAdapter.INSTANCE);
|
ByteArrayToBase64TypeAdapter.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addExc(byte[] exclusion) {
|
||||||
|
JsonArray add = new JsonArray(exclusion.length);
|
||||||
|
for (byte b : exclusion) add.add(new JsonPrimitive(b));
|
||||||
|
ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeExc(byte[] exclusion) {
|
||||||
|
ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion);
|
||||||
|
}
|
||||||
|
|
||||||
private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
|
private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
|
||||||
private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter();
|
private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter();
|
||||||
private Base64.Decoder decoder = Base64.getUrlDecoder();
|
private static final Map<byte[], JsonArray> exclusions = new ConcurrentHashMap<>();
|
||||||
private Base64.Encoder encoder = Base64.getUrlEncoder();
|
private final Base64.Decoder decoder = Base64.getUrlDecoder();
|
||||||
|
private final Base64.Encoder encoder = Base64.getUrlEncoder();
|
||||||
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (json.isJsonArray()) {
|
if (json.isJsonArray()) {
|
||||||
JsonArray byteArr = json.getAsJsonArray();
|
JsonArray byteArr = json.getAsJsonArray();
|
||||||
|
|
Loading…
Reference in a new issue