From a9a9a7898313aaa012038d5175536408927d452a Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 13 Oct 2018 15:20:23 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BB=D1=83=D1=87=D0=B0=D0=B9=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BF=D0=BE=D1=80=D1=82=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B5=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/binary/JAConfigurator.java | 5 +++++ .../ru/gravit/launchserver/binary/JARLauncherBinary.java | 1 + .../main/java/ru/gravit/launcher/client/ClientLauncher.java | 2 +- .../src/main/java/ru/gravit/launcher/AutogenConfig.java | 1 + .../src/main/java/ru/gravit/launcher/LauncherConfig.java | 4 ++++ 5 files changed, 12 insertions(+), 1 deletion(-) 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 adbb3cb8..9437c661 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,11 @@ public void setPort(int port) { body.append(port); body.append(";"); } + public void setClientPort(int port) { + body.append("this.clientPort = "); + body.append(port); + 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 9bd3cc78..dda5377a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -173,6 +173,7 @@ private void stdBuild() throws IOException { jaConfigurator.setPort(server.config.port); jaConfigurator.setProjectName(server.config.projectName); jaConfigurator.setSecretKey(SecurityHelper.randomStringToken()); + jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); server.buildHookManager.registerAllClientModuleClass(jaConfigurator); try (ZipInputStream input = new ZipInputStream( IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) { 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 632d72cb..985438af 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -160,7 +160,7 @@ public void write(HOutput output) throws IOException { private static final String[] EMPTY_ARRAY = new String[0]; private static final String SOCKET_HOST = "127.0.0.1"; - private static final int SOCKET_PORT = 32148; + 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; @SuppressWarnings("unused") diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index 32f6b445..4c2a776c 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -4,6 +4,7 @@ public class AutogenConfig { public String projectname; public String address; public int port; + public int clientPort; private boolean isInitModules; public String secretKeyClient; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index 6eafe618..4822320e 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -34,6 +34,7 @@ public static AutogenConfig getAutogenConfig() { public final InetSocketAddress address; @LauncherAPI public final String projectname; + public final int clientPort; public String secretKeyClient; @LauncherAPI public final RSAPublicKey publicKey; @@ -48,6 +49,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException ADDRESS_OVERRIDE == null ? localAddress : ADDRESS_OVERRIDE, config.port); publicKey = SecurityHelper.toPublicRSAKey(input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH)); projectname = config.projectname; + clientPort = config.clientPort; secretKeyClient = config.secretKeyClient; // Read signed runtime int count = input.readLength(0); @@ -72,6 +74,7 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = projectname; + this.clientPort = 32148; } @LauncherAPI @@ -81,6 +84,7 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = "Minecraft"; + this.clientPort = 32148; } @Override