mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev
This commit is contained in:
commit
0d31257625
7 changed files with 38 additions and 11 deletions
|
@ -81,6 +81,7 @@ pack project(':LauncherAPI')
|
||||||
bundle 'org.fusesource.jansi:jansi:1.18'
|
bundle 'org.fusesource.jansi:jansi:1.18'
|
||||||
bundle 'commons-io:commons-io:2.6'
|
bundle 'commons-io:commons-io:2.6'
|
||||||
bundle 'commons-codec:commons-codec:1.12'
|
bundle 'commons-codec:commons-codec:1.12'
|
||||||
|
bundle 'org.apache.httpcomponents:httpclient:4.5.7'
|
||||||
bundle 'org.javassist:javassist:3.25.0-GA'
|
bundle 'org.javassist:javassist:3.25.0-GA'
|
||||||
bundle 'io.netty:netty-all:4.1.36.Final'
|
bundle 'io.netty:netty-all:4.1.36.Final'
|
||||||
bundle 'org.hibernate:hibernate-core:5.4.4.Final'
|
bundle 'org.hibernate:hibernate-core:5.4.4.Final'
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ProcessBuilder.Redirect;
|
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.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
@ -390,9 +391,8 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
private LauncherBinary binary() {
|
private LauncherBinary binary() {
|
||||||
if (launcherEXEBinaryClass != null) {
|
if (launcherEXEBinaryClass != null) {
|
||||||
try {
|
try {
|
||||||
return launcherEXEBinaryClass.getConstructor(LaunchServer.class).newInstance(this);
|
return (LauncherBinary) MethodHandles.publicLookup().findConstructor(launcherEXEBinaryClass, MethodType.methodType(void.class, LaunchServer.class)).invoke(this);
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
} catch (Throwable e) {
|
||||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,12 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) {
|
||||||
newConfig.netty.fileServerEnabled = true;
|
newConfig.netty.fileServerEnabled = true;
|
||||||
newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)};
|
newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)};
|
||||||
newConfig.netty.performance = new NettyPerformanceConfig();
|
newConfig.netty.performance = new NettyPerformanceConfig();
|
||||||
|
try {
|
||||||
newConfig.netty.performance.usingEpoll = Epoll.isAvailable();
|
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.bossThread = 2;
|
||||||
newConfig.netty.performance.workerThread = 8;
|
newConfig.netty.performance.workerThread = 8;
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,18 @@ public interface DownloadTotalCallback {
|
||||||
|
|
||||||
public static class DownloadTask {
|
public static class DownloadTask {
|
||||||
public final String apply;
|
public final String apply;
|
||||||
public final long size;
|
public long size;
|
||||||
|
public final String urlApply;
|
||||||
|
|
||||||
public DownloadTask(String apply, long size) {
|
public DownloadTask(String apply, long size) {
|
||||||
this.apply = apply;
|
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;
|
this.size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +78,7 @@ public void download(String base, List<DownloadTask> applies, Path dstDirFile, D
|
||||||
String path = baseUri.getPath();
|
String path = baseUri.getPath();
|
||||||
List<IOException> excs = new CopyOnWriteArrayList<>();
|
List<IOException> excs = new CopyOnWriteArrayList<>();
|
||||||
for (DownloadTask apply : applies) {
|
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);
|
callback.stateChanged(apply.apply, 0L, apply.size);
|
||||||
Path targetPath = dstDirFile.resolve(apply.apply);
|
Path targetPath = dstDirFile.resolve(apply.apply);
|
||||||
toExec.add(() -> {
|
toExec.add(() -> {
|
||||||
|
@ -181,7 +189,9 @@ public Path handleResponse(HttpResponse response) throws IOException {
|
||||||
}
|
}
|
||||||
long contentLength = response.getEntity().getContentLength();
|
long contentLength = response.getEntity().getContentLength();
|
||||||
if (task != null && contentLength != task.size) {
|
if (task != null && contentLength != task.size) {
|
||||||
|
if (task.size > 0)
|
||||||
LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength);
|
LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength);
|
||||||
|
else task.size = contentLength;
|
||||||
}
|
}
|
||||||
if (zip) {
|
if (zip) {
|
||||||
try (ZipInputStream input = IOHelper.newZipInput(source)) {
|
try (ZipInputStream input = IOHelper.newZipInput(source)) {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
import pro.gravit.utils.verify.LauncherTrustManager;
|
import pro.gravit.utils.verify.LauncherTrustManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
public class SimpleModuleManager implements LauncherModulesManager {
|
public class SimpleModuleManager implements LauncherModulesManager {
|
||||||
|
private static final MethodType VOID_TYPE = MethodType.methodType(void.class);
|
||||||
protected final List<LauncherModule> modules = new ArrayList<>();
|
protected final List<LauncherModule> modules = new ArrayList<>();
|
||||||
protected final List<String> moduleNames = new ArrayList<>();
|
protected final List<String> moduleNames = new ArrayList<>();
|
||||||
protected final SimpleModuleContext context;
|
protected final SimpleModuleContext context;
|
||||||
|
@ -149,10 +152,17 @@ public LauncherModule loadModule(Path file) throws IOException {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends LauncherModule> clazz = (Class<? extends LauncherModule>) Class.forName(moduleClass, false, classLoader);
|
Class<? extends LauncherModule> clazz = (Class<? extends LauncherModule>) Class.forName(moduleClass, false, classLoader);
|
||||||
checkModuleClass(clazz, checkMode);
|
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);
|
loadModule(module);
|
||||||
return module;
|
return module;
|
||||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
} catch (ClassNotFoundException | InstantiationException e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
LogHelper.error("In module %s Module-Main-Class incorrect", file.toString());
|
LogHelper.error("In module %s Module-Main-Class incorrect", file.toString());
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -38,6 +38,7 @@ task javadocJar(type: Jar) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
pack project(':LauncherAuthlib')
|
pack project(':LauncherAuthlib')
|
||||||
|
pack 'org.bouncycastle:bcprov-jdk15:1.46'
|
||||||
pack 'org.apache.httpcomponents:httpclient:4.5.7'
|
pack 'org.apache.httpcomponents:httpclient:4.5.7'
|
||||||
pack 'io.netty:netty-codec-http:4.1.36.Final'
|
pack 'io.netty:netty-codec-http:4.1.36.Final'
|
||||||
}
|
}
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 52818e6ef05d90ad678d02e83f9bd4140d8eda34
|
Subproject commit cec48e154a44b3ee51aadda8e2886739445939ec
|
Loading…
Reference in a new issue