Compare commits

...

4 commits

Author SHA1 Message Date
Antoni
b3f170232a
Merge 0e1691ee4c into e67bb6a12f 2025-04-25 11:01:54 +03:00
Gravita
e67bb6a12f [FEATURE] Support /webapi/status endpoint for Docker 2025-04-25 14:58:02 +07:00
Gravita
e2e0ef6ea4 [FEATURE] Support enableNativeAccess, fix libraries modularity 2025-04-25 14:49:51 +07:00
microwin7
0e1691ee4c
Add Discord Widget 2023-05-19 22:40:26 +03:00
7 changed files with 53 additions and 5 deletions

View file

@ -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']

View file

@ -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");

View file

@ -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) {

View file

@ -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));
}
}

View file

@ -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<>();
} }
} }

View file

@ -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);
} }
} }

View file

@ -1,4 +1,6 @@
# Modification of the launcher sashok724's v3 from Gravit [![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher) # Modification of the launcher sashok724's v3 from Gravit
[![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher)
[![Join our Discord](https://img.shields.io/discord/853340557522370561.svg?logo=discord&label=)](https://discord.gg/b9QG4ygY75)
* [Discord channel](https://discord.gg/b9QG4ygY75) * [Discord channel](https://discord.gg/b9QG4ygY75)
@ -9,4 +11,4 @@
```sh ```sh
curl -s https://raw.githubusercontent.com/GravitLauncher/Launcher/master/get_it.sh | sh curl -s https://raw.githubusercontent.com/GravitLauncher/Launcher/master/get_it.sh | sh
``` ```