diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java index 9ede059a..558e75ec 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -53,7 +53,7 @@ public final byte[] getHash() { public final boolean sync() throws IOException { boolean exists = exists(); binary = exists ? new SignedBytesHolder(IOHelper.read(syncBinaryFile), server.privateKey) : null; - hash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512,IOHelper.newInput(syncBinaryFile)); + hash = exists ? SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512,IOHelper.newInput(syncBinaryFile)) : null; return exists; } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java index ee82ef42..b983e9f4 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java @@ -24,16 +24,20 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client byte[] bytes = Base64.getDecoder().decode(hash); if(launcher_type == 1) // JAR { - if(Arrays.equals(bytes, LaunchServer.server.launcherBinary.getHash())) //REPLACE REAL HASH + byte[] hash = LaunchServer.server.launcherBinary.getHash(); + if(hash == null) service.sendObjectAndClose(ctx, new Result(true)); + if(Arrays.equals(bytes, hash)) //REPLACE REAL HASH { service.sendObject(ctx, new Result(false)); } else { service.sendObjectAndClose(ctx, new Result(true)); } - } else if(launcher_type == 2) + } else if(launcher_type == 2) //EXE { - if(Arrays.equals(bytes, LaunchServer.server.launcherEXEBinary.getHash())) //REPLACE REAL HASH + byte[] hash = LaunchServer.server.launcherEXEBinary.getHash(); + if(hash == null) service.sendObjectAndClose(ctx, new Result(true)); + if(Arrays.equals(bytes, hash)) //REPLACE REAL HASH { service.sendObject(ctx, new Result(false)); } else