From 0201c8d474000a737cdbf2b04053721858118107 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 12 Apr 2019 05:15:05 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A3=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20guardType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 11 +++++---- .../launchserver/binary/JAConfigurator.java | 18 +++++---------- .../binary/tasks/MainBuildTask.java | 3 +-- .../launcher/client/ClientLauncher.java | 11 --------- .../launcher/guard/LauncherGuardManager.java | 23 +++++++++++++++---- .../ru/gravit/launcher/AutogenConfig.java | 3 +-- .../ru/gravit/launcher/LauncherConfig.java | 14 ++++------- 7 files changed, 37 insertions(+), 46 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index b7ca5b45..722fb3b8 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -131,20 +131,16 @@ public AuthProviderPair getAuthProviderPair() { public NettyConfig netty; public GuardLicenseConf guardLicense; - public boolean compress; - public String whitelistRejectString; public boolean genMappings; - public boolean isUsingWrapper; - public boolean isDownloadJava; + public LauncherConf launcher; public boolean isWarningMissArchJava; public boolean enabledProGuard; public boolean enabledRadon; public boolean stripLineNumbers; public boolean deleteTempFiles; - public boolean enableRcon; public String startScript; @@ -242,6 +238,11 @@ public static class ExeConf { public String txtProductVersion; } + public class LauncherConf + { + public String guardType; + } + public class NettyConfig { public boolean clientEnabled; public String launcherURL; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index dfe913d3..a720d371 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -83,6 +83,12 @@ public void setSecretKey(String key) { body.append("\";"); } + public void setGuardType(String key) { + body.append("this.guardType = \""); + body.append(key); + body.append("\";"); + } + public void setEnv(LauncherConfig.LauncherEnvironment env) { int i = 2; switch (env) { @@ -111,18 +117,6 @@ public void setClientPort(int port) { body.append(";"); } - public void setUsingWrapper(boolean b) { - body.append("this.isUsingWrapper = "); - body.append(b ? "true" : "false"); - body.append(";"); - } - - public void setDownloadJava(boolean b) { - body.append("this.isDownloadJava = "); - body.append(b ? "true" : "false"); - body.append(";"); - } - public void setWarningMissArchJava(boolean b) { body.append("this.isWarningMissArchJava = "); body.append(b ? "true" : "false"); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 916783ea..e7e9de06 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -134,9 +134,8 @@ public Path process(Path inputJar) throws IOException { jaConfigurator.setProjectName(server.config.projectName); jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); - jaConfigurator.setUsingWrapper(server.config.isUsingWrapper); + jaConfigurator.setGuardType(server.config.launcher.guardType); jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava); - jaConfigurator.setDownloadJava(server.config.isDownloadJava); jaConfigurator.setEnv(server.config.env); server.buildHookManager.registerAllClientModuleClass(jaConfigurator); reader.getCp().add(new JarFile(inputJar.toFile())); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 62f8339c..f83de1c2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -139,8 +139,6 @@ public void write(HOutput output) throws IOException { private static final String SOCKET_HOST = "127.0.0.1"; private static final int SOCKET_PORT = Launcher.getConfig().clientPort; private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"; - private static final boolean isUsingWrapper = Launcher.getConfig().isUsingWrapper; - private static final boolean isDownloadJava = Launcher.getConfig().isDownloadJava; private static Path JavaBinPath; @SuppressWarnings("unused") @@ -165,10 +163,6 @@ public static class ClientUserProperties { String[] cloakDigest; } - public static boolean isDownloadJava() { - return isDownloadJava; - } - public static Path getJavaBinPath() { return JavaBinPath; } @@ -265,11 +259,6 @@ public static boolean isLaunched() { return Launcher.LAUNCHED.get(); } - - public static boolean isUsingWrapper() { - return JVMHelper.OS_TYPE == OS.MUSTDIE && isUsingWrapper; - } - private static void launch(ClientProfile profile, Params params) throws Throwable { // Add client args Collection args = new LinkedList<>(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java index 419b4839..ee9930d0 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java @@ -1,5 +1,7 @@ package ru.gravit.launcher.guard; +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.client.ClientLauncher; import java.nio.file.Path; @@ -8,11 +10,22 @@ public class LauncherGuardManager { public static LauncherGuardInterface guard; public static void initGuard(boolean clientInstance) { - if (ClientLauncher.isUsingWrapper()) { - guard = new LauncherWrapperGuard(); - } else if (ClientLauncher.isDownloadJava()) { - guard = new LauncherJavaGuard(); - } else guard = new LauncherNoGuard(); + LauncherConfig config = Launcher.getConfig(); + switch (config.guardType) + { + case "wrapper": + { + guard = new LauncherWrapperGuard(); + } + case "java": + { + guard = new LauncherJavaGuard(); + } + default: + { + guard = new LauncherNoGuard(); + } + } guard.init(clientInstance); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index e0c26129..dd00f048 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -6,8 +6,7 @@ public class AutogenConfig { public int clientPort; @SuppressWarnings("unused") private boolean isInitModules; - public boolean isUsingWrapper; - public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части + public String guardType; public String secretKeyClient; public String guardLicenseName; public String guardLicenseKey; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index dacfa5ea..b5429d84 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -30,15 +30,13 @@ public static AutogenConfig getAutogenConfig() { @LauncherAPI public final Map runtime; - - public final boolean isUsingWrapper; - public final boolean isDownloadJava; public final boolean isWarningMissArchJava; public boolean isNettyEnabled; public final String guardLicenseName; public final String guardLicenseKey; public final String guardLicenseEncryptKey; + public final String guardType; @LauncherAPI public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException { @@ -46,11 +44,11 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException projectname = config.projectname; clientPort = config.clientPort; secretKeyClient = config.secretKeyClient; - isDownloadJava = config.isDownloadJava; - isUsingWrapper = config.isUsingWrapper; + isWarningMissArchJava = config.isWarningMissArchJava; guardLicenseEncryptKey = config.guardLicenseEncryptKey; guardLicenseKey = config.guardLicenseKey; + guardType = config.guardType; guardLicenseName = config.guardLicenseName; address = config.address; LauncherEnvironment env; @@ -82,8 +80,7 @@ public LauncherConfig(String address, RSAPublicKey publicKey, Map