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