mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 14:33:04 +03:00
Merge branch 'dev' into feature/antiConf
This commit is contained in:
commit
907e1fe242
8 changed files with 30 additions and 10 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
Collections.addAll(args, MAGIC_ARG);
|
Collections.addAll(args, MAGIC_ARG);
|
||||||
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
||||||
Collections.addAll(args, "-Xmx256M");
|
Collections.addAll(args, "-Xmx256M");
|
||||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
//Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||||
Collections.addAll(args, "-cp");
|
Collections.addAll(args, "-cp");
|
||||||
Collections.addAll(args, pathLauncher);
|
Collections.addAll(args, pathLauncher);
|
||||||
Collections.addAll(args, LauncherEngine.class.getName());
|
Collections.addAll(args, LauncherEngine.class.getName());
|
||||||
|
|
|
@ -54,6 +54,7 @@ public static void main(String... args) throws Throwable {
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
EnvHelper.checkDangerousParams();
|
EnvHelper.checkDangerousParams();
|
||||||
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
||||||
|
JVMHelper.verifyNoAgent();
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
LauncherEngine.checkClass(LauncherEngine.class);
|
LauncherEngine.checkClass(LauncherEngine.class);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import pro.gravit.launcher.modules.LauncherModule;
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
|
|
||||||
public class ClientPreGuiPhase extends LauncherModule.Event {
|
public class ClientPreGuiPhase extends LauncherModule.Event {
|
||||||
public final RuntimeProvider runtimeProvider;
|
public RuntimeProvider runtimeProvider;
|
||||||
|
|
||||||
public ClientPreGuiPhase(RuntimeProvider runtimeProvider) {
|
public ClientPreGuiPhase(RuntimeProvider runtimeProvider) {
|
||||||
this.runtimeProvider = runtimeProvider;
|
this.runtimeProvider = runtimeProvider;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -65,7 +65,7 @@ public WebSocketEvent get() throws InterruptedException, ExecutionException {
|
||||||
}
|
}
|
||||||
WebSocketEvent result = event.result;
|
WebSocketEvent result = event.result;
|
||||||
waitEventHandler.requests.remove(event);
|
waitEventHandler.requests.remove(event);
|
||||||
if (event.result.getType().equals("error") || event.result.getType().equals("exception")) {
|
if (event.result.getType().equals("error")) {
|
||||||
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
|
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
|
||||||
throw new ExecutionException(new RequestException(errorRequestEvent.error));
|
throw new ExecutionException(new RequestException(errorRequestEvent.error));
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,4 +180,8 @@ public static void verifySystemProperties(Class<?> mainClass, boolean requireSys
|
||||||
|
|
||||||
private JVMHelper() {
|
private JVMHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void verifyNoAgent() {
|
||||||
|
if (RUNTIME_MXBEAN.getInputArguments().stream().filter(e -> e != null && !e.isEmpty()).anyMatch(e -> e.contains("javaagent"))) throw new SecurityException("JavaAgent found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue