From 6b85de280657f4cf429c17893d2bc17e0902a317 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 15 Nov 2019 14:37:43 +0100 Subject: [PATCH 1/4] =?UTF-8?q?[FIX]=20=D0=92=202=20=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=85=20=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B5=D1=84=D0=BB=D0=B5=D0=BA=D1=81=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pro/gravit/launchserver/LaunchServer.java | 8 ++++---- .../launchserver/config/LaunchServerConfig.java | 7 ++++++- .../launcher/modules/impl/SimpleModuleManager.java | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 0b60e7f8..67fae76b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -36,7 +36,8 @@ import java.io.BufferedReader; import java.io.IOException; import java.lang.ProcessBuilder.Redirect; -import java.lang.reflect.InvocationTargetException; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.security.InvalidAlgorithmParameterException; @@ -390,9 +391,8 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La private LauncherBinary binary() { if (launcherEXEBinaryClass != null) { try { - return launcherEXEBinaryClass.getConstructor(LaunchServer.class).newInstance(this); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | NoSuchMethodException | SecurityException e) { + return (LauncherBinary) MethodHandles.publicLookup().findConstructor(launcherEXEBinaryClass, MethodType.methodType(void.class, LaunchServer.class)).invoke(this); + } catch (Throwable e) { LogHelper.error(e); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index d37031be..e2f20159 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -319,7 +319,12 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) { newConfig.netty.fileServerEnabled = true; newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)}; newConfig.netty.performance = new NettyPerformanceConfig(); - newConfig.netty.performance.usingEpoll = Epoll.isAvailable(); + try { + newConfig.netty.performance.usingEpoll = Epoll.isAvailable(); + } catch (Throwable e) { + // Epoll class line 51+ catch (Exception) but Error will be thrown by System.load + newConfig.netty.performance.usingEpoll = false; + } // such as on ARM newConfig.netty.performance.bossThread = 2; newConfig.netty.performance.workerThread = 8; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java index 740fe8b4..16737cd1 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java @@ -10,6 +10,8 @@ import pro.gravit.utils.verify.LauncherTrustManager; import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -29,6 +31,7 @@ import java.util.jar.JarFile; public class SimpleModuleManager implements LauncherModulesManager { + private static final MethodType VOID_TYPE = MethodType.methodType(void.class); protected final List modules = new ArrayList<>(); protected final List moduleNames = new ArrayList<>(); protected final SimpleModuleContext context; @@ -149,10 +152,17 @@ public LauncherModule loadModule(Path file) throws IOException { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(moduleClass, false, classLoader); checkModuleClass(clazz, checkMode); - LauncherModule module = clazz.newInstance(); + if (!LauncherModule.class.isAssignableFrom(clazz)) + throw new ClassNotFoundException("Invalid module class... Not contains LauncherModule in hierarchy."); + LauncherModule module; + try { + module = (LauncherModule) MethodHandles.publicLookup().findConstructor(clazz, VOID_TYPE).invoke(); + } catch (Throwable e) { + throw (InstantiationException) new InstantiationException("Error on instancing...").initCause(e); + } loadModule(module); return module; - } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { + } catch (ClassNotFoundException | InstantiationException e) { LogHelper.error(e); LogHelper.error("In module %s Module-Main-Class incorrect", file.toString()); return null; From 31c32aa2c2ca04a6f2f27e8a4c596cc2a0eeb8be Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Nov 2019 20:38:59 +0300 Subject: [PATCH 2/4] =?UTF-8?q?[FIX]=20=D0=A0=D0=B0=D0=B7=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20url=20=D0=B8=20=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D0=B8=20=D0=B2=20ListDownloader.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/downloader/ListDownloader.java | 16 +++++++++++++--- modules | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java index 643e50e3..741cdf3f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java @@ -47,10 +47,18 @@ public interface DownloadTotalCallback { public static class DownloadTask { public final String apply; - public final long size; + public long size; + public final String urlApply; public DownloadTask(String apply, long size) { this.apply = apply; + urlApply = apply; + this.size = size; + } + + public DownloadTask(String urlApply, String apply, long size) { + this.apply = apply; + this.urlApply = urlApply; this.size = size; } } @@ -70,7 +78,7 @@ public void download(String base, List applies, Path dstDirFile, D String path = baseUri.getPath(); List excs = new CopyOnWriteArrayList<>(); for (DownloadTask apply : applies) { - URI u = new URI(scheme, host, path + apply.apply, "", ""); + URI u = new URI(scheme, host, path + apply.urlApply, "", ""); callback.stateChanged(apply.apply, 0L, apply.size); Path targetPath = dstDirFile.resolve(apply.apply); toExec.add(() -> { @@ -181,7 +189,9 @@ public Path handleResponse(HttpResponse response) throws IOException { } long contentLength = response.getEntity().getContentLength(); if (task != null && contentLength != task.size) { - LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength); + if (task.size > 0) + LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength); + else task.size = contentLength; } if (zip) { try (ZipInputStream input = IOHelper.newZipInput(source)) { diff --git a/modules b/modules index 52818e6e..e098678d 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 52818e6ef05d90ad678d02e83f9bd4140d8eda34 +Subproject commit e098678d7ea2c5e6a926f457dcbc820c4e9fba66 From a841746ac868c20447b12327fd99adf19b4abd40 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Nov 2019 21:14:28 +0300 Subject: [PATCH 3/4] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 1 + ServerWrapper/build.gradle | 1 + modules | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 890bb281..77e444c7 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -81,6 +81,7 @@ pack project(':LauncherAPI') bundle 'org.fusesource.jansi:jansi:1.18' bundle 'commons-io:commons-io:2.6' bundle 'commons-codec:commons-codec:1.12' + bundle 'org.apache.httpcomponents:httpclient:4.5.7' bundle 'org.javassist:javassist:3.25.0-GA' bundle 'io.netty:netty-all:4.1.36.Final' bundle 'org.hibernate:hibernate-core:5.4.4.Final' diff --git a/ServerWrapper/build.gradle b/ServerWrapper/build.gradle index 72d24cec..e4d95236 100644 --- a/ServerWrapper/build.gradle +++ b/ServerWrapper/build.gradle @@ -38,6 +38,7 @@ task javadocJar(type: Jar) { dependencies { pack project(':LauncherAuthlib') + pack 'org.bouncycastle:bcprov-jdk15:1.46' pack 'org.apache.httpcomponents:httpclient:4.5.7' pack 'io.netty:netty-codec-http:4.1.36.Final' } diff --git a/modules b/modules index e098678d..bac8af98 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit e098678d7ea2c5e6a926f457dcbc820c4e9fba66 +Subproject commit bac8af98b5cac38e634a7776b947d01eb30ff873 From 8c1a8235a86ca8c83792036772fdf203939dc5e7 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Nov 2019 21:17:45 +0300 Subject: [PATCH 4/4] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index bac8af98..cec48e15 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit bac8af98b5cac38e634a7776b947d01eb30ff873 +Subproject commit cec48e154a44b3ee51aadda8e2886739445939ec