diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java index 83b87337..c9aa8db2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -1,12 +1,12 @@ package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launcher.request.secure.HardwareReportRequest; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; public class HardwareReportResponse extends SimpleResponse { - public String pathToJava; - public String javaVersion; + public HardwareReportRequest.HardwareInfo hardware; @Override public String getType() { diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java new file mode 100644 index 00000000..2d7a879e --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java @@ -0,0 +1,48 @@ +package pro.gravit.launcher.console.test; + +import pro.gravit.launcher.utils.HWIDProvider; +import pro.gravit.utils.command.Command; +import pro.gravit.utils.helper.LogHelper; + +public class PrintHardwareInfoCommand extends Command { + @Override + public String getArgsDescription() { + return "[]"; + } + + @Override + public String getUsageDescription() { + return "print your hardware info and timings"; + } + + @Override + public void invoke(String... args) throws Exception { + LogHelper.info("Your Hardware ID:"); + long startTime = System.currentTimeMillis(); + long currentTime; + HWIDProvider provider = new HWIDProvider(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Create HWIDProvider instance: %d ms", currentTime - startTime); + startTime = System.currentTimeMillis(); + int bitness = provider.getBitness(); + long totalMemory = provider.getTotalMemory(); + boolean isBattery = provider.isBattery(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Bitness: %d, totalMemory: %d(%.3f GB), battery %s, TIME: %d ms", bitness, totalMemory, (double)totalMemory / (1024.0*1024.0*1024.0), Boolean.toString(isBattery), currentTime - startTime); + startTime = System.currentTimeMillis(); + int logicalProcessors = provider.getProcessorLogicalCount(); + int physicalProcessors = provider.getProcessorPhysicalCount(); + long processorMaxFreq = provider.getProcessorMaxFreq(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Processors || logical: %d physical %d freq %d, TIME: %d ms", logicalProcessors, physicalProcessors, processorMaxFreq, currentTime - startTime); + startTime = System.currentTimeMillis(); + String hwDiskID = provider.getHWDiskID(); + currentTime = System.currentTimeMillis(); + LogHelper.info("HWDiskID %s, TIME: %d ms", hwDiskID, currentTime - startTime); + startTime = System.currentTimeMillis(); + String baseboardSerial = provider.getBaseboardSerialNumber(); + currentTime = System.currentTimeMillis(); + LogHelper.info("BaseboardSerial %s, TIME: %d ms", baseboardSerial, currentTime - startTime); + LogHelper.info("Hardware ID end"); + } +} diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java index c0d6543d..641be710 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java @@ -4,6 +4,7 @@ import pro.gravit.launcher.LauncherEngine; import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent; import pro.gravit.launcher.console.UnlockCommand; +import pro.gravit.launcher.console.test.PrintHardwareInfoCommand; import pro.gravit.utils.command.CommandHandler; import pro.gravit.utils.command.JLineCommandHandler; import pro.gravit.utils.command.StdCommandHandler; @@ -44,6 +45,7 @@ public static void registerCommands() { handler.registerCommand("gc", new GCCommand()); handler.registerCommand("clear", new ClearCommand(handler)); handler.registerCommand("unlock", new UnlockCommand()); + handler.registerCommand("printhardware", new PrintHardwareInfoCommand()); } public static boolean checkUnlockKey(String key) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java index 3f8aa00d..bdf41d46 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java @@ -1,6 +1,7 @@ package pro.gravit.launcher.utils; import oshi.SystemInfo; +import oshi.hardware.Display; import oshi.hardware.HWDiskStore; import oshi.hardware.HardwareAbstractionLayer; import oshi.hardware.PowerSource; @@ -63,6 +64,20 @@ public String getHWDiskID() } return null; } + public byte[] getDisplayID() + { + Display[] displays = hardware.getDisplays(); + if(displays == null || displays.length == 0) return null; + for(Display display : displays) + { + return display.getEdid(); + } + return null; + } + public String getBaseboardSerialNumber() + { + return hardware.getComputerSystem().getBaseboard().getSerialNumber(); + } public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) { HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo(); @@ -75,6 +90,8 @@ public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) if(needSerial) { info.hwDiskId = getHWDiskID(); + info.displayId = getDisplayID(); + info.baseboardSerialNumber = getBaseboardSerialNumber(); } return info; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java index 857d6c97..2f7fd075 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java @@ -18,5 +18,7 @@ public static class HardwareInfo { public long processorMaxFreq; public boolean battery; public String hwDiskId; + public byte[] displayId; + public String baseboardSerialNumber; } }