From 90e116720c6ffccb333e93a4cee6965ed5fc9dc2 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:22:44 +0700 Subject: [PATCH] [FIX] onHardwareReport NPE --- .../auth/protect/AdvancedProtectHandler.java | 10 +++++++--- .../java/pro/gravit/launchserver/socket/Client.java | 3 ++- .../src/main/java/pro/gravit/utils/Version.java | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java index 1899292a..83ce07e2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java @@ -49,6 +49,10 @@ public void onHardwareReport(HardwareReportResponse response, Client client) { response.sendError("Access denied"); return; } + if(client.trustLevel.hardwareInfo != null) { + response.sendResult(new HardwareReportRequestEvent(createHardwareToken(client.username, client.trustLevel.hardwareInfo), SECONDS.toMillis(server.config.netty.security.hardwareTokenExpire))); + return; + } logger.debug("HardwareInfo received"); { var authSupportHardware = client.auth.isSupport(AuthSupportHardware.class); @@ -63,7 +67,7 @@ public void onHardwareReport(HardwareReportResponse response, Client client) { if (hardware.isBanned()) { throw new SecurityException("Your hardware banned"); } - client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); + client.trustLevel.hardwareInfo = hardware; response.sendResult(new HardwareReportRequestEvent(createHardwareToken(client.username, hardware), SECONDS.toMillis(server.config.netty.security.hardwareTokenExpire))); } else { logger.error("AuthCoreProvider not supported hardware"); @@ -83,7 +87,7 @@ public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { if (hardware.isBanned()) { throw new SecurityException("Your hardware banned"); } - client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); + client.trustLevel.hardwareInfo = hardware; authSupportHardware.connectUserAndHardware(client.sessionObject, hardware); return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey), SECONDS.toMillis(server.config.netty.security.publicKeyTokenExpire)); } else { @@ -145,7 +149,7 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken if (hardwareSupport == null) return false; UserHardware hardware = hardwareSupport.getHardwareInfoById(hardwareInfoId); if (client.trustLevel == null) client.trustLevel = new Client.TrustLevel(); - client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); + client.trustLevel.hardwareInfo = hardware; return true; } catch (Throwable e) { logger.error("Hardware JWT error", e); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java index 3ac02c04..3853bf93 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java @@ -5,6 +5,7 @@ import pro.gravit.launcher.request.secure.HardwareReportRequest; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthProviderPair; +import pro.gravit.launchserver.auth.core.interfaces.UserHardware; import pro.gravit.launchserver.socket.response.auth.AuthResponse; import java.util.HashMap; @@ -87,7 +88,7 @@ public static class TrustLevel { public byte[] verifySecureKey; public boolean keyChecked; public byte[] publicKey; - public HardwareReportRequest.HardwareInfo hardwareInfo; + public UserHardware hardwareInfo; // May be used later public double rating; public long latestMillis; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 1f1c5356..13ff9f72 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -6,9 +6,9 @@ public final class Version implements Comparable { public static final int MAJOR = 5; public static final int MINOR = 5; - public static final int PATCH = 0; + public static final int PATCH = 1; public static final int BUILD = 1; - public static final Version.Type RELEASE = Type.STABLE; + public static final Version.Type RELEASE = Type.DEV; public final int major; public final int minor; public final int patch;