mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Фикс найденных багов
This commit is contained in:
parent
c3fd501ef1
commit
b0baf1e1f6
5 changed files with 21 additions and 16 deletions
|
@ -11,18 +11,18 @@
|
|||
import ru.gravit.launchserver.auth.texture.TextureProvider;
|
||||
import ru.gravit.launchserver.components.Component;
|
||||
import ru.gravit.utils.UniversalJsonAdapter;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class LaunchServerGsonManager extends GsonManager {
|
||||
@Override
|
||||
public void registerAdapters(GsonBuilder builder) {
|
||||
super.registerAdapters(builder);
|
||||
Launcher.gsonManager.gsonBuilder = new GsonBuilder();
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(AuthProvider.class, new UniversalJsonAdapter<>(AuthProvider.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(TextureProvider.class, new UniversalJsonAdapter<>(TextureProvider.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(AuthHandler.class, new UniversalJsonAdapter<>(AuthHandler.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(PermissionsHandler.class, new UniversalJsonAdapter<>(PermissionsHandler.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(HWIDHandler.class, new UniversalJsonAdapter<>(HWIDHandler.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers));
|
||||
Launcher.gsonManager.gsonBuilder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers));
|
||||
builder.registerTypeAdapter(AuthProvider.class, new UniversalJsonAdapter<>(AuthProvider.providers));
|
||||
builder.registerTypeAdapter(TextureProvider.class, new UniversalJsonAdapter<>(TextureProvider.providers));
|
||||
builder.registerTypeAdapter(AuthHandler.class, new UniversalJsonAdapter<>(AuthHandler.providers));
|
||||
builder.registerTypeAdapter(PermissionsHandler.class, new UniversalJsonAdapter<>(PermissionsHandler.providers));
|
||||
builder.registerTypeAdapter(HWIDHandler.class, new UniversalJsonAdapter<>(HWIDHandler.providers));
|
||||
builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers));
|
||||
builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,14 +37,14 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, JAR_URL));
|
||||
if (Arrays.equals(bytes, hash)) {
|
||||
client.checkSign = true;
|
||||
service.sendObject(ctx, new LauncherRequestEvent(false, JAR_URL));
|
||||
sendResult(new LauncherRequestEvent(false, JAR_URL));
|
||||
} else {
|
||||
service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, JAR_URL));
|
||||
sendResultAndClose(new LauncherRequestEvent(true, JAR_URL));
|
||||
}
|
||||
} else if (launcher_type == 2) //EXE
|
||||
{
|
||||
byte[] hash = LaunchServer.server.launcherEXEBinary.getBytes().getDigest();
|
||||
if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, EXE_URL));
|
||||
if (hash == null) sendResultAndClose(new LauncherRequestEvent(true, EXE_URL));
|
||||
if (Arrays.equals(bytes, hash)) {
|
||||
client.checkSign = true;
|
||||
sendResult(new LauncherRequestEvent(false, EXE_URL));
|
||||
|
|
|
@ -18,11 +18,14 @@ public void process(ResultInterface result) {
|
|||
{
|
||||
RequestEvent event = (RequestEvent) result;
|
||||
checkUUID = event.requestUUID;
|
||||
if(checkUUID != null)
|
||||
LogHelper.debug("Event UUID: %s found", checkUUID.toString());
|
||||
}
|
||||
for (ResultEvent r : requests) {
|
||||
if( (r.uuid != null && r.uuid.equals(checkUUID)) || ( r.uuid == null && (r.type.equals(result.getType()) || result.getType().equals("error") )) ) {
|
||||
if(r.uuid != null)
|
||||
LogHelper.debug("Request UUID found: %s", r.uuid.toString());
|
||||
if( (r.uuid != null && r.uuid.equals(checkUUID)) || ( checkUUID == null && (r.type.equals(result.getType()) || result.getType().equals("error") )) ) {
|
||||
LogHelper.debug("Event %s type", r.type);
|
||||
LogHelper.debug("Event UUID contains: %s", (r.uuid != null && r.uuid.equals(checkUUID)) ? "true" : "false");
|
||||
synchronized (r) {
|
||||
r.result = result;
|
||||
r.ready = true;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.gravit.utils;
|
||||
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
import java.lang.reflect.Type;
|
||||
|
||||
public class UniversalJsonAdapter<R> implements JsonSerializer<R>, JsonDeserializer<R> {
|
||||
public ProviderMap<R> providerMap;
|
||||
public String PROP_NAME = "type";
|
||||
public final ProviderMap<R> providerMap;
|
||||
public final String PROP_NAME;
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap) {
|
||||
this.providerMap = providerMap;
|
||||
this.PROP_NAME = "type";
|
||||
}
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap, String PROP_NAME) {
|
||||
|
@ -22,7 +23,7 @@ public R deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext
|
|||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<? extends R> cls = providerMap.getProviderClass(typename);
|
||||
if (cls == null) {
|
||||
LogHelper.error("AuthHandler %s not found", typename);
|
||||
LogHelper.error("Provider %s not found", typename);
|
||||
return null;
|
||||
}
|
||||
return context.deserialize(json, cls);
|
||||
|
|
Loading…
Reference in a new issue