From f750e8897a5e1b9a207aa4731320ed2353931e6f Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 10 Feb 2019 17:18:37 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=20=D0=B2=D0=B5=D0=B1?= =?UTF-8?q?=D1=81=D0=BE=D0=BA=D0=B5=D1=82=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 2 ++ .../json/update/LauncherResponse.java | 4 ++-- .../request/update/LauncherRequest.java | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index ffd0034f..47e3cdbe 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -185,6 +185,8 @@ public class NettyConfig { public String bindAddress; public int port; + public String launcherURL; + public String launcherEXEURL; } public class GuardLicenseConf { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java index 8df5524e..9b78bfd5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java @@ -17,8 +17,8 @@ public class LauncherResponse implements JsonResponseInterface { public byte[] digest; public int launcher_type; //REPLACED TO REAL URL - public static final String JAR_URL = "http://localhost:9752/Launcher.jar"; - public static final String EXE_URL = "http://localhost:9752/Launcher.exe"; + public static final String JAR_URL = LaunchServer.server.config.netty.launcherURL; + public static final String EXE_URL = LaunchServer.server.config.netty.launcherEXEURL; @Override public String getType() { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index 98390ec6..763f5caf 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -17,6 +17,10 @@ import ru.gravit.utils.helper.SecurityHelper; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -46,7 +50,16 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th builder.inheritIO(); // Rewrite and start new instance - IOHelper.write(BINARY_PATH, result.binary); + if(result.binary != null) + IOHelper.write(BINARY_PATH, result.binary); + else + { + URLConnection connection = IOHelper.newConnection(new URL(result.url)); + connection.connect(); + try(OutputStream stream = connection.getOutputStream()) { + IOHelper.transfer(BINARY_PATH, stream); + } + } builder.start(); // Kill current instance @@ -62,7 +75,8 @@ public LauncherRequest() { @Override public LauncherRequestEvent requestWebSockets() throws Exception { - return (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this); + LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this); + return result; } @LauncherAPI