Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev

This commit is contained in:
Zaxar163 2020-04-13 20:16:48 +03:00
commit d06f179e9c
11 changed files with 218 additions and 2 deletions

View file

@ -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;
@ -72,6 +73,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 process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) {

View file

@ -0,0 +1,20 @@
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 HardwareReportRequest.HardwareInfo hardware;
@Override
public String getType() {
return "hardwareReport";
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
}
}

View file

@ -34,6 +34,7 @@ public class ClientLauncherProcess {
public Path executeFile;
public Path workDir;
public Path javaDir;
public boolean useLegacyJavaClassPathProperty;
public boolean isStarted;
private transient Process process;
@ -103,9 +104,16 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
List<String> processArgs = new LinkedList<>();
processArgs.add(executeFile.toString());
processArgs.addAll(jvmArgs);
processArgs.add("-cp");
//ADD CLASSPATH
processArgs.add(String.join(getPathSeparator(), systemClassPath));
if(useLegacyJavaClassPathProperty)
{
processArgs.add("-Djava.class.path=".concat(String.join(getPathSeparator(), systemClassPath)));
}
else
{
processArgs.add("-cp");
processArgs.add(String.join(getPathSeparator(), systemClassPath));
}
processArgs.add(mainClass);
processArgs.addAll(systemClientArgs);
synchronized (waitWriteParams) {

View file

@ -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");
}
}

View file

@ -34,6 +34,7 @@ public void applyGuardParams(ClientLauncherProcess process) {
String projectName = Launcher.getConfig().projectName;
String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe");
process.executeFile = DirBridge.getGuardDir().resolve(wrapperUnpackName);
process.useLegacyJavaClassPathProperty = true;
}
}
}

View file

@ -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) {

View file

@ -0,0 +1,98 @@
package pro.gravit.launcher.utils;
import oshi.SystemInfo;
import oshi.hardware.Display;
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 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();
info.bitness = getBitness();
info.logicalProcessors = getProcessorLogicalCount();
info.physicalProcessors = getProcessorPhysicalCount();
info.processorMaxFreq = getProcessorMaxFreq();
info.totalMemory = getTotalMemory();
info.battery = isBattery();
if(needSerial)
{
info.hwDiskId = getHWDiskID();
info.displayId = getDisplayID();
info.baseboardSerialNumber = getBaseboardSerialNumber();
}
return info;
}
}

View file

@ -7,7 +7,9 @@
public class ClientPermissions {
public static final ClientPermissions DEFAULT = new ClientPermissions();
@LauncherNetworkAPI
public long permissions;
@LauncherNetworkAPI
public long flags;
public ClientPermissions(HInput input) throws IOException {

View file

@ -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";
}
}

View file

@ -0,0 +1,24 @@
package pro.gravit.launcher.request.secure;
import pro.gravit.launcher.events.request.HardwareReportRequestEvent;
import pro.gravit.launcher.request.Request;
public class HardwareReportRequest extends Request<HardwareReportRequestEvent> {
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;
public byte[] displayId;
public String baseboardSerialNumber;
}
}

View file

@ -101,6 +101,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() {