mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 16:29:46 +03:00
Compare commits
2 commits
18419fcd3a
...
e67bb6a12f
Author | SHA1 | Date | |
---|---|---|---|
|
e67bb6a12f | ||
|
e2e0ef6ea4 |
6 changed files with 49 additions and 3 deletions
|
@ -75,9 +75,9 @@
|
||||||
pack project(':LauncherAPI')
|
pack project(':LauncherAPI')
|
||||||
bundle group: 'me.tongfei', name: 'progressbar', version: '0.10.1'
|
bundle group: 'me.tongfei', name: 'progressbar', version: '0.10.1'
|
||||||
bundle group: 'org.fusesource.jansi', name: 'jansi', version: rootProject['verJansi']
|
bundle group: 'org.fusesource.jansi', name: 'jansi', version: rootProject['verJansi']
|
||||||
bundle group: 'org.jline', name: 'jline', version: rootProject['verJline']
|
bundle group: 'org.jline', name: 'jline-native', version: rootProject['verJline']
|
||||||
bundle group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
|
bundle group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
|
||||||
bundle group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline']
|
bundle group: 'org.jline', name: 'jline-terminal-ffm', version: rootProject['verJline']
|
||||||
bundle group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: rootProject['verBcpkix']
|
bundle group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: rootProject['verBcpkix']
|
||||||
bundle group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: rootProject['verBcpkix']
|
bundle group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: rootProject['verBcpkix']
|
||||||
bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm']
|
bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm']
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static final List<String> classpathOnly = List.of("proguard", "jline", "progressbar", "kotlin");
|
private static final List<String> classpathOnly = List.of("proguard", "progressbar", "kotlin");
|
||||||
private static final String LOG4J_PROPERTY = "log4j2.configurationFile";
|
private static final String LOG4J_PROPERTY = "log4j2.configurationFile";
|
||||||
private static final String DEBUG_PROPERTY = "launchserver.main.debug";
|
private static final String DEBUG_PROPERTY = "launchserver.main.debug";
|
||||||
private static final String LIBRARIES_PROPERTY = "launchserver.dir.libraries";
|
private static final String LIBRARIES_PROPERTY = "launchserver.dir.libraries";
|
||||||
|
@ -74,6 +74,8 @@ public static void main(String[] args) throws Throwable {
|
||||||
classpath.add(IOHelper.getCodeSource(LaunchServerStarter.class));
|
classpath.add(IOHelper.getCodeSource(LaunchServerStarter.class));
|
||||||
options.moduleConf.modulePath.addAll(modulepath);
|
options.moduleConf.modulePath.addAll(modulepath);
|
||||||
options.moduleConf.modules.add("ALL-MODULE-PATH");
|
options.moduleConf.modules.add("ALL-MODULE-PATH");
|
||||||
|
options.moduleConf.enableNativeAccess.add("org.fusesource.jansi");
|
||||||
|
options.moduleConf.enableNativeAccess.add("io.netty.common");
|
||||||
ClassLoaderControl control = launch.init(classpath, "natives", options);
|
ClassLoaderControl control = launch.init(classpath, "natives", options);
|
||||||
control.clearLauncherPackages();
|
control.clearLauncherPackages();
|
||||||
control.addLauncherPackage("pro.gravit.utils.launch");
|
control.addLauncherPackage("pro.gravit.utils.launch");
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.base.Launcher;
|
import pro.gravit.launcher.base.Launcher;
|
||||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||||
|
import pro.gravit.launchserver.socket.severlet.StatusSeverlet;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
@ -34,6 +35,7 @@ public class NettyWebAPIHandler extends SimpleChannelInboundHandler<FullHttpRequ
|
||||||
public NettyWebAPIHandler(NettyConnectContext context) {
|
public NettyWebAPIHandler(NettyConnectContext context) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
addNewSeverlet("status", new StatusSeverlet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addNewSeverlet(String path, SimpleSeverletHandler callback) {
|
public static void addNewSeverlet(String path, SimpleSeverletHandler callback) {
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package pro.gravit.launchserver.socket.severlet;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||||
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||||
|
import pro.gravit.launchserver.socket.handlers.NettyWebAPIHandler;
|
||||||
|
|
||||||
|
public class StatusSeverlet implements NettyWebAPIHandler.SimpleSeverletHandler {
|
||||||
|
@Override
|
||||||
|
public void handle(ChannelHandlerContext ctx, FullHttpRequest msg, NettyConnectContext context) {
|
||||||
|
sendHttpResponse(ctx, new DefaultFullHttpResponse(msg.protocolVersion(), HttpResponseStatus.OK));
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,5 +14,6 @@ public static final class ModuleConf {
|
||||||
public Map<String, String> exports = new HashMap<>();
|
public Map<String, String> exports = new HashMap<>();
|
||||||
public Map<String, String> opens = new HashMap<>();
|
public Map<String, String> opens = new HashMap<>();
|
||||||
public Map<String, String> reads = new HashMap<>();
|
public Map<String, String> reads = new HashMap<>();
|
||||||
|
public List<String> enableNativeAccess = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,18 @@ public class ModuleLaunch implements Launch {
|
||||||
private ModuleLayer layer;
|
private ModuleLayer layer;
|
||||||
private MethodHandles.Lookup hackLookup;
|
private MethodHandles.Lookup hackLookup;
|
||||||
private boolean disablePackageDelegateSupport;
|
private boolean disablePackageDelegateSupport;
|
||||||
|
private static final MethodHandle ENABLE_NATIVE_ACCESS;
|
||||||
|
|
||||||
|
static {
|
||||||
|
MethodHandle mh;
|
||||||
|
try {
|
||||||
|
mh = MethodHandles.lookup().findVirtual(ModuleLayer.Controller.class, "enableNativeAccess", MethodType.methodType(ModuleLayer.Controller.class, Module.class));
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException e) {
|
||||||
|
mh = null;
|
||||||
|
}
|
||||||
|
ENABLE_NATIVE_ACCESS = mh;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassLoaderControl init(List<Path> files, String nativePath, LaunchOptions options) {
|
public ClassLoaderControl init(List<Path> files, String nativePath, LaunchOptions options) {
|
||||||
this.disablePackageDelegateSupport = options.disablePackageDelegateSupport;
|
this.disablePackageDelegateSupport = options.disablePackageDelegateSupport;
|
||||||
|
@ -120,6 +132,20 @@ public ClassLoaderControl init(List<Path> files, String nativePath, LaunchOption
|
||||||
controller.addReads(source, target);
|
controller.addReads(source, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(var e : options.moduleConf.enableNativeAccess) {
|
||||||
|
LogHelper.dev("Enable Native Access %s", e);
|
||||||
|
Module source = layer.findModule(e).orElse(null);
|
||||||
|
if(source == null) {
|
||||||
|
throw new RuntimeException(String.format("Module %s not found", e));
|
||||||
|
}
|
||||||
|
if(ENABLE_NATIVE_ACCESS != null) {
|
||||||
|
try {
|
||||||
|
ENABLE_NATIVE_ACCESS.invoke(controller, source);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
moduleClassLoader.initializeWithLayer(layer);
|
moduleClassLoader.initializeWithLayer(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue