diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 00b1b1b7..6f0908f1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -22,6 +22,7 @@ import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUsername; import pro.gravit.launchserver.socket.response.secure.GetSecureLevelInfoResponse; +import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse; import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.launchserver.socket.response.secure.VerifySecureLevelKeyResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse; @@ -131,6 +132,7 @@ public static void registerResponses() { providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class); providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class); providers.register("securityReport", SecurityReportResponse.class); + providers.register("hardwareReport", HardwareReportResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { 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 new file mode 100644 index 00000000..83b87337 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -0,0 +1,20 @@ +package pro.gravit.launchserver.socket.response.secure; + +import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.response.SimpleResponse; + +public class HardwareReportResponse extends SimpleResponse { + public String pathToJava; + public String javaVersion; + + @Override + public String getType() { + return "hardwareReport"; + } + + @Override + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { + + } +} diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java new file mode 100644 index 00000000..3f8aa00d --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java @@ -0,0 +1,81 @@ +package pro.gravit.launcher.utils; + +import oshi.SystemInfo; +import oshi.hardware.HWDiskStore; +import oshi.hardware.HardwareAbstractionLayer; +import oshi.hardware.PowerSource; +import oshi.software.os.OperatingSystem; +import pro.gravit.launcher.request.secure.HardwareReportRequest; + +public class HWIDProvider { + public SystemInfo systemInfo; + public OperatingSystem system; + public HardwareAbstractionLayer hardware; + public HWIDProvider() + { + systemInfo = new SystemInfo(); + system = systemInfo.getOperatingSystem(); + hardware = systemInfo.getHardware(); + } + //Statistic information + public int getBitness() + { + return system.getBitness(); + } + public long getTotalMemory() + { + return hardware.getMemory().getTotal(); + } + public long getProcessorMaxFreq() + { + return hardware.getProcessor().getMaxFreq(); + } + public int getProcessorPhysicalCount() + { + return hardware.getProcessor().getPhysicalProcessorCount(); + } + public int getProcessorLogicalCount() + { + return hardware.getProcessor().getLogicalProcessorCount(); + } + public boolean isBattery() + { + PowerSource[] powerSources = hardware.getPowerSources(); + return powerSources != null && powerSources.length != 0; + } + //Hardware Information + public String getHWDiskID() + { + HWDiskStore[] hwDiskStore = hardware.getDiskStores(); + long size = 0; + HWDiskStore maxStore = null; + for(HWDiskStore store : hwDiskStore) + { + if(store.getSize() > size) + { + maxStore = store; + size = store.getSize(); + } + } + if(maxStore != null) + { + return maxStore.getSerial(); + } + return null; + } + public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) + { + HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo(); + info.bitness = getBitness(); + info.logicalProcessors = getProcessorLogicalCount(); + info.physicalProcessors = getProcessorPhysicalCount(); + info.processorMaxFreq = getProcessorMaxFreq(); + info.totalMemory = getTotalMemory(); + info.battery = isBattery(); + if(needSerial) + { + info.hwDiskId = getHWDiskID(); + } + return info; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java new file mode 100644 index 00000000..7305eca8 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.events.request; + +import pro.gravit.launcher.events.RequestEvent; + +public class HardwareReportRequestEvent extends RequestEvent { + @Override + public String getType() { + return "hardwareReport"; + } +} 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 new file mode 100644 index 00000000..857d6c97 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java @@ -0,0 +1,22 @@ +package pro.gravit.launcher.request.secure; + +import pro.gravit.launcher.events.request.HardwareReportRequestEvent; +import pro.gravit.launcher.request.Request; + +public class HardwareReportRequest extends Request { + public HardwareInfo hardware; + @Override + public String getType() { + return "hardwareReport"; + } + + public static class HardwareInfo { + public int bitness; + public long totalMemory; + public int logicalProcessors; + public int physicalProcessors; + public long processorMaxFreq; + public boolean battery; + public String hwDiskId; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index 4e74f253..0e50045c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -110,6 +110,7 @@ public void registerResults() { results.register("getSecureLevelInfo", GetSecureLevelInfoRequestEvent.class); results.register("verifySecureLevelKey", VerifySecureLevelKeyRequestEvent.class); results.register("securityReport", SecurityReportRequestEvent.class); + results.register("hardwareReport", HardwareReportRequestEvent.class); } public void waitIfNotConnected() {