mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 16:29:46 +03:00
Compare commits
4 commits
eca8a51794
...
b3f170232a
Author | SHA1 | Date | |
---|---|---|---|
|
b3f170232a | ||
|
e67bb6a12f | ||
|
e2e0ef6ea4 | ||
|
0e1691ee4c |
7 changed files with 53 additions and 5 deletions
|
@ -75,9 +75,9 @@
|
|||
pack project(':LauncherAPI')
|
||||
bundle group: 'me.tongfei', name: 'progressbar', version: '0.10.1'
|
||||
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-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: 'bcpkix-jdk18on', version: rootProject['verBcpkix']
|
||||
bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm']
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import java.util.stream.Stream;
|
||||
|
||||
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 DEBUG_PROPERTY = "launchserver.main.debug";
|
||||
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));
|
||||
options.moduleConf.modulePath.addAll(modulepath);
|
||||
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);
|
||||
control.clearLauncherPackages();
|
||||
control.addLauncherPackage("pro.gravit.utils.launch");
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.base.Launcher;
|
||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||
import pro.gravit.launchserver.socket.severlet.StatusSeverlet;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
|
@ -34,6 +35,7 @@ public class NettyWebAPIHandler extends SimpleChannelInboundHandler<FullHttpRequ
|
|||
public NettyWebAPIHandler(NettyConnectContext context) {
|
||||
super();
|
||||
this.context = context;
|
||||
addNewSeverlet("status", new StatusSeverlet());
|
||||
}
|
||||
|
||||
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> opens = 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 MethodHandles.Lookup hackLookup;
|
||||
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
|
||||
public ClassLoaderControl init(List<Path> files, String nativePath, LaunchOptions options) {
|
||||
this.disablePackageDelegateSupport = options.disablePackageDelegateSupport;
|
||||
|
@ -120,6 +132,20 @@ public ClassLoaderControl init(List<Path> files, String nativePath, LaunchOption
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Modification of the launcher sashok724's v3 from Gravit [](https://travis-ci.com/GravitLauncher/Launcher)
|
||||
# Modification of the launcher sashok724's v3 from Gravit
|
||||
[](https://travis-ci.com/GravitLauncher/Launcher)
|
||||
[](https://discord.gg/b9QG4ygY75)
|
||||
|
||||
* [Discord channel](https://discord.gg/b9QG4ygY75)
|
||||
|
||||
|
@ -9,4 +11,4 @@
|
|||
|
||||
```sh
|
||||
curl -s https://raw.githubusercontent.com/GravitLauncher/Launcher/master/get_it.sh | sh
|
||||
```
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue