mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-03 22:30:31 +03:00
[FEATURE] Проверка HWID
This commit is contained in:
parent
925c1170a3
commit
c438f08d7a
5 changed files with 71 additions and 2 deletions
|
@ -1,12 +1,12 @@
|
||||||
package pro.gravit.launchserver.socket.response.secure;
|
package pro.gravit.launchserver.socket.response.secure;
|
||||||
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||||
|
|
||||||
public class HardwareReportResponse extends SimpleResponse {
|
public class HardwareReportResponse extends SimpleResponse {
|
||||||
public String pathToJava;
|
public HardwareReportRequest.HardwareInfo hardware;
|
||||||
public String javaVersion;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
import pro.gravit.launcher.LauncherEngine;
|
import pro.gravit.launcher.LauncherEngine;
|
||||||
import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent;
|
import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent;
|
||||||
import pro.gravit.launcher.console.UnlockCommand;
|
import pro.gravit.launcher.console.UnlockCommand;
|
||||||
|
import pro.gravit.launcher.console.test.PrintHardwareInfoCommand;
|
||||||
import pro.gravit.utils.command.CommandHandler;
|
import pro.gravit.utils.command.CommandHandler;
|
||||||
import pro.gravit.utils.command.JLineCommandHandler;
|
import pro.gravit.utils.command.JLineCommandHandler;
|
||||||
import pro.gravit.utils.command.StdCommandHandler;
|
import pro.gravit.utils.command.StdCommandHandler;
|
||||||
|
@ -44,6 +45,7 @@ public static void registerCommands() {
|
||||||
handler.registerCommand("gc", new GCCommand());
|
handler.registerCommand("gc", new GCCommand());
|
||||||
handler.registerCommand("clear", new ClearCommand(handler));
|
handler.registerCommand("clear", new ClearCommand(handler));
|
||||||
handler.registerCommand("unlock", new UnlockCommand());
|
handler.registerCommand("unlock", new UnlockCommand());
|
||||||
|
handler.registerCommand("printhardware", new PrintHardwareInfoCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkUnlockKey(String key) {
|
public static boolean checkUnlockKey(String key) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package pro.gravit.launcher.utils;
|
package pro.gravit.launcher.utils;
|
||||||
|
|
||||||
import oshi.SystemInfo;
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.Display;
|
||||||
import oshi.hardware.HWDiskStore;
|
import oshi.hardware.HWDiskStore;
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
import oshi.hardware.HardwareAbstractionLayer;
|
||||||
import oshi.hardware.PowerSource;
|
import oshi.hardware.PowerSource;
|
||||||
|
@ -63,6 +64,20 @@ public String getHWDiskID()
|
||||||
}
|
}
|
||||||
return null;
|
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)
|
public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial)
|
||||||
{
|
{
|
||||||
HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo();
|
HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo();
|
||||||
|
@ -75,6 +90,8 @@ public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial)
|
||||||
if(needSerial)
|
if(needSerial)
|
||||||
{
|
{
|
||||||
info.hwDiskId = getHWDiskID();
|
info.hwDiskId = getHWDiskID();
|
||||||
|
info.displayId = getDisplayID();
|
||||||
|
info.baseboardSerialNumber = getBaseboardSerialNumber();
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,7 @@ public static class HardwareInfo {
|
||||||
public long processorMaxFreq;
|
public long processorMaxFreq;
|
||||||
public boolean battery;
|
public boolean battery;
|
||||||
public String hwDiskId;
|
public String hwDiskId;
|
||||||
|
public byte[] displayId;
|
||||||
|
public String baseboardSerialNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue