From ca19734a88a9284cf4d0680fd9e315de5e7168c6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 9 Aug 2019 23:04:26 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=B0=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D1=80=D1=8B,=20=D0=BE=D1=82=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=8F=D1=89=D0=B8=D0=B5=D1=81=D1=8F=20=D0=BA=20=D1=81=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D0=B5=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B2=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=20?= =?UTF-8?q?launcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 24 +++++++++---------- .../binary/JARLauncherBinary.java | 4 ++-- .../launchserver/binary/ProguardConf.java | 2 +- .../tasks/AdditionalFixesApplyTask.java | 2 +- .../binary/tasks/MainBuildTask.java | 2 +- .../binary/tasks/ProGuardBuildTask.java | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 2437fcd9..18ed9b62 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -147,15 +147,8 @@ public AuthProviderPair getAuthProviderPair() { public GuardLicenseConf guardLicense; public String whitelistRejectString; - - public boolean genMappings; public LauncherConf launcher; - public boolean isWarningMissArchJava; - public boolean enabledProGuard; - public boolean stripLineNumbers; - public boolean deleteTempFiles; - public String startScript; public void setProjectName(String projectName) { @@ -276,6 +269,11 @@ public class LauncherConf { public String guardType; public boolean attachLibraryBeforeProGuard; public boolean compress; + public boolean warningMissArchJava; + public boolean enabledProGuard; + public boolean stripLineNumbers; + public boolean deleteTempFiles; + public boolean proguardGenMappings; } public class NettyConfig { @@ -802,12 +800,12 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.launcher = new LauncherConf(); newConfig.launcher.guardType = "no"; newConfig.launcher.compress = true; - - newConfig.genMappings = true; - newConfig.enabledProGuard = true; - newConfig.stripLineNumbers = true; - newConfig.deleteTempFiles = true; - newConfig.isWarningMissArchJava = true; + newConfig.launcher.warningMissArchJava = true; + newConfig.launcher.attachLibraryBeforeProGuard = false; + newConfig.launcher.deleteTempFiles = true; + newConfig.launcher.enabledProGuard = true; + newConfig.launcher.stripLineNumbers = true; + newConfig.launcher.proguardGenMappings = true; newConfig.components = new HashMap<>(); AuthLimiterComponent authLimiterComponent = new AuthLimiterComponent(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java index 01ecec9e..179dadd1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java @@ -64,12 +64,12 @@ public void build() throws IOException { long time_task_end = System.currentTimeMillis(); long time_task = time_task_end - time_this; time_this = time_task_end; - if (isNeedDelete && server.config.deleteTempFiles) Files.deleteIfExists(oldPath); + if (isNeedDelete && server.config.launcher.deleteTempFiles) Files.deleteIfExists(oldPath); isNeedDelete = task.allowDelete(); LogHelper.subInfo("Task %s processed from %d millis", task.getName(), time_task); } long time_end = System.currentTimeMillis(); - if (isNeedDelete && server.config.deleteTempFiles) IOHelper.move(thisPath, syncBinaryFile); + if (isNeedDelete && server.config.launcher.deleteTempFiles) IOHelper.move(thisPath, syncBinaryFile); else IOHelper.copy(thisPath, syncBinaryFile); LogHelper.info("Build successful from %d millis", time_end - time_start); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java index c4149bd8..78246022 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java @@ -44,7 +44,7 @@ public ProguardConf(LaunchServer srv) { public String[] buildConfig(Path inputJar, Path outputJar) { List confStrs = new ArrayList<>(); prepare(false); - if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); + if (srv.config.launcher.proguardGenMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-injar \'" + inputJar.toAbsolutePath() + "\'"); confStrs.add("-outjar \'" + outputJar.toAbsolutePath() + "\'"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java index 7b92834c..8dcd35e0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java @@ -75,7 +75,7 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L bytes = outputStream.toByteArray(); } try { - bytes = classFix(bytes, reader, srv.config.stripLineNumbers); + bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers); } catch (Throwable t) { LogHelper.subWarning("Error on fixing class: " + t); } 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 b1a9d83a..34ea7c4e 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 @@ -135,7 +135,7 @@ public Path process(Path inputJar) throws IOException { jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); jaConfigurator.setGuardType(server.config.launcher.guardType); - jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava); + jaConfigurator.setWarningMissArchJava(server.config.launcher.warningMissArchJava); jaConfigurator.setEnv(server.config.env); if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); jaConfigurator.setOemUnlockKey(server.runtime.oemUnlockKey); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java index f2203728..71f2117e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java @@ -26,7 +26,7 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { Path outputJar = server.launcherBinary.nextLowerPath(this); - if (server.config.enabledProGuard) { + if (server.config.launcher.enabledProGuard) { Configuration proguard_cfg = new Configuration(); ConfigurationParser parser = new ConfigurationParser(server.proguardConf.buildConfig(inputFile, outputJar), server.proguardConf.proguard.toFile(), System.getProperties());