From ecb904035a56cb27982682424de8fa51f1766308 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 20 Oct 2018 16:33:02 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=85=D0=BD=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=8F=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B2?= =?UTF-8?q?=D0=BE=D0=B5=D0=B9=20JVM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 5 +++++ .../launchserver/binary/JAConfigurator.java | 10 ++++++++++ .../binary/JARLauncherBinary.java | 2 ++ .../gravit/launchserver/defaults/config.cfg | 3 +++ .../launcher/client/ClientLauncher.java | 20 ++++++++++++++++--- .../ru/gravit/launcher/AutogenConfig.java | 2 ++ .../ru/gravit/launcher/LauncherConfig.java | 9 +++++++++ 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 8f3ec478..9e458841 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -99,6 +99,8 @@ public static final class Config extends ConfigObject { public final String whitelistRejectString; public final boolean genMappings; + public final boolean isUsingWrapper; + public final boolean isDownloadJava; public ListConfigEntry mirrors; public final String binaryName; @@ -142,6 +144,9 @@ private Config(BlockConfigEntry block, Path coredir,LaunchServer server) { binaryName = block.getEntryValue("binaryName", StringConfigEntry.class); projectName = block.hasEntry("projectName") ? block.getEntryValue("projectName", StringConfigEntry.class) : "Minecraft"; compress = block.getEntryValue("compress", BooleanConfigEntry.class); + + isUsingWrapper = block.getEntryValue("isUsingWrapper", BooleanConfigEntry.class); + isDownloadJava = block.getEntryValue("isDownloadJava", BooleanConfigEntry.class); } 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 9437c661..ef19075f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -88,6 +88,16 @@ public void setClientPort(int port) { body.append(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 ClassPool getPool() { return pool; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 7528945d..e4291d50 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -174,6 +174,8 @@ private void stdBuild() throws IOException { jaConfigurator.setProjectName(server.config.projectName); jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); + jaConfigurator.setUsingWrapper(server.config.isUsingWrapper); + jaConfigurator.setDownloadJava(server.config.isDownloadJava); server.buildHookManager.registerAllClientModuleClass(jaConfigurator); try (ZipInputStream input = new ZipInputStream( IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) { diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg index 7f29a108..8433f42c 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg @@ -7,6 +7,9 @@ authRateLimit: 2; authRateLimitMilis: 5000; authRejectString: "Вы превысили лимит авторизаций. Подождите некоторое время перед повторной попыткой"; +isUsingWrapper: true; +isDownloadJava: false; + # White list testers whitelistRejectString: "Вас нет в белом списке"; 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 82b45e18..711d5850 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -162,7 +162,10 @@ 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 = true; + private static final boolean isUsingWrapper = Launcher.getConfig().isUsingWrapper; + private static final boolean isDownloadJava = Launcher.getConfig().isDownloadJava; + + private static Path JavaBinPath; @SuppressWarnings("unused") private static final Set BIN_POSIX_PERMISSIONS = Collections.unmodifiableSet(EnumSet.of( PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, // Owner @@ -227,6 +230,10 @@ private static void addClientArgs(Collection args, ClientProfile profile Collections.addAll(args, "--height", Integer.toString(params.height)); } } + @LauncherAPI + public static void setJavaBinPath(Path javaBinPath) { + JavaBinPath = javaBinPath; + } private static void addClientLegacyArgs(Collection args, ClientProfile profile, Params params) { args.add(params.pp.username); @@ -288,7 +295,6 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl private static Process process = null; @LauncherAPI public static Process launch( - SignedObjectHolder assetHDir, SignedObjectHolder clientHDir, SignedObjectHolder profile, Params params, boolean pipeOutput) throws Throwable { // Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars) @@ -331,9 +337,17 @@ public static Process launch( checkJVMBitsAndVersion(); // Fill CLI arguments List args = new LinkedList<>(); - boolean wrapper = isUsingWrapper() && Launcher.isUsingAvanguard(); + boolean wrapper = isUsingWrapper(); Path javaBin; if (wrapper) javaBin = JVMHelper.JVM_BITS == 64 ? AvanguardStarter.wrap64 : AvanguardStarter.wrap32; + else if(isDownloadJava) + { + //Linux и Mac не должны скачивать свою JVM + if(JVMHelper.OS_TYPE == OS.MUSTDIE) + javaBin = IOHelper.resolveJavaBin(JavaBinPath); + else + javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java"); + } else javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java"); args.add(javaBin.toString()); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index 4c2a776c..4434bb6b 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -6,6 +6,8 @@ public class AutogenConfig { public int port; public int clientPort; private boolean isInitModules; + public boolean isUsingWrapper; + public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части public String secretKeyClient; AutogenConfig() { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index 4822320e..54286338 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -42,6 +42,9 @@ public static AutogenConfig getAutogenConfig() { @LauncherAPI public final Map runtime; + public final boolean isUsingWrapper; + public final boolean isDownloadJava; + @LauncherAPI public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException { String localAddress = config.address; @@ -51,6 +54,8 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException projectname = config.projectname; clientPort = config.clientPort; secretKeyClient = config.secretKeyClient; + isDownloadJava = config.isDownloadJava; + isUsingWrapper = config.isUsingWrapper; // Read signed runtime int count = input.readLength(0); Map localResources = new HashMap<>(count); @@ -75,6 +80,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = projectname; this.clientPort = 32148; + isUsingWrapper = true; + isDownloadJava = false; } @LauncherAPI @@ -85,6 +92,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = "Minecraft"; this.clientPort = 32148; + isUsingWrapper = true; + isDownloadJava = false; } @Override