Фикс LauncherResponse

This commit is contained in:
Gravit 2018-10-02 19:39:54 +07:00
parent fb7ac48962
commit e8126f565d
2 changed files with 8 additions and 4 deletions

View file

@ -53,7 +53,7 @@ public final byte[] getHash() {
public final boolean sync() throws IOException { public final boolean sync() throws IOException {
boolean exists = exists(); boolean exists = exists();
binary = exists ? new SignedBytesHolder(IOHelper.read(syncBinaryFile), server.privateKey) : null; 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; return exists;
} }
} }

View file

@ -24,16 +24,20 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
byte[] bytes = Base64.getDecoder().decode(hash); byte[] bytes = Base64.getDecoder().decode(hash);
if(launcher_type == 1) // JAR 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)); service.sendObject(ctx, new Result(false));
} else } else
{ {
service.sendObjectAndClose(ctx, new Result(true)); 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)); service.sendObject(ctx, new Result(false));
} else } else