From a26311be882771541c88ddf0da6510488755fa75 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 19:20:26 +0700 Subject: [PATCH 01/26] =?UTF-8?q?[FEATURE]=20=D0=9E=D1=82=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=BE=D1=87=D0=BD=D1=8B=D0=B9=20=D0=B2=D1=8B=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=20verifyHDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/client/ClientLauncher.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 eff70e03..76009d70 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -19,6 +19,7 @@ import ru.gravit.utils.helper.JVMHelper.OS; import javax.swing.*; +import java.io.File; import java.io.IOException; import java.lang.ProcessBuilder.Redirect; import java.lang.invoke.MethodHandle; @@ -537,8 +538,17 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, // Hash directory and compare (ignore update-only matcher entries, it will break offline-mode) HashedDir currentHDir = new HashedDir(dir, matcher, true, digest); - if (!hdir.diff(currentHDir, matcher).isSame()) + HashedDir.Diff diff = hdir.diff(currentHDir, matcher); + if (!diff.isSame()) + { + diff.extra.walk(File.separator, (e,k,v) -> { + LogHelper.error("Extra %s", e); + }); + diff.mismatch.walk(File.separator, (e,k,v) -> { + LogHelper.error("Mismatch %s", e); + }); throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); + } } private ClientLauncher() { From 05539133cbdb90dcf8f1a8be223babea86d863fb Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sat, 27 Apr 2019 15:24:20 +0300 Subject: [PATCH 02/26] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=201.14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/profiles/ClientProfile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index 488ab996..e2ed0b54 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -28,6 +28,7 @@ public enum Version { MC113("1.13", 393), MC1131("1.13.1", 401), MC1132("1.13.2", 402); + MC114("1.14", 477); private static final Map VERSIONS; static { From 76661305af09e499e31a16f2aca53346f8dd50ef Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 19:44:48 +0700 Subject: [PATCH 03/26] =?UTF-8?q?[FIX]=20=D0=9D=D0=B5=20=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=B3=D0=B8=D1=80=D1=83=D0=B5=D0=BC=20=D0=B5=D1=81=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=D0=B8=D1=81=D1=8C?= =?UTF-8?q?=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B4=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/client/ClientLauncher.java | 5 +++++ 1 file changed, 5 insertions(+) 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 76009d70..604537bd 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -6,6 +6,7 @@ import ru.gravit.launcher.hasher.DirWatcher; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; @@ -35,6 +36,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; public final class ClientLauncher { @@ -541,10 +543,13 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, HashedDir.Diff diff = hdir.diff(currentHDir, matcher); if (!diff.isSame()) { + AtomicBoolean isFoundFile = new AtomicBoolean(false); diff.extra.walk(File.separator, (e,k,v) -> { + if(v.getType().equals(HashedEntry.Type.FILE)) isFoundFile.set(true); LogHelper.error("Extra %s", e); }); diff.mismatch.walk(File.separator, (e,k,v) -> { + if(v.getType().equals(HashedEntry.Type.FILE)) isFoundFile.set(true); LogHelper.error("Mismatch %s", e); }); throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); From 63183873a59920fb2022beb330300015531ff97d Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 19:51:29 +0700 Subject: [PATCH 04/26] =?UTF-8?q?[FIX]=20=D0=9E=D0=BF=D0=B5=D1=87=D0=B0?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=B2=20ClientProfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/profiles/ClientProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index e2ed0b54..62d66cfc 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -27,7 +27,7 @@ public enum Version { MC1122("1.12.2", 340), MC113("1.13", 393), MC1131("1.13.1", 401), - MC1132("1.13.2", 402); + MC1132("1.13.2", 402), MC114("1.14", 477); private static final Map VERSIONS; From b1fe3cf2a99b29a20f3d603c5ea8f3f9f9b71f27 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 19:56:55 +0700 Subject: [PATCH 05/26] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B2=20verifyHDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/client/ClientLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 604537bd..686df2cc 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -552,7 +552,7 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, if(v.getType().equals(HashedEntry.Type.FILE)) isFoundFile.set(true); LogHelper.error("Mismatch %s", e); }); - throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); + if(isFoundFile.get()) throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); } } From 24a453f338430ba1456e0545dd87cdfc559915a8 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 20:27:22 +0700 Subject: [PATCH 06/26] =?UTF-8?q?[FIX]=20=D0=94=D0=BE=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=20verifyHDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launcher/client/ClientLauncher.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 686df2cc..274a2c41 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -545,12 +545,12 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, { AtomicBoolean isFoundFile = new AtomicBoolean(false); diff.extra.walk(File.separator, (e,k,v) -> { - if(v.getType().equals(HashedEntry.Type.FILE)) isFoundFile.set(true); - LogHelper.error("Extra %s", e); + if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); isFoundFile.set(true); } + else LogHelper.error("Extra %s", e); }); diff.mismatch.walk(File.separator, (e,k,v) -> { - if(v.getType().equals(HashedEntry.Type.FILE)) isFoundFile.set(true); - LogHelper.error("Mismatch %s", e); + if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Mismatch file %s", e); isFoundFile.set(true); } + else LogHelper.error("Mismatch %s", e); }); if(isFoundFile.get()) throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); } From b3079b83dcaa2d2ad8da0a132f5e9636eddc1825 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 20:55:29 +0700 Subject: [PATCH 07/26] =?UTF-8?q?[FIX]=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=B9=20UpdateRequest'=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launcher/request/update/UpdateRequest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index 0e652a40..a39c21f2 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -174,11 +174,19 @@ public UpdateRequestEvent requestDo() throws Exception { HashedDir.Diff diff = e.hdir.diff(localDir, matcher); final List adds = new ArrayList<>(); diff.mismatch.walk(IOHelper.CROSS_SEPARATOR, (path, name, entry) -> { - if(entry.getType() == HashedEntry.Type.FILE) { + if(entry.getType().equals(HashedEntry.Type.FILE)) { HashedFile file = (HashedFile) entry; totalSize += file.size; adds.add(new ListDownloader.DownloadTask(path, file.size)); } + else if(entry.getType().equals(HashedEntry.Type.DIR)) + { + try { + Files.createDirectories(dir.resolve(path)); + } catch (IOException ex) { + LogHelper.error(ex); + } + } }); totalSize = diff.mismatch.size(); startTime = Instant.now(); From 446acf2181bdb4901d1ac4527de2fe6bfa60d6b2 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 20:58:33 +0700 Subject: [PATCH 08/26] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=20verifyHDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/client/ClientLauncher.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 274a2c41..3609fe38 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -543,7 +543,7 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, HashedDir.Diff diff = hdir.diff(currentHDir, matcher); if (!diff.isSame()) { - AtomicBoolean isFoundFile = new AtomicBoolean(false); + /*AtomicBoolean isFoundFile = new AtomicBoolean(false); diff.extra.walk(File.separator, (e,k,v) -> { if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); isFoundFile.set(true); } else LogHelper.error("Extra %s", e); @@ -552,7 +552,8 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Mismatch file %s", e); isFoundFile.set(true); } else LogHelper.error("Mismatch %s", e); }); - if(isFoundFile.get()) throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); + if(isFoundFile.get())*/ + throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); } } From 175df1796c82c84a14664c30b657599f33d4675e Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 28 Apr 2019 11:39:43 +0700 Subject: [PATCH 09/26] =?UTF-8?q?[FIX][CRITICAL]=20=D0=A4=D0=B8=D0=BA?= =?UTF-8?q?=D1=81=20java.util.IllegalFormatConversionException:=20d=20!=3D?= =?UTF-8?q?=20java.lang.String=20=D0=B2=20ServerWrapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/server/ServerWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index 872fc72d..56b946ce 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -170,7 +170,7 @@ public void run(String... args) throws Throwable { auth(); }; } - LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s port %d. Title: %s", config.projectname, config.websocket.address, config.title); + LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s. Title: %s", config.projectname, config.websocket.address, config.title); LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name); LogHelper.info("Start Minecraft Server"); LogHelper.debug("Invoke main method %s", mainClass.getName()); From c4cd9812e0443c2fe639643da06458965abf95f2 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 28 Apr 2019 07:07:01 +0200 Subject: [PATCH 10/26] =?UTF-8?q?[FIX]=20=D0=9E=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=BF=D0=B0=D1=82=D1=82=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=85=20ServerWrapper;=20=D0=B1=D0=B0=D0=B3=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20RAM.?= =?UTF-8?q?=20(#232)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] Убраны лишние классы из libLauncher. * [FIX] Получение RAM. * [FIX] Ещё фиксы такового с RAM. * [REFACTOR] Удалён лишний код. * [FEATURE] Теперь прикрутить sentry можно просто добавив библиотеку в libraries и дописав 3 строчки в runtime. * [FIX] Ошибка в паттернах ServerWrapper, порождает java.util.IllegalFormatConversionException --- .../dialog/overlay/settings/settings.js | 2 +- .../java/cpw/mods/fml/SafeExitJVMLegacy.java | 0 .../net/minecraftforge/fml/SafeExitJVM.java | 0 .../ru/gravit/launcher/LauncherAgent.java | 3 +- .../ru/gravit/launcher/LauncherEngine.java | 3 +- .../launcher/client/ClientLauncher.java | 8 +- .../launcher/client/FunctionalBridge.java | 12 +- .../launcher/hwid/OshiHWIDProvider.java | 2 +- .../ru/gravit/launcher/utils}/DirWatcher.java | 7 +- .../gravit/launcher}/utils/NativeJVMHalt.java | 2 +- .../gravit/launcher/server/ServerWrapper.java | 2 +- .../gravit/utils/downloader/Downloader.java | 213 ------------------ .../ru/gravit/utils/helper/JVMHelper.java | 17 -- .../ru/gravit/utils/helper/LogHelper.java | 8 + 14 files changed, 27 insertions(+), 252 deletions(-) rename {libLauncher => Launcher}/src/main/java/cpw/mods/fml/SafeExitJVMLegacy.java (100%) rename {libLauncher => Launcher}/src/main/java/net/minecraftforge/fml/SafeExitJVM.java (100%) rename {libLauncher/src/main/java/ru/gravit/launcher/hasher => Launcher/src/main/java/ru/gravit/launcher/utils}/DirWatcher.java (95%) rename {libLauncher/src/main/java/ru/gravit => Launcher/src/main/java/ru/gravit/launcher}/utils/NativeJVMHalt.java (96%) delete mode 100644 libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java diff --git a/Launcher/runtime/dialog/overlay/settings/settings.js b/Launcher/runtime/dialog/overlay/settings/settings.js index 8429fd46..590dea8b 100644 --- a/Launcher/runtime/dialog/overlay/settings/settings.js +++ b/Launcher/runtime/dialog/overlay/settings/settings.js @@ -42,7 +42,7 @@ var settingsOverlay = { settingsOverlay.updateRAMLabel(); var ramSlider = holder.lookup("#ramSlider"); - ramSlider.setMax(JVMHelper.RAM); + ramSlider.setMax(FunctionalBridge.getJVMTotalMemory()); ramSlider.setSnapToTicks(true); ramSlider.setShowTickMarks(true); ramSlider.setShowTickLabels(true); diff --git a/libLauncher/src/main/java/cpw/mods/fml/SafeExitJVMLegacy.java b/Launcher/src/main/java/cpw/mods/fml/SafeExitJVMLegacy.java similarity index 100% rename from libLauncher/src/main/java/cpw/mods/fml/SafeExitJVMLegacy.java rename to Launcher/src/main/java/cpw/mods/fml/SafeExitJVMLegacy.java diff --git a/libLauncher/src/main/java/net/minecraftforge/fml/SafeExitJVM.java b/Launcher/src/main/java/net/minecraftforge/fml/SafeExitJVM.java similarity index 100% rename from libLauncher/src/main/java/net/minecraftforge/fml/SafeExitJVM.java rename to Launcher/src/main/java/net/minecraftforge/fml/SafeExitJVM.java diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java index f42740fc..cb3f0ca4 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -7,7 +7,8 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.MethodNode; -import ru.gravit.utils.NativeJVMHalt; + +import ru.gravit.launcher.utils.NativeJVMHalt; import ru.gravit.utils.helper.LogHelper; import java.io.ByteArrayOutputStream; diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 85f82be1..52c4d22b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -9,7 +9,6 @@ import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.managers.ConsoleManager; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.websockets.ClientWebSocketService; import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.EnvHelper; @@ -25,7 +24,7 @@ public static void main(String... args) throws Throwable { JVMHelper.checkStackTrace(LauncherEngine.class); JVMHelper.verifySystemProperties(Launcher.class, true); EnvHelper.checkDangerousParams(); - //if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); + if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); LogHelper.printVersion("Launcher"); LogHelper.printLicense("Launcher"); // Start Launcher 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 3609fe38..3d8d118a 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -3,10 +3,8 @@ import ru.gravit.launcher.*; import ru.gravit.launcher.guard.LauncherGuardManager; import ru.gravit.launcher.gui.JSRuntimeProvider; -import ru.gravit.launcher.hasher.DirWatcher; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; -import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; @@ -15,12 +13,12 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.launcher.utils.DirWatcher; import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.utils.helper.*; import ru.gravit.utils.helper.JVMHelper.OS; import javax.swing.*; -import java.io.File; import java.io.IOException; import java.lang.ProcessBuilder.Redirect; import java.lang.invoke.MethodHandle; @@ -36,10 +34,8 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; public final class ClientLauncher { - private static final class ClassPathFileVisitor extends SimpleFileVisitor { private final Collection result; @@ -331,7 +327,7 @@ public static Process launch( context.playerProfile = params.pp; context.args.add(javaBin.toString()); context.args.add(MAGICAL_INTEL_OPTION); - if (params.ram > 0 && params.ram <= JVMHelper.RAM) { + if (params.ram > 0 && params.ram <= FunctionalBridge.getJVMTotalMemory()) { context.args.add("-Xms" + params.ram + 'M'); context.args.add("-Xmx" + params.ram + 'M'); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index 6639966d..a530b0d7 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -11,7 +11,6 @@ import ru.gravit.launcher.managers.HasherManager; import ru.gravit.launcher.managers.HasherStore; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.websockets.RequestInterface; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.utils.helper.LogHelper; @@ -30,6 +29,8 @@ public class FunctionalBridge { public static AtomicReference hwid = new AtomicReference<>(); @LauncherAPI public static Thread getHWID = null; + + private static long cachedMemorySize = -1; @LauncherAPI public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder hdir, FileNameMatcher matcher, boolean digest) { @@ -42,11 +43,6 @@ public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, S }; } - @LauncherAPI - public static void makeJsonRequest(RequestInterface request, Runnable callback) { - - } - @LauncherAPI public static void startTask(Runnable task) { threadPool.execute(task); @@ -61,7 +57,8 @@ public static HWID getHWID() { @LauncherAPI public static long getTotalMemory() { - return hwidProvider.getTotalMemory() >> 20; + if (cachedMemorySize > 0) return cachedMemorySize; + return cachedMemorySize = hwidProvider.getTotalMemory() >> 20; } @LauncherAPI @@ -106,6 +103,7 @@ public static void setAuthParams(AuthRequestEvent event) { public interface HashedDirRunnable { SignedObjectHolder run() throws Exception; } + @LauncherAPI public static void evalCommand(String cmd) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java index 43003f1c..5e75d632 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -83,7 +83,7 @@ public String getMacAddr() { } public long getTotalMemory() { - if (noHWID) return -1; + if (noHWID) return 1024<<20; if (hardware == null) hardware = systemInfo.getHardware(); return hardware.getMemory().getTotal(); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java b/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java similarity index 95% rename from libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java rename to Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java index cc0aaba8..9c0e30bf 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java @@ -1,8 +1,11 @@ -package ru.gravit.launcher.hasher; +package ru.gravit.launcher.utils; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.hasher.FileNameMatcher; +import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.launcher.hasher.HashedEntry; +import ru.gravit.launcher.hasher.HashedFile; import ru.gravit.launcher.hasher.HashedEntry.Type; -import ru.gravit.utils.NativeJVMHalt; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.JVMHelper.OS; diff --git a/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java b/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java similarity index 96% rename from libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java rename to Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java index 5a154c50..4401ceb1 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java +++ b/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java @@ -1,4 +1,4 @@ -package ru.gravit.utils; +package ru.gravit.launcher.utils; import cpw.mods.fml.SafeExitJVMLegacy; import net.minecraftforge.fml.SafeExitJVM; diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index 56b946ce..6a2948f3 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -1,4 +1,4 @@ -package ru.gravit.launcher.server; + package ru.gravit.launcher.server; import ru.gravit.launcher.ClientPermissions; import ru.gravit.launcher.Launcher; diff --git a/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java b/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java deleted file mode 100644 index dd128305..00000000 --- a/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java +++ /dev/null @@ -1,213 +0,0 @@ -package ru.gravit.utils.downloader; - -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - -import javax.net.ssl.HttpsURLConnection; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.security.cert.Certificate; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -public class Downloader implements Runnable { - @FunctionalInterface - public interface Handler { - void check(Certificate[] certs) throws IOException; - } - - public static final Map requestClient = Collections.singletonMap("User-Agent", - "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); - public static final int INTERVAL = 300; - - private final File file; - private final URL url; - private final String method; - public final Map requestProps; - public AtomicInteger writed = new AtomicInteger(0); - public final AtomicBoolean interrupt = new AtomicBoolean(false); - public final AtomicBoolean interrupted = new AtomicBoolean(false); - public AtomicReference ex = new AtomicReference<>(null); - private final int skip; - private final Handler handler; - - private HttpURLConnection connect = null; - - public Downloader(URL url, File file) { - this.requestProps = new HashMap<>(requestClient); - this.file = file; - this.url = url; - this.skip = 0; - this.handler = null; - this.method = null; - } - - public Downloader(URL url, File file, int skip) { - this.requestProps = new HashMap<>(requestClient); - this.file = file; - this.url = url; - this.skip = skip; - this.handler = null; - this.method = null; - } - - public Downloader(URL url, File file, Handler handler) { - this.requestProps = new HashMap<>(requestClient); - this.file = file; - this.url = url; - this.skip = 0; - this.handler = handler; - this.method = null; - } - - public Downloader(URL url, File file, int skip, Handler handler) { - this.requestProps = new HashMap<>(requestClient); - this.file = file; - this.url = url; - this.skip = skip; - this.handler = handler; - this.method = null; - } - - public Downloader(URL url, File file, int skip, Handler handler, Map requestProps) { - this.requestProps = new HashMap<>(requestProps); - this.file = file; - this.url = url; - this.skip = skip; - this.handler = handler; - this.method = null; - } - - public Downloader(URL url, File file, int skip, Handler handler, Map requestProps, String method) { - this.requestProps = new HashMap<>(requestProps); - this.file = file; - this.url = url; - this.skip = skip; - this.handler = handler; - this.method = method; - } - - public Downloader(URL url, File file, int skip, Handler handler, String method) { - this.requestProps = new HashMap<>(requestClient); - this.file = file; - this.url = url; - this.skip = skip; - this.handler = handler; - this.method = method; - } - - public Map getProps() { - return requestProps; - } - - public void addProp(String key, String value) { - requestProps.put(key, value); - } - - public File getFile() { - return file; - } - - public String getMethod() { - return method; - } - - public Handler getHandler() { - return handler; - } - - public void downloadFile() throws IOException { - if (!(url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equalsIgnoreCase("https"))) - throw new IOException("Invalid protocol."); - interrupted.set(false); - if (url.getProtocol().equalsIgnoreCase("http")) { - HttpURLConnection connect = (HttpURLConnection) (url).openConnection(); - this.connect = connect; - if (method != null) connect.setRequestMethod(method); - for (Map.Entry ent : requestProps.entrySet()) { - connect.setRequestProperty(ent.getKey(), ent.getValue()); - } - connect.setInstanceFollowRedirects(true); - if (!(connect.getResponseCode() >= 200 && connect.getResponseCode() < 300)) - throw new IOException(String.format("Invalid response of http server %d.", connect.getResponseCode())); - try (BufferedInputStream in = new BufferedInputStream(connect.getInputStream(), IOHelper.BUFFER_SIZE); - FileOutputStream fout = new FileOutputStream(file, skip != 0)) { - byte data[] = new byte[IOHelper.BUFFER_SIZE]; - int count = -1; - long timestamp = System.currentTimeMillis(); - int writed_local = 0; - in.skip(skip); - while ((count = in.read(data)) != -1) { - fout.write(data, 0, count); - writed_local += count; - if (System.currentTimeMillis() - timestamp > INTERVAL) { - writed.set(writed_local); - LogHelper.debug("Downloaded %d", writed_local); - if (interrupt.get()) { - break; - } - } - } - LogHelper.debug("Downloaded %d", writed_local); - writed.set(writed_local); - } - } else { - HttpsURLConnection connect = (HttpsURLConnection) (url).openConnection(); - this.connect = connect; - if (method != null) connect.setRequestMethod(method); - for (Map.Entry ent : requestProps.entrySet()) { - connect.setRequestProperty(ent.getKey(), ent.getValue()); - } - connect.setInstanceFollowRedirects(true); - if (handler != null) - handler.check(connect.getServerCertificates()); - if (!(connect.getResponseCode() >= 200 && connect.getResponseCode() < 300)) - throw new IOException(String.format("Invalid response of http server %d.", connect.getResponseCode())); - try (BufferedInputStream in = new BufferedInputStream(connect.getInputStream(), IOHelper.BUFFER_SIZE); - FileOutputStream fout = new FileOutputStream(file, skip != 0)) { - byte data[] = new byte[IOHelper.BUFFER_SIZE]; - int count = -1; - long timestamp = System.currentTimeMillis(); - int writed_local = 0; - in.skip(skip); - while ((count = in.read(data)) != -1) { - fout.write(data, 0, count); - writed_local += count; - if (System.currentTimeMillis() - timestamp > INTERVAL) { - writed.set(writed_local); - LogHelper.debug("Downloaded %d", writed_local); - if (interrupt.get()) { - break; - } - } - } - LogHelper.debug("Downloaded %d", writed_local); - writed.set(writed_local); - } - } - interrupted.set(true); - } - - @Override - public void run() { - try { - downloadFile(); - } catch (Throwable ex) { - this.ex.set(ex); - LogHelper.error(ex); - } - if (connect != null) - try { - connect.disconnect(); - } catch (Throwable ignored) { - } - } -} diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java index e4e2510b..f0351c92 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java @@ -7,8 +7,6 @@ import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.lang.management.RuntimeMXBean; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; @@ -52,8 +50,6 @@ public static OS byName(String name) { public static final int OS_BITS = getCorrectOSArch(); @LauncherAPI public static final int JVM_BITS = Integer.parseInt(System.getProperty("sun.arch.data.model")); - @LauncherAPI - public static final int RAM = getRAMAmount(); @LauncherAPI public static final SecurityManager SECURITY_MANAGER = System.getSecurityManager(); @@ -137,19 +133,6 @@ public static String getEnvPropertyCaseSensitive(String name) { return System.getenv().get(name); } - private static int getRAMAmount() { - int physicalRam = 1024; - try { - final Method getTotalPhysicalMemorySize = OPERATING_SYSTEM_MXBEAN.getClass().getDeclaredMethod("getTotalPhysicalMemorySize"); - getTotalPhysicalMemorySize.setAccessible(true); - physicalRam = (int) ((long)getTotalPhysicalMemorySize.invoke(OPERATING_SYSTEM_MXBEAN) >> 20); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | SecurityException e) { - throw new Error(e); - } - return Math.min(physicalRam, OS_BITS == 32 ? 1536 : 32768); // Limit 32-bit OS to 1536 MiB, and 64-bit OS to 32768 MiB (because it's enough) - } - @LauncherAPI public static boolean isJVMMatchesSystemArch() { return JVM_BITS == OS_BITS; diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java index 6ff72f84..90898237 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java @@ -15,6 +15,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; import java.util.function.Supplier; public final class LogHelper { @@ -50,6 +51,7 @@ public enum OutputTypes { } private static final Set OUTPUTS = Collections.newSetFromMap(new ConcurrentHashMap<>(2)); + private static final Set> EXCEPTIONS_CALLBACKS = Collections.newSetFromMap(new ConcurrentHashMap<>(2)); private static final OutputEnity STD_OUTPUT; private LogHelper() { @@ -60,6 +62,11 @@ public static void addOutput(OutputEnity output) { OUTPUTS.add(Objects.requireNonNull(output, "output")); } + @LauncherAPI + public static void addExcCallback(Consumer output) { + EXCEPTIONS_CALLBACKS.add(Objects.requireNonNull(output, "output")); + } + @LauncherAPI public static void addOutput(Output output, OutputTypes type) { OUTPUTS.add(new OutputEnity(Objects.requireNonNull(output, "output"), type)); @@ -105,6 +112,7 @@ public static void dev(String format, Object... args) { @LauncherAPI public static void error(Throwable exc) { + EXCEPTIONS_CALLBACKS.forEach(e -> e.accept(exc)); error(isStacktraceEnabled() ? toString(exc) : exc.toString()); } From 57e334efc893bde21ee4c1f93a166da7a0a46eb7 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 28 Apr 2019 12:44:23 +0700 Subject: [PATCH 11/26] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20setup?= =?UTF-8?q?=20ServerWrapper'=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java index b7d192ec..195d49ab 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java @@ -67,6 +67,7 @@ public void run() throws IOException { wrapper.config.password = password; wrapper.config.title = title; wrapper.config.stopOnError = false; + wrapper.updateLauncherConfig(); if (wrapper.auth()) { break; From 8ba8d27241d1e2b01f8530e55b8e37623cdbc1a9 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 28 Apr 2019 13:48:45 +0200 Subject: [PATCH 12/26] =?UTF-8?q?[FIX]=20=D0=98=D0=BD=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=81=20authOptions.=20(#235)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 5221e81d..8e195196 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -59,6 +59,8 @@ function initLoginScene() { savePasswordBox = pane.lookup("#rememberchb"); savePasswordBox.setSelected(settings.login === null || settings.rsaPassword !== null); + authOptions = pane.lookup("#authOptions"); + var link = pane.lookup("#link"); link.setText(config.linkText); link.setOnAction(function(event) app.getHostServices().showDocument(config.linkURL.toURI())); @@ -466,4 +468,4 @@ launcher.loadScript("dialog/overlay/update/update.js"); /* ======== Scenes scripts ======== */ launcher.loadScript("dialog/scenes/options/options.js"); -launcher.loadScript("dialog/scenes/console/console.js"); \ No newline at end of file +launcher.loadScript("dialog/scenes/console/console.js"); From 10a441b2ae581b8d264779c9084212b37cc94b8e Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 28 Apr 2019 13:49:17 +0200 Subject: [PATCH 13/26] =?UTF-8?q?[ANY]=20=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D1=88=D0=BE=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3.=20(#233)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] Убрал свою криворукость. * [ANY] Небольшой рефакторинг. * [ANY] Обновил readme, --- Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java | 2 +- README.md | 3 ++- .../src/main/java/ru/gravit/launcher/server/ServerWrapper.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 52c4d22b..6990a706 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -24,7 +24,7 @@ public static void main(String... args) throws Throwable { JVMHelper.checkStackTrace(LauncherEngine.class); JVMHelper.verifySystemProperties(Launcher.class, true); EnvHelper.checkDangerousParams(); - if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); + //if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); LogHelper.printVersion("Launcher"); LogHelper.printLicense("Launcher"); // Start Launcher diff --git a/README.md b/README.md index 051f38c6..c03966a5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ * Discord channel: https://discord.gg/aJK6nMN * [See license](LICENSE) * [See code of conduct](CODE_OF_CONDUCT.md) -* [WIKI](https://launcher.gravit.pro) +* [WIKI](https://yii2.gravit.pro) +* [OLD WIKI (4.X.X)](https://launcher.gravit.pro) * Get it (requires cURL): ```sh curl -s https://raw.githubusercontent.com/GravitLauncher/Launcher/master/get_it.sh | sh diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index 6a2948f3..56b946ce 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -1,4 +1,4 @@ - package ru.gravit.launcher.server; +package ru.gravit.launcher.server; import ru.gravit.launcher.ClientPermissions; import ru.gravit.launcher.Launcher; From c6c86afce14aa33691a0b45d8fda30d646744dd1 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 28 Apr 2019 14:06:12 +0200 Subject: [PATCH 14/26] =?UTF-8?q?[FEATURE]=20=D0=9E=D0=BF=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB-=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=20+=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BA=D0=BE?= =?UTF-8?q?=D0=BF=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20binari?= =?UTF-8?q?es=20(=D1=82=D0=BE=D0=B6=D0=B5=20=D0=BE=D0=BF=D1=86=D0=B8=D1=8F?= =?UTF-8?q?).=20(#236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] Убраны лишние классы из libLauncher. * [FIX] Получение RAM. * [FIX] Ещё фиксы такового с RAM. * [REFACTOR] Удалён лишний код. * [FEATURE] Теперь прикрутить sentry можно просто добавив библиотеку в libraries и дописав 3 строчки в runtime. * [FIX] Ошибка в паттернах ServerWrapper, порождает java.util.IllegalFormatConversionException * [FEATURE] Чистка конфига. * [FIX] Убрал лишние варнинги. * [FIX] Мои ошибки. --- .../ru/gravit/launchserver/LaunchServer.java | 34 +++++++++++-------- .../binary/EXEL4JLauncherBinary.java | 2 +- .../binary/EXELauncherBinary.java | 2 +- .../binary/JARLauncherBinary.java | 3 +- .../launchserver/binary/LauncherBinary.java | 10 +++--- .../websocket/LauncherNettyServer.java | 2 +- .../launcher/client/FunctionalBridge.java | 8 ++--- .../launcher/ssl/LauncherSSLContext.java | 2 -- 8 files changed, 33 insertions(+), 30 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index dc483640..5709d4f5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -79,6 +79,8 @@ public static final class Config { public String[] mirrors; public String binaryName; + + public boolean copyBinaries = true; public LauncherConfig.LauncherEnvironment env; @@ -269,7 +271,7 @@ public class LauncherConf } public class NettyConfig { - public boolean clientEnabled; + public boolean fileServerEnabled; public boolean sendExceptionEnabled; public String launcherURL; public String downloadURL; @@ -704,11 +706,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.whitelistRejectString = "Вас нет в белом списке"; newConfig.netty = new NettyConfig(); - newConfig.netty.address = "ws://localhost:9274/api"; - newConfig.netty.downloadURL = "http://localhost:9274/%dirname%/"; - newConfig.netty.launcherURL = "http://localhost:9274/Launcher.jar"; - newConfig.netty.launcherEXEURL = "http://localhost:9274/Launcher.exe"; - newConfig.netty.clientEnabled = false; + newConfig.netty.fileServerEnabled = true; newConfig.netty.binds = new NettyBindAddress[]{ new NettyBindAddress("0.0.0.0", 9274) }; newConfig.netty.performance = new NettyPerformanceConfig(); newConfig.netty.performance.bossThread = 2; @@ -734,25 +732,33 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.components.put("authLimiter", authLimiterComponent); // Set server address + String address; if (testEnv) { - newConfig.setLegacyAddress("localhost"); + address = "localhost"; newConfig.setProjectName("test"); } else { - System.out.println("LaunchServer legacy address(default: localhost): "); - newConfig.setLegacyAddress(commandHandler.readLine()); + System.out.println("LaunchServer address(default: localhost): "); + address = commandHandler.readLine(); System.out.println("LaunchServer projectName: "); newConfig.setProjectName(commandHandler.readLine()); } - if(newConfig.legacyAddress == null) + if(address == null) { - LogHelper.error("Legacy address null. Using localhost"); - newConfig.legacyAddress = "localhost"; + LogHelper.error("Address null. Using localhost"); + address = "localhost"; } if(newConfig.projectName == null) { LogHelper.error("ProjectName null. Using MineCraft"); newConfig.projectName = "MineCraft"; } + + newConfig.legacyAddress = address; + newConfig.netty.address = "ws://" + address + ":9274/api"; + newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; + newConfig.netty.launcherURL = "http://" + address + ":9274/internal/Launcher.jar"; + newConfig.netty.launcherEXEURL = "http://" + address + ":9274/internal/Launcher.exe"; + newConfig.netty.sendExceptionEnabled = true; // Write LaunchServer config LogHelper.info("Writing LaunchServer config file"); @@ -836,14 +842,14 @@ public void syncUpdatesDir(Collection dirs) throws IOException { LogHelper.info("Syncing updates dir"); Map> newUpdatesDirMap = new HashMap<>(16); try (DirectoryStream dirStream = Files.newDirectoryStream(updatesDir)) { - for (Path updateDir : dirStream) { + for (final Path updateDir : dirStream) { if (Files.isHidden(updateDir)) continue; // Skip hidden // Resolve name and verify is dir String name = IOHelper.getFileName(updateDir); if (!IOHelper.isDir(updateDir)) { - LogHelper.warning("Not update dir: '%s'", name); + if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) LogHelper.warning("Not update dir: '%s'", name); continue; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java index 8be92cf1..ba669376 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java @@ -35,7 +35,7 @@ public void clear() { public EXEL4JLauncherBinary(LaunchServer server) { - super(server, server.dir.resolve(server.config.binaryName + ".exe")); + super(server, LauncherBinary.resolve(server, ".exe")); faviconFile = server.dir.resolve("favicon.ico"); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java index 16c68a2d..77b785ea 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java @@ -10,7 +10,7 @@ public class EXELauncherBinary extends LauncherBinary { public EXELauncherBinary(LaunchServer server) { - super(server, server.dir.resolve(server.config.binaryName + ".exe")); + super(server, LauncherBinary.resolve(server, ".exe")); } @Override 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 605d3675..839976f1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -24,9 +24,8 @@ public final class JARLauncherBinary extends LauncherBinary { public List addonLibs; public JARLauncherBinary(LaunchServer server) throws IOException { - super(server); + super(server, LauncherBinary.resolve(server, ".jar")); count = new AtomicLong(0); - syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar"); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); guardDir = server.dir.resolve(Launcher.GUARD_DIR); buildDir = server.dir.resolve("build"); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java index da9a9be4..1e37d764 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -10,7 +10,7 @@ public abstract class LauncherBinary { public final LaunchServer server; - public Path syncBinaryFile; + public final Path syncBinaryFile; private volatile DigestBytesHolder binary; private volatile byte[] sign; @@ -19,10 +19,6 @@ protected LauncherBinary(LaunchServer server, Path binaryFile) { syncBinaryFile = binaryFile; } - protected LauncherBinary(LaunchServer server) { - this.server = server; - } - public abstract void build() throws IOException; @@ -49,4 +45,8 @@ public final boolean sync() throws IOException { return exists; } + + public static final Path resolve(LaunchServer server, String ext) { + return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext); + } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java index 29725e9c..0df2a864 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java @@ -42,7 +42,7 @@ public void initChannel(NioSocketChannel ch) { pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); - pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true)); + if (LaunchServer.server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true)); pipeline.addLast(new WebSocketFrameHandler()); } }); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index a530b0d7..57f7334c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -56,9 +56,9 @@ public static HWID getHWID() { } @LauncherAPI - public static long getTotalMemory() { - if (cachedMemorySize > 0) return cachedMemorySize; - return cachedMemorySize = hwidProvider.getTotalMemory() >> 20; + public static int getTotalMemory() { + if (cachedMemorySize > 0) return (int)cachedMemorySize; + return (int)(cachedMemorySize = hwidProvider.getTotalMemory() >> 20); } @LauncherAPI @@ -67,7 +67,7 @@ public static int getClientJVMBits() { } @LauncherAPI - public static long getJVMTotalMemory() { + public static int getJVMTotalMemory() { if (getClientJVMBits() == 32) { return Math.min(getTotalMemory(), 1536); } else { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java b/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java index eaa6ba8a..480f52ce 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java @@ -6,8 +6,6 @@ public class LauncherSSLContext { public SSLServerSocketFactory ssf; public SSLSocketFactory sf; - @SuppressWarnings("unused") - private SSLContext sc; public LauncherSSLContext(KeyStore ks, String keypassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { TrustManager[] trustAllCerts = new TrustManager[]{ From aa3a5b447a70cc2ed5d49f73c3df46c932a9035d Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 28 Apr 2019 15:15:12 +0300 Subject: [PATCH 15/26] =?UTF-8?q?[FIX][CRITICAL]=20=D0=9E=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=20=D0=B2=20=D0=B4=D0=B5=D1=84=D0=BE=D0=BB?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=D0=BC=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3?= =?UTF-8?q?=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=BC=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 5709d4f5..ff3b71f2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -756,8 +756,8 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.legacyAddress = address; newConfig.netty.address = "ws://" + address + ":9274/api"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; - newConfig.netty.launcherURL = "http://" + address + ":9274/internal/Launcher.jar"; - newConfig.netty.launcherEXEURL = "http://" + address + ":9274/internal/Launcher.exe"; + newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar"; + newConfig.netty.launcherEXEURL = "http://" + address + ":9274/Launcher.exe"; newConfig.netty.sendExceptionEnabled = true; // Write LaunchServer config From e172cb194a61f182ddd5cf6f1b64f56c3f9f703e Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sun, 28 Apr 2019 15:20:51 +0300 Subject: [PATCH 16/26] =?UTF-8?q?[FIX]=20=D0=95=D1=89=D1=91=20=D0=BE=D0=B4?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B5,=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=83=D1=8E=20=D0=BD=D0=B5=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=87=D0=B0=D0=BB=D0=B8=20=D1=81=204.5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index ff3b71f2..f0309cc5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -680,6 +680,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { Config newConfig = new Config(); newConfig.mirrors = new String[]{"http://mirror.gravitlauncher.ml/", "https://mirror.gravit.pro/"}; newConfig.launch4j = new ExeConf(); + newConfig.launch4j.enabled = true; newConfig.launch4j.copyright = "© GravitLauncher Team"; newConfig.launch4j.fileDesc = "GravitLauncher ".concat(Launcher.getVersion().getVersionString()); newConfig.launch4j.fileVer = Launcher.getVersion().getVersionString().concat(".").concat(String.valueOf(Launcher.getVersion().patch)); From 91d26907614d999b03ae934369d50cd8b0ec81ba Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Mon, 29 Apr 2019 03:30:56 +0200 Subject: [PATCH 17/26] =?UTF-8?q?[FIX]=20=D0=AD=D0=BA=D1=81=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D1=84=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=D0=BC=20=D1=80=D0=B5=D0=BA=D0=BE=D0=BD=D0=BD?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/LauncherEngine.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 6990a706..f0b096ce 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.managers.ConsoleManager; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.auth.RestoreSessionRequest; import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.EnvHelper; @@ -71,11 +72,27 @@ public void start(String... args) throws Throwable { if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider(); runtimeProvider.init(false); runtimeProvider.preLoad(); - if(Request.service != null) + if(Request.service == null) { String address = Launcher.getConfig().address; LogHelper.debug("Start async connection to %s", address); Request.service = StandartClientWebSocketService.initWebSockets(address, true); + Request.service.reconnectCallback = () -> + { + LogHelper.debug("WebSocket connect closed. Try reconnect"); + try { + if (!Request.service.reconnectBlocking()) LogHelper.error("Error connecting"); + LogHelper.debug("Connect to %s", Launcher.getConfig().address); + } catch (InterruptedException e) { + e.printStackTrace(); + } + try { + RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); + request1.request(); + } catch (Exception e) { + LogHelper.error(e); + } + }; } LauncherGuardManager.initGuard(false); Objects.requireNonNull(args, "args"); From 9480e94778d2dbaf1e51f16ad76fa70d008226a5 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 10:19:47 +0700 Subject: [PATCH 18/26] =?UTF-8?q?[FEATURE][EXPERIMENTAL]=20Netty=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=B0=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=B1?= =?UTF-8?q?=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA=D0=B8=20=D0=B2?= =?UTF-8?q?=D0=B5=D0=B1=D1=81=D0=BE=D0=BA=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/build.gradle | 3 +- .../ru/gravit/launcher/LauncherEngine.java | 4 +- .../launcher/client/ClientLauncher.java | 4 +- LauncherAPI/build.gradle | 2 +- .../request/websockets/ClientJSONPoint.java | 98 +++++++++++++++---- .../websockets/ClientWebSocketService.java | 49 +++------- .../StandartClientWebSocketService.java | 15 ++- .../websockets/WebSocketClientHandler.java | 97 ++++++++++++++++++ .../gravit/launcher/server/ServerWrapper.java | 4 +- 9 files changed, 212 insertions(+), 64 deletions(-) create mode 100644 LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java diff --git a/Launcher/build.gradle b/Launcher/build.gradle index f01e92e7..cb817a76 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -30,6 +30,7 @@ shadowJar { classifier = null relocate 'org.objectweb.asm', 'ru.gravit.repackage.org.objectweb.asm' + relocate 'io.netty', 'ru.gravit.repackage.io.netty' configurations = [project.configurations.pack] exclude 'module-info.class' } @@ -39,7 +40,7 @@ pack project(':LauncherAPI') // Not error on obf. bundle 'com.github.oshi:oshi-core:3.13.0' bundle 'com.jfoenix:jfoenix:8.0.8' bundle 'de.jensd:fontawesomefx:8.9' - bundle 'org.fusesource.jansi:jansi:1.17.1' + pack 'io.netty:netty-all:4.1.32.Final' pack 'org.ow2.asm:asm-tree:7.1' } diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index f0b096ce..d976e31a 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -81,9 +81,9 @@ public void start(String... args) throws Throwable { { LogHelper.debug("WebSocket connect closed. Try reconnect"); try { - if (!Request.service.reconnectBlocking()) LogHelper.error("Error connecting"); + Request.service.open(); LogHelper.debug("Connect to %s", Launcher.getConfig().address); - } catch (InterruptedException e) { + } catch (Exception e) { e.printStackTrace(); } try { 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 3d8d118a..a762b11c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -459,9 +459,9 @@ public static void main(String... args) throws Throwable { { LogHelper.debug("WebSocket connect closed. Try reconnect"); try { - if (!Request.service.reconnectBlocking()) LogHelper.error("Error connecting"); + Request.service.open(); LogHelper.debug("Connect to %s", Launcher.getConfig().address); - } catch (InterruptedException e) { + } catch (Exception e) { e.printStackTrace(); } try { diff --git a/LauncherAPI/build.gradle b/LauncherAPI/build.gradle index 0f04a4d3..ad4e07c0 100644 --- a/LauncherAPI/build.gradle +++ b/LauncherAPI/build.gradle @@ -3,7 +3,7 @@ dependencies { compile project(':libLauncher') - compile 'org.java-websocket:Java-WebSocket:1.3.9' + compileOnly 'io.netty:netty-all:4.1.32.Final' compile 'org.apache.httpcomponents:httpclient:4.5.7' compileOnly 'com.google.guava:guava:26.0-jre' compile files('../compat/authlib/authlib-clean.jar') diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java index a09f1241..40735fab 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -1,36 +1,100 @@ package ru.gravit.launcher.request.websockets; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.drafts.Draft_6455; -import org.java_websocket.handshake.ServerHandshake; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.*; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.http.HttpClientCodec; +import io.netty.handler.codec.http.HttpHeaders; +import io.netty.handler.codec.http.HttpObjectAggregator; +import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; +import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; +import io.netty.handler.codec.http.websocketx.WebSocketVersion; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; import ru.gravit.utils.helper.LogHelper; +import java.io.IOException; import java.net.URI; import java.util.Map; -public class ClientJSONPoint extends WebSocketClient { +public class ClientJSONPoint { - public ClientJSONPoint(URI serverUri, Map httpHeaders, int connectTimeout) { - super(serverUri, new Draft_6455(), httpHeaders, connectTimeout); + private final URI uri; + private Channel ch; + private static final EventLoopGroup group = new NioEventLoopGroup(); + protected WebSocketClientHandler webSocketClientHandler; + + public ClientJSONPoint(final String uri) { + this.uri = URI.create(uri); } - @Override - public void onOpen(ServerHandshake handshakedata) { - + public ClientJSONPoint(URI uri) { + this.uri = uri; } - @Override - public void onMessage(String message) { + public void open() throws Exception { + Bootstrap b = new Bootstrap(); + String protocol = uri.getScheme(); + if (!"ws".equals(protocol) && !"wss".equals(protocol)) { + throw new IllegalArgumentException("Unsupported protocol: " + protocol); + } + boolean ssl = false; + if("wss".equals(protocol)) + { + ssl = true; + } + final SslContext sslCtx; + if (ssl) { + sslCtx = SslContextBuilder.forClient().build(); + } else { + sslCtx = null; + } + + // Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00. + // If you change it to V00, ping is not supported and remember to change + // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline. + webSocketClientHandler = + new WebSocketClientHandler( + WebSocketClientHandshakerFactory.newHandshaker( + uri, WebSocketVersion.V13, null, false, HttpHeaders.EMPTY_HEADERS, 1280000)); + + b.group(group) + .channel(NioSocketChannel.class) + .handler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel ch) throws Exception { + ChannelPipeline pipeline = ch.pipeline(); + if (sslCtx != null) { + pipeline.addLast(sslCtx.newHandler(ch.alloc())); + } + pipeline.addLast("http-codec", new HttpClientCodec()); + pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); + pipeline.addLast("ws-handler", webSocketClientHandler); + } + }); + + //System.out.println("WebSocket Client connecting"); + ch = b.connect(uri.getHost(), uri.getPort()).sync().channel(); + webSocketClientHandler.handshakeFuture().sync(); + } + public ChannelFuture send(String text) + { + LogHelper.dev("Send: %s", text); + return ch.writeAndFlush(new TextWebSocketFrame(text)); } - @Override - public void onClose(int code, String reason, boolean remote) { - LogHelper.debug("Disconnected: " + code + " " + remote + " " + reason != null ? reason : "no reason"); + public void close() throws InterruptedException { + //System.out.println("WebSocket Client sending close"); + ch.writeAndFlush(new CloseWebSocketFrame()); + ch.closeFuture().sync(); + //group.shutdownGracefully(); } - @Override - public void onError(Exception ex) { - LogHelper.error(ex); + public void eval(final String text) throws IOException { + ch.writeAndFlush(new TextWebSocketFrame(text)); } } \ No newline at end of file diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 395aaf4a..5e995190 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -2,7 +2,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.java_websocket.handshake.ServerHandshake; import ru.gravit.launcher.events.ExceptionEvent; import ru.gravit.launcher.events.request.*; import ru.gravit.launcher.hasher.HashedEntry; @@ -13,7 +12,6 @@ import java.io.IOException; import java.lang.reflect.Type; import java.net.URI; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -28,7 +26,7 @@ public class ClientWebSocketService extends ClientJSONPoint { private HashSet handlers; public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) { - super(createURL(address), Collections.emptyMap(), i); + super(createURL(address)); requests = new HashMap<>(); results = new HashMap<>(); handlers = new HashSet<>(); @@ -51,33 +49,16 @@ private static URI createURL(String address) { } @Override - public void onMessage(String message) { - ResultInterface result = gson.fromJson(message, ResultInterface.class); - for (EventHandler handler : handlers) { - handler.process(result); - } + public void open() throws Exception { + super.open(); + webSocketClientHandler.onMessageCallback = (message) -> { + ResultInterface result = gson.fromJson(message, ResultInterface.class); + for (EventHandler handler : handlers) { + handler.process(result); + } + }; } - @Override - public void onError(Exception e) { - LogHelper.error(e); - } - @Override - public void onOpen(ServerHandshake handshakedata) { - //Notify open - synchronized (onConnect) - { - onConnect.notifyAll(); - } - } - - @Override - public void onClose(int code, String reason, boolean remote) - { - LogHelper.debug("Disconnected: " + code + " " + remote + " " + (reason != null ? reason : "no reason")); - if(onCloseCallback != null) - onCloseCallback.onClose(code, reason, remote); - } @FunctionalInterface public interface OnCloseCallback { @@ -136,7 +117,7 @@ public void registerHandler(EventHandler eventHandler) { } public void waitIfNotConnected() { - if(!isOpen() && !isClosed() && !isClosing()) + /*if(!isOpen() && !isClosed() && !isClosing()) { LogHelper.warning("WebSocket not connected. Try wait onConnect object"); synchronized (onConnect) @@ -147,20 +128,20 @@ public void waitIfNotConnected() LogHelper.error(e); } } - } + }*/ } public void sendObject(Object obj) throws IOException { waitIfNotConnected(); - if(isClosed() && reconnectCallback != null) - reconnectCallback.onReconnect(); + //if(isClosed() && reconnectCallback != null) + // reconnectCallback.onReconnect(); send(gson.toJson(obj, RequestInterface.class)); } public void sendObject(Object obj, Type type) throws IOException { waitIfNotConnected(); - if(isClosed() && reconnectCallback != null) - reconnectCallback.onReconnect(); + //if(isClosed() && reconnectCallback != null) + // reconnectCallback.onReconnect(); send(gson.toJson(obj, type)); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 68b2ff3c..234bd257 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -108,20 +108,25 @@ public static StandartClientWebSocketService initWebSockets(String address, bool if(!async) { try { - if (!service.connectBlocking()) LogHelper.error("Error connecting"); + service.open(); LogHelper.debug("Connect to %s", address); - } catch (InterruptedException e) { + } catch (Exception e) { e.printStackTrace(); } } else { - service.connect(); + try { + service.open(); + } catch (Exception e) { + e.printStackTrace(); + } } JVMHelper.RUNTIME.addShutdownHook(new Thread(() -> { try { - if(service.isOpen()) - service.closeBlocking(); + //if(service.isOpen()) + // service.closeBlocking(); + service.close(); } catch (InterruptedException e) { LogHelper.error(e); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java new file mode 100644 index 00000000..2fc12055 --- /dev/null +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -0,0 +1,97 @@ +package ru.gravit.launcher.request.websockets; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; +import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; +import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; +import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; +import io.netty.handler.codec.http.websocketx.WebSocketFrame; +import io.netty.util.CharsetUtil; +import ru.gravit.utils.helper.LogHelper; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class WebSocketClientHandler extends SimpleChannelInboundHandler { + + private final WebSocketClientHandshaker handshaker; + private ChannelPromise handshakeFuture; + interface OnMessageCallback + { + void onMessage(String text); + } + public OnMessageCallback onMessageCallback; + + public WebSocketClientHandler(final WebSocketClientHandshaker handshaker) { + this.handshaker = handshaker; + } + + public ChannelFuture handshakeFuture() { + return handshakeFuture; + } + + @Override + public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { + handshakeFuture = ctx.newPromise(); + } + + @Override + public void channelActive(final ChannelHandlerContext ctx) throws Exception { + handshaker.handshake(ctx.channel()); + } + + @Override + public void channelInactive(final ChannelHandlerContext ctx) throws Exception { + //System.out.println("WebSocket Client disconnected!"); + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { + final Channel ch = ctx.channel(); + if (!handshaker.isHandshakeComplete()) { + // web socket client connected + handshaker.finishHandshake(ch, (FullHttpResponse) msg); + handshakeFuture.setSuccess(); + return; + } + + if (msg instanceof FullHttpResponse) { + final FullHttpResponse response = (FullHttpResponse) msg; + throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content=" + + response.content().toString(CharsetUtil.UTF_8) + ')'); + } + + final WebSocketFrame frame = (WebSocketFrame) msg; + if (frame instanceof TextWebSocketFrame) { + final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; + if(onMessageCallback != null) onMessageCallback.onMessage(textFrame.text()); + LogHelper.dev("Message: %s", textFrame.text()); + // uncomment to print request + // logger.info(textFrame.text()); + } else if (frame instanceof PongWebSocketFrame) { + } else if (frame instanceof CloseWebSocketFrame) + ch.close(); + else if (frame instanceof BinaryWebSocketFrame) { + // uncomment to print request + // logger.info(frame.content().toString()); + } + + } + + @Override + public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { + cause.printStackTrace(); + + if (!handshakeFuture.isDone()) { + handshakeFuture.setFailure(cause); + } + + ctx.close(); + } +} \ No newline at end of file diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index 56b946ce..98d554f1 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -162,9 +162,9 @@ public void run(String... args) throws Throwable { { LogHelper.debug("WebSocket connect closed. Try reconnect"); try { - if (!Request.service.reconnectBlocking()) LogHelper.error("Error connecting"); + Request.service.open(); LogHelper.debug("Connect to %s", config.websocket.address); - } catch (InterruptedException e) { + } catch (Exception e) { e.printStackTrace(); } auth(); From 1cc08204e5cbc7d14867ab078ce132a4c0616e71 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 11:00:37 +0700 Subject: [PATCH 19/26] =?UTF-8?q?[FEATURE][EXPERIMENTAL]=20=D0=98=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=20Netty=20=D0=BD=D0=B0=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/websockets/ClientJSONPoint.java | 50 +++++++++---------- .../websockets/ClientWebSocketService.java | 24 +++++---- .../StandartClientWebSocketService.java | 11 +++- .../websockets/WebSocketClientHandler.java | 7 ++- 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java index 40735fab..91f1b554 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -5,8 +5,8 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.http.EmptyHttpHeaders; import io.netty.handler.codec.http.HttpClientCodec; -import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; @@ -16,27 +16,33 @@ import io.netty.handler.ssl.SslContextBuilder; import ru.gravit.utils.helper.LogHelper; +import javax.net.ssl.SSLException; import java.io.IOException; import java.net.URI; -import java.util.Map; -public class ClientJSONPoint { +public abstract class ClientJSONPoint { private final URI uri; - private Channel ch; + protected Channel ch; private static final EventLoopGroup group = new NioEventLoopGroup(); protected WebSocketClientHandler webSocketClientHandler; + protected Bootstrap bootstrap = new Bootstrap(); + public boolean isClosed; - public ClientJSONPoint(final String uri) { - this.uri = URI.create(uri); + public ClientJSONPoint(final String uri) throws SSLException { + this(URI.create(uri)); } - public ClientJSONPoint(URI uri) { + public ClientJSONPoint(URI uri) throws SSLException { this.uri = uri; - } + // Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00. + // If you change it to V00, ping is not supported and remember to change + // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline. + webSocketClientHandler = + new WebSocketClientHandler( + WebSocketClientHandshakerFactory.newHandshaker( + uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this); - public void open() throws Exception { - Bootstrap b = new Bootstrap(); String protocol = uri.getScheme(); if (!"ws".equals(protocol) && !"wss".equals(protocol)) { throw new IllegalArgumentException("Unsupported protocol: " + protocol); @@ -49,19 +55,8 @@ public void open() throws Exception { final SslContext sslCtx; if (ssl) { sslCtx = SslContextBuilder.forClient().build(); - } else { - sslCtx = null; - } - - // Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00. - // If you change it to V00, ping is not supported and remember to change - // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline. - webSocketClientHandler = - new WebSocketClientHandler( - WebSocketClientHandshakerFactory.newHandshaker( - uri, WebSocketVersion.V13, null, false, HttpHeaders.EMPTY_HEADERS, 1280000)); - - b.group(group) + } else sslCtx = null; + bootstrap.group(group) .channel(NioSocketChannel.class) .handler(new ChannelInitializer() { @Override @@ -74,10 +69,12 @@ public void initChannel(SocketChannel ch) throws Exception { pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); pipeline.addLast("ws-handler", webSocketClientHandler); } - }); + }); + } + public void open() throws Exception { //System.out.println("WebSocket Client connecting"); - ch = b.connect(uri.getHost(), uri.getPort()).sync().channel(); + ch = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel(); webSocketClientHandler.handshakeFuture().sync(); } public ChannelFuture send(String text) @@ -85,9 +82,12 @@ public ChannelFuture send(String text) LogHelper.dev("Send: %s", text); return ch.writeAndFlush(new TextWebSocketFrame(text)); } + abstract void onMessage(String message) throws Exception; + abstract void onDisconnect() throws Exception; public void close() throws InterruptedException { //System.out.println("WebSocket Client sending close"); + isClosed = true; ch.writeAndFlush(new CloseWebSocketFrame()); ch.closeFuture().sync(); //group.shutdownGracefully(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 5e995190..2a39a54f 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.helper.LogHelper; +import javax.net.ssl.SSLException; import java.io.IOException; import java.lang.reflect.Type; import java.net.URI; @@ -25,7 +26,7 @@ public class ClientWebSocketService extends ClientJSONPoint { private HashMap> results; private HashSet handlers; - public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) { + public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { super(createURL(address)); requests = new HashMap<>(); results = new HashMap<>(); @@ -49,14 +50,17 @@ private static URI createURL(String address) { } @Override - public void open() throws Exception { - super.open(); - webSocketClientHandler.onMessageCallback = (message) -> { - ResultInterface result = gson.fromJson(message, ResultInterface.class); - for (EventHandler handler : handlers) { - handler.process(result); - } - }; + void onMessage(String message) { + ResultInterface result = gson.fromJson(message, ResultInterface.class); + for (EventHandler handler : handlers) { + handler.process(result); + } + } + + @Override + void onDisconnect() { + LogHelper.info("WebSocket client disconnect"); + if(onCloseCallback != null) onCloseCallback.onClose(0,"unsupported param", !isClosed); } @FunctionalInterface @@ -133,6 +137,7 @@ public void waitIfNotConnected() public void sendObject(Object obj) throws IOException { waitIfNotConnected(); + if(ch == null || !ch.isActive()) reconnectCallback.onReconnect(); //if(isClosed() && reconnectCallback != null) // reconnectCallback.onReconnect(); send(gson.toJson(obj, RequestInterface.class)); @@ -140,6 +145,7 @@ public void sendObject(Object obj) throws IOException { public void sendObject(Object obj, Type type) throws IOException { waitIfNotConnected(); + if(ch == null || !ch.isActive()) reconnectCallback.onReconnect(); //if(isClosed() && reconnectCallback != null) // reconnectCallback.onReconnect(); send(gson.toJson(obj, type)); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 234bd257..54ac6940 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -8,6 +8,7 @@ import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.LogHelper; +import javax.net.ssl.SSLException; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -15,7 +16,7 @@ public class StandartClientWebSocketService extends ClientWebSocketService { public WaitEventHandler waitEventHandler = new WaitEventHandler(); - public StandartClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) { + public StandartClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { super(gsonBuilder, address, i); } public class RequestFuture implements Future @@ -101,7 +102,13 @@ public RequestFuture asyncSendRequest(RequestInterface request) throws IOExcepti } public static StandartClientWebSocketService initWebSockets(String address, boolean async) { - StandartClientWebSocketService service = new StandartClientWebSocketService(new GsonBuilder(), address, 5000); + StandartClientWebSocketService service; + try { + service = new StandartClientWebSocketService(new GsonBuilder(), address, 5000); + } catch (SSLException e) { + LogHelper.error(e); + return null; + } service.registerResults(); service.registerRequests(); service.registerHandler(service.waitEventHandler); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java index 2fc12055..41d98c39 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -21,6 +21,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler { private final WebSocketClientHandshaker handshaker; + private final ClientJSONPoint clientJSONPoint; private ChannelPromise handshakeFuture; interface OnMessageCallback { @@ -28,8 +29,9 @@ interface OnMessageCallback } public OnMessageCallback onMessageCallback; - public WebSocketClientHandler(final WebSocketClientHandshaker handshaker) { + public WebSocketClientHandler(final WebSocketClientHandshaker handshaker, ClientJSONPoint clientJSONPoint) { this.handshaker = handshaker; + this.clientJSONPoint = clientJSONPoint; } public ChannelFuture handshakeFuture() { @@ -49,6 +51,7 @@ public void channelActive(final ChannelHandlerContext ctx) throws Exception { @Override public void channelInactive(final ChannelHandlerContext ctx) throws Exception { //System.out.println("WebSocket Client disconnected!"); + clientJSONPoint.onDisconnect(); } @Override @@ -70,7 +73,7 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except final WebSocketFrame frame = (WebSocketFrame) msg; if (frame instanceof TextWebSocketFrame) { final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; - if(onMessageCallback != null) onMessageCallback.onMessage(textFrame.text()); + clientJSONPoint.onMessage(textFrame.text()); LogHelper.dev("Message: %s", textFrame.text()); // uncomment to print request // logger.info(textFrame.text()); From 323cfe763adc7725ca62755811a472ae1eb233c4 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 13:38:35 +0700 Subject: [PATCH 20/26] =?UTF-8?q?[FEATURE][EXPERIMENTAL]=20onOpen=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/request/websockets/ClientJSONPoint.java | 1 + .../request/websockets/ClientWebSocketService.java | 8 ++++++++ .../request/websockets/WebSocketClientHandler.java | 10 +++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java index 91f1b554..be03e5f4 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -84,6 +84,7 @@ public ChannelFuture send(String text) } abstract void onMessage(String message) throws Exception; abstract void onDisconnect() throws Exception; + abstract void onOpen() throws Exception; public void close() throws InterruptedException { //System.out.println("WebSocket Client sending close"); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 2a39a54f..b47ccf66 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -63,6 +63,14 @@ void onDisconnect() { if(onCloseCallback != null) onCloseCallback.onClose(0,"unsupported param", !isClosed); } + @Override + void onOpen() throws Exception { + synchronized (onConnect) + { + onConnect.notifyAll(); + } + } + @FunctionalInterface public interface OnCloseCallback { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java index 41d98c39..da494a72 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -23,11 +23,6 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler private final WebSocketClientHandshaker handshaker; private final ClientJSONPoint clientJSONPoint; private ChannelPromise handshakeFuture; - interface OnMessageCallback - { - void onMessage(String text); - } - public OnMessageCallback onMessageCallback; public WebSocketClientHandler(final WebSocketClientHandshaker handshaker, ClientJSONPoint clientJSONPoint) { this.handshaker = handshaker; @@ -46,6 +41,7 @@ public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { handshaker.handshake(ctx.channel()); + clientJSONPoint.onOpen(); } @Override @@ -66,7 +62,7 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except if (msg instanceof FullHttpResponse) { final FullHttpResponse response = (FullHttpResponse) msg; - throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content=" + throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.status() + ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')'); } @@ -89,7 +85,7 @@ else if (frame instanceof BinaryWebSocketFrame) { @Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { - cause.printStackTrace(); + LogHelper.error(cause); if (!handshakeFuture.isDone()) { handshakeFuture.setFailure(cause); From a921fde598c0f9af50c4ebf8dd73404207e5e6c5 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Mon, 29 Apr 2019 09:56:39 +0300 Subject: [PATCH 21/26] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=BF=D0=B0=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20netty=20=D0=B2=20ServerWrapper.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/defaults/proguard.cfg | 4 ++-- Launcher/build.gradle | 3 ++- LauncherAPI/build.gradle | 2 +- ServerWrapper/build.gradle | 22 ++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg index 4c93356a..b2e34d42 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg @@ -20,9 +20,9 @@ -keepattributes Signature -adaptresourcefilecontents META-INF/MANIFEST.MF --keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.**,org.slf4j.**,oshi.jna.**,com.sun.jna.**,org.apache.commons.logging.**, org.fusesource.**, com.jfoenix.** +-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,ru.gravit.repackage.**,org.fusesource.** --keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.**,org.slf4j.**,oshi.jna.**,com.sun.jna.**,org.apache.commons.logging.**, org.fusesource.**, com.jfoenix.** { +-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,ru.gravit.repackage.**,org.fusesource.** { *; } diff --git a/Launcher/build.gradle b/Launcher/build.gradle index cb817a76..904fba57 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -36,10 +36,11 @@ } dependencies { - pack project(':LauncherAPI') // Not error on obf. + pack project(':LauncherAPI') bundle 'com.github.oshi:oshi-core:3.13.0' bundle 'com.jfoenix:jfoenix:8.0.8' bundle 'de.jensd:fontawesomefx:8.9' + bundle 'org.apache.httpcomponents:httpclient:4.5.7' pack 'io.netty:netty-all:4.1.32.Final' pack 'org.ow2.asm:asm-tree:7.1' } diff --git a/LauncherAPI/build.gradle b/LauncherAPI/build.gradle index ad4e07c0..6c28c79d 100644 --- a/LauncherAPI/build.gradle +++ b/LauncherAPI/build.gradle @@ -4,7 +4,7 @@ dependencies { compile project(':libLauncher') compileOnly 'io.netty:netty-all:4.1.32.Final' - compile 'org.apache.httpcomponents:httpclient:4.5.7' + compileOnly 'org.apache.httpcomponents:httpclient:4.5.7' compileOnly 'com.google.guava:guava:26.0-jre' compile files('../compat/authlib/authlib-clean.jar') } diff --git a/ServerWrapper/build.gradle b/ServerWrapper/build.gradle index 4ec8ef0a..241d2b17 100644 --- a/ServerWrapper/build.gradle +++ b/ServerWrapper/build.gradle @@ -1,6 +1,12 @@ +apply plugin: 'com.github.johnrengelman.shadow' + String mainClassName = "ru.gravit.launcher.server.ServerWrapper" String mainAgentName = "ru.gravit.launcher.server.ServerAgent" +configurations { + pack + compile.extendsFrom pack +} repositories { maven { @@ -12,6 +18,7 @@ targetCompatibility = '1.8' jar { + classifier = 'clean' from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } manifest.attributes("Main-Class": mainClassName, "Premain-Class": mainAgentName, @@ -21,5 +28,18 @@ } dependencies { - compile project(':LauncherAPI') + pack project(':LauncherAPI') + pack 'org.apache.httpcomponents:httpclient:4.5.7' + pack 'io.netty:netty-all:4.1.32.Final' } + +shadowJar { + classifier = null + relocate 'io.netty', 'ru.gravit.repackage.io.netty' + configurations = [project.configurations.pack] + exclude 'module-info.class' + } + + + build.dependsOn tasks.shadowJar + \ No newline at end of file From edc5f1f7b2da52575b7581413f1645891fa08353 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 15:35:51 +0700 Subject: [PATCH 22/26] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B3=D0=BE=D0=BD=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BA=D0=BE=D0=B2,=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20reconnect=20loop,?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=88=D0=B5=D0=BD=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/LauncherEngine.java | 4 +++- .../launcher/client/ClientLauncher.java | 4 +++- .../request/websockets/ClientJSONPoint.java | 20 +++++++++---------- .../websockets/WebSocketClientHandler.java | 4 ---- .../gravit/launcher/server/ServerWrapper.java | 4 +++- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index d976e31a..0d0a657a 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.managers.ConsoleManager; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.request.auth.RestoreSessionRequest; import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.CommonHelper; @@ -84,7 +85,8 @@ public void start(String... args) throws Throwable { Request.service.open(); LogHelper.debug("Connect to %s", Launcher.getConfig().address); } catch (Exception e) { - e.printStackTrace(); + LogHelper.error(e); + throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null")); } try { RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); 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 a762b11c..e3dc7e66 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.request.auth.RestoreSessionRequest; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -462,7 +463,8 @@ public static void main(String... args) throws Throwable { Request.service.open(); LogHelper.debug("Connect to %s", Launcher.getConfig().address); } catch (Exception e) { - e.printStackTrace(); + LogHelper.error(e); + throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null")); } try { RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java index be03e5f4..22e0c07d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -35,14 +35,6 @@ public ClientJSONPoint(final String uri) throws SSLException { public ClientJSONPoint(URI uri) throws SSLException { this.uri = uri; - // Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00. - // If you change it to V00, ping is not supported and remember to change - // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline. - webSocketClientHandler = - new WebSocketClientHandler( - WebSocketClientHandshakerFactory.newHandshaker( - uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this); - String protocol = uri.getScheme(); if (!"ws".equals(protocol) && !"wss".equals(protocol)) { throw new IllegalArgumentException("Unsupported protocol: " + protocol); @@ -74,6 +66,10 @@ public void initChannel(SocketChannel ch) throws Exception { public void open() throws Exception { //System.out.println("WebSocket Client connecting"); + webSocketClientHandler = + new WebSocketClientHandler( + WebSocketClientHandshakerFactory.newHandshaker( + uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this); ch = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel(); webSocketClientHandler.handshakeFuture().sync(); } @@ -89,8 +85,12 @@ public ChannelFuture send(String text) public void close() throws InterruptedException { //System.out.println("WebSocket Client sending close"); isClosed = true; - ch.writeAndFlush(new CloseWebSocketFrame()); - ch.closeFuture().sync(); + if(ch != null && ch.isActive()) + { + ch.writeAndFlush(new CloseWebSocketFrame()); + ch.closeFuture().sync(); + } + //group.shutdownGracefully(); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java index da494a72..7d185225 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -14,10 +14,6 @@ import io.netty.handler.codec.http.websocketx.WebSocketFrame; import io.netty.util.CharsetUtil; import ru.gravit.utils.helper.LogHelper; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ public class WebSocketClientHandler extends SimpleChannelInboundHandler { private final WebSocketClientHandshaker handshaker; diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index 98d554f1..15710be1 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -6,6 +6,7 @@ import ru.gravit.launcher.events.request.ProfilesRequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.request.auth.AuthRequest; import ru.gravit.launcher.request.update.ProfilesRequest; import ru.gravit.launcher.server.setup.ServerWrapperSetup; @@ -165,7 +166,8 @@ public void run(String... args) throws Throwable { Request.service.open(); LogHelper.debug("Connect to %s", config.websocket.address); } catch (Exception e) { - e.printStackTrace(); + LogHelper.error(e); + throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null")); } auth(); }; From 72ce4234a3f5009ab4ed16802483961263d85425 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 15:56:19 +0700 Subject: [PATCH 23/26] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20NPE=20=D0=B2=20AuthResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/websocket/json/auth/AuthResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java index 1ff9a85f..8059d02e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java @@ -60,7 +60,7 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti try { AuthRequestEvent result = new AuthRequestEvent(); String ip = IOHelper.getIP(ctx.channel().remoteAddress()); - if ((authType == null || authType == ConnectTypes.CLIENT) && !clientData.checkSign) { + if ((authType == null || authType == ConnectTypes.CLIENT) && ( clientData == null || !clientData.checkSign )) { AuthProvider.authError("Don't skip Launcher Update"); return; } From 02c8ee49995aa98a9b1b2b22ffe8c952e16cd484 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 15:59:30 +0700 Subject: [PATCH 24/26] =?UTF-8?q?[FIX]=20=D0=92=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=B2=D1=8B=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D1=8F=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20Netty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 2 ++ .../ru/gravit/launchserver/websocket/LauncherNettyServer.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index f0309cc5..08bb893f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -1,5 +1,6 @@ package ru.gravit.launchserver; +import io.netty.handler.logging.LogLevel; import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.NeedGarbageCollection; @@ -280,6 +281,7 @@ public class NettyConfig { public Map bindings = new HashMap<>(); public NettyPerformanceConfig performance; public NettyBindAddress[] binds; + public LogLevel logLevel = LogLevel.DEBUG; } public class NettyPerformanceConfig { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java index 0df2a864..0259bdc9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java @@ -32,7 +32,7 @@ public LauncherNettyServer() { serverBootstrap = new ServerBootstrap(); serverBootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) - .handler(new LoggingHandler(LogLevel.DEBUG)) + .handler(new LoggingHandler(config.logLevel)) .childHandler(new ChannelInitializer() { @Override public void initChannel(NioSocketChannel ch) { From f820271418573ff1ba7e26aab8447ce94517de4d Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 16:08:43 +0700 Subject: [PATCH 25/26] =?UTF-8?q?[FIX]=20Radon=20=D0=B2=D1=8B=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B5=D0=BD=20=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE?= =?UTF-8?q?=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 08bb893f..94f4db54 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -721,7 +721,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.threadCoreCount = 0; // on your own newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); - newConfig.enabledRadon = true; + newConfig.enabledRadon = false; newConfig.enabledProGuard = true; newConfig.stripLineNumbers = true; newConfig.deleteTempFiles = true; From adb8091ff3fa248e666529972e7f6bc85759b6ab Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 29 Apr 2019 16:16:33 +0700 Subject: [PATCH 26/26] [ANY] 5.0.0b3 beta --- libLauncher/src/main/java/ru/gravit/launcher/Launcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java index 81ad3e3d..d11cfafa 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java @@ -60,7 +60,7 @@ public final class Launcher { public static final int MAJOR = 5; public static final int MINOR = 0; public static final int PATCH = 0; - public static final int BUILD = 2; + public static final int BUILD = 3; public static final Version.Type RELEASE = Version.Type.BETA; public static GsonManager gsonManager;