From b9761637db4ce8f6d6d463db929ca8f1eee1bc59 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 19 Oct 2019 23:52:57 +0700 Subject: [PATCH] =?UTF-8?q?[ANY]=20=D0=A7=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?LauncherConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/tasks/MainBuildTask.java | 2 +- .../launcher/ClientLauncherWrapper.java | 2 +- .../pro/gravit/launcher/client/DirBridge.java | 2 +- .../launcher/guard/LauncherStdGuard.java | 11 ++---- .../launcher/guard/LauncherWrapperGuard.java | 11 ++---- .../pro/gravit/launcher/AutogenConfig.java | 3 -- .../pro/gravit/launcher/LauncherConfig.java | 37 ++----------------- 7 files changed, 13 insertions(+), 55 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index faf37520..60b17d06 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -195,7 +195,7 @@ public Path process(Path inputJar) throws IOException { byte[] launcherConfigBytes; try (ByteArrayOutputStream configArray = IOHelper.newByteArrayOutput()) { try (HOutput configOutput = new HOutput(configArray)) { - new LauncherConfig(server.config.netty.address, server.publicKey, runtime) + new LauncherConfig(server.config.netty.address, server.publicKey, runtime, server.config.projectName) .write(configOutput); } launcherConfigBytes = configArray.toByteArray(); diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index e2aeaada..9838ffe5 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -33,7 +33,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep LauncherEngine.modulesManager = new ClientModuleManager(); LauncherConfig.getAutogenConfig().initModules(); - LogHelper.info("Launcher for project %s", config.projectname); + LogHelper.info("Launcher for project %s", config.projectName); if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) { LogHelper.warning("Found -Dlauncher.debug=true"); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java b/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java index 347b764c..6e4ff2dd 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java @@ -102,7 +102,7 @@ public static void setUseLegacyDir(boolean b) { } static { - String projectName = Launcher.getConfig().projectname; + String projectName = Launcher.getConfig().projectName; try { DirBridge.dir = getLauncherDir(projectName); if (!IOHelper.exists(DirBridge.dir)) Files.createDirectories(DirBridge.dir); diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java index b24bcadb..96d17677 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java @@ -29,7 +29,7 @@ public String getName() { public Path getJavaBinPath() { if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { javaBinPath = ClientLauncher.getJavaBinPath(); - String projectName = Launcher.getConfig().projectname; + String projectName = Launcher.getConfig().projectName; String wrapperUnpackName = (javaBinPath == null ? JVMHelper.JVM_BITS : JVMHelper.OS_BITS) == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); return DirBridge.getGuardDir().resolve(wrapperUnpackName); } else @@ -48,7 +48,7 @@ public int getClientJVMBits() { @Override public void init(boolean clientInstance) { try { - String projectName = Launcher.getConfig().projectname; + String projectName = Launcher.getConfig().projectName; UnpackHelper.unpack(Launcher.getResourceURL("wrapper64.exe", "guard"), DirBridge.getGuardDir().resolve(projectName.concat("64.exe"))); UnpackHelper.unpack(Launcher.getResourceURL("AntiInject64.dll", "guard"), DirBridge.getGuardDir().resolve("AntiInject64.dll")); @@ -73,14 +73,9 @@ public void addCustomEnv(ClientLauncherContext context) { env.put("JAVA_HOME", javaBinPath.toAbsolutePath().toString()); LauncherConfig config = Launcher.getConfig(); env.put("GUARD_USERNAME", context.playerProfile.username); - env.put("GUARD_PROJECTNAME", config.projectname); + env.put("GUARD_PROJECTNAME", config.projectName); if (protectToken != null) env.put("GUARD_TOKEN", protectToken); - if (config.guardLicenseName != null) - env.put("GUARD_LICENSE_NAME", config.guardLicenseName); - if (config.guardLicenseKey != null) { - env.put("GUARD_LICENSE_KEY", config.guardLicenseKey); - } } @Override diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java index 725cb1fc..fe841e79 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java @@ -26,7 +26,7 @@ public String getName() { @Override public Path getJavaBinPath() { if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { - String projectName = Launcher.getConfig().projectname; + String projectName = Launcher.getConfig().projectName; String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); return DirBridge.getGuardDir().resolve(wrapperUnpackName); } else @@ -42,7 +42,7 @@ public int getClientJVMBits() { public void init(boolean clientInstance) { try { String wrapperName = JVMHelper.JVM_BITS == 64 ? "wrapper64.exe" : "wrapper32.exe"; - String projectName = Launcher.getConfig().projectname; + String projectName = Launcher.getConfig().projectName; String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); String antiInjectName = JVMHelper.JVM_BITS == 64 ? "AntiInject64.dll" : "AntiInject32.dll"; UnpackHelper.unpack(Launcher.getResourceURL(wrapperName, "guard"), DirBridge.getGuardDir().resolve(wrapperUnpackName)); @@ -63,14 +63,9 @@ public void addCustomEnv(ClientLauncherContext context) { env.put("JAVA_HOME", System.getProperty("java.home")); LauncherConfig config = Launcher.getConfig(); env.put("GUARD_USERNAME", context.playerProfile.username); - env.put("GUARD_PROJECTNAME", config.projectname); + env.put("GUARD_PROJECTNAME", config.projectName); if (protectToken != null) env.put("GUARD_TOKEN", protectToken); - if (config.guardLicenseName != null) - env.put("GUARD_LICENSE_NAME", config.guardLicenseName); - if (config.guardLicenseKey != null) { - env.put("GUARD_LICENSE_KEY", config.guardLicenseKey); - } } @Override diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java index 67f19b48..da1d710c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java @@ -7,9 +7,6 @@ public class AutogenConfig { public String guardType; public String secretKeyClient; public String oemUnlockKey; - public String guardLicenseName; - public String guardLicenseKey; - public String guardLicenseEncryptKey; public String secureCheckHash; public String secureCheckSalt; public String passwordEncryptKey; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java index 1d64cf48..c916c8b7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java @@ -25,7 +25,7 @@ public static AutogenConfig getAutogenConfig() { // Instance public String address; @LauncherAPI - public final String projectname; + public final String projectName; public final int clientPort; public String secretKeyClient; public String oemUnlockKey; @@ -39,9 +39,6 @@ public static AutogenConfig getAutogenConfig() { public boolean isNettyEnabled; public LauncherEnvironment environment; - public final String guardLicenseName; - public final String guardLicenseKey; - public final String guardLicenseEncryptKey; public final String guardType; public final String secureCheckHash; @@ -54,7 +51,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException secureCheckHash = config.secureCheckHash; secureCheckSalt = config.secureCheckSalt; passwordEncryptKey = config.passwordEncryptKey; - projectname = config.projectname; + projectName = config.projectname; clientPort = config.clientPort; secretKeyClient = config.secretKeyClient; oemUnlockKey = config.oemUnlockKey; @@ -65,10 +62,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException } isWarningMissArchJava = config.isWarningMissArchJava; - guardLicenseEncryptKey = config.guardLicenseEncryptKey; - guardLicenseKey = config.guardLicenseKey; guardType = config.guardType; - guardLicenseName = config.guardLicenseName; address = config.address; LauncherEnvironment env; if (config.env == 0) env = LauncherEnvironment.DEV; @@ -91,34 +85,11 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException } @LauncherAPI - public LauncherConfig(String address, ECPublicKey publicKey, Map runtime, String projectname) { + public LauncherConfig(String address, ECPublicKey publicKey, Map runtime, String projectName) { this.address = address; this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); - this.projectname = projectname; - this.clientPort = 32148; - this.guardLicenseName = "FREE"; - this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD"; - this.guardLicenseEncryptKey = "12345"; - guardType = "no"; - isWarningMissArchJava = true; - isNettyEnabled = false; - environment = LauncherEnvironment.STD; - secureCheckSalt = null; - secureCheckHash = null; - passwordEncryptKey = null; - trustManager = null; - } - - @LauncherAPI - public LauncherConfig(String address, ECPublicKey publicKey, Map runtime) { - this.address = address; - this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); - this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); - this.projectname = "Minecraft"; - this.guardLicenseName = "FREE"; - this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD"; - this.guardLicenseEncryptKey = "12345"; + this.projectName = projectName; this.clientPort = 32148; guardType = "no"; isWarningMissArchJava = true;