mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-14 19:19:12 +03:00
[FIX] ExitResponse, update SimpleModuleManager
This commit is contained in:
parent
64635cbb9b
commit
f321b8bd27
10 changed files with 61 additions and 76 deletions
|
@ -43,6 +43,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
return;
|
||||
}
|
||||
if (username == null) {
|
||||
if(!client.isAuth || client.auth == null) {
|
||||
sendError("You are not authorized");
|
||||
return;
|
||||
}
|
||||
{
|
||||
WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class);
|
||||
if (handler == null) {
|
||||
|
@ -65,7 +69,6 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
}
|
||||
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT));
|
||||
}
|
||||
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT));
|
||||
} else {
|
||||
service.forEachActiveChannels(((channel, webSocketFrameHandler) -> {
|
||||
Client client1 = webSocketFrameHandler.getClient();
|
||||
|
|
|
@ -83,6 +83,10 @@ protected final <T extends LauncherModule> T requireModule(Class<? extends T> cl
|
|||
return module;
|
||||
}
|
||||
|
||||
protected LauncherModulesContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
private void requireModule(LauncherModule module, Version minVersion, String requiredModuleName) {
|
||||
if (module == null)
|
||||
throw new RuntimeException(String.format("Module %s required %s v%s or higher", moduleInfo.name, requiredModuleName, minVersion.getVersionString()));
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package pro.gravit.launcher.base.modules;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface LauncherModulesContext {
|
||||
LauncherModulesManager getModulesManager();
|
||||
|
||||
ModulesConfigManager getModulesConfigManager();
|
||||
|
||||
void addURL(URL url);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
import pro.gravit.launcher.base.modules.LauncherModulesManager;
|
||||
import pro.gravit.launcher.base.modules.ModulesConfigManager;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public class SimpleModuleContext implements LauncherModulesContext {
|
||||
public final LauncherModulesManager modulesManager;
|
||||
public final ModulesConfigManager configManager;
|
||||
|
@ -13,6 +15,15 @@ public SimpleModuleContext(LauncherModulesManager modulesManager, ModulesConfigM
|
|||
this.configManager = configManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(URL url) {
|
||||
if(modulesManager instanceof SimpleModuleManager s) {
|
||||
s.addUrlToClassLoader(url);
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherModulesManager getModulesManager() {
|
||||
return modulesManager;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -32,9 +33,13 @@ public class SimpleModuleManager implements LauncherModulesManager {
|
|||
protected final ModulesConfigManager modulesConfigManager;
|
||||
protected final Path modulesDir;
|
||||
protected final LauncherTrustManager trustManager;
|
||||
protected final PublicURLClassLoader classLoader = new PublicURLClassLoader(new URL[]{}, SimpleModuleManager.class.getClassLoader());
|
||||
protected final ModulesClassLoader classLoader = createClassLoader();
|
||||
protected LauncherInitContext initContext;
|
||||
|
||||
protected ModulesClassLoader createClassLoader() {
|
||||
return new ModulesClassLoader(new URL[]{}, SimpleModuleManager.class.getClassLoader());
|
||||
}
|
||||
|
||||
public SimpleModuleManager(Path modulesDir, Path configDir) {
|
||||
modulesConfigManager = new SimpleModulesConfigManager(configDir);
|
||||
context = new SimpleModuleContext(this, modulesConfigManager);
|
||||
|
@ -268,6 +273,10 @@ public ModulesConfigManager getConfigManager() {
|
|||
return modulesConfigManager;
|
||||
}
|
||||
|
||||
void addUrlToClassLoader(URL url) {
|
||||
classLoader.addURL(url);
|
||||
}
|
||||
|
||||
protected final class ModulesVisitor extends SimpleFileVisitor<Path> {
|
||||
private ModulesVisitor() {
|
||||
}
|
||||
|
@ -279,4 +288,16 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
|||
return super.visitFile(file, attrs);
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ModulesClassLoader extends URLClassLoader {
|
||||
|
||||
public ModulesClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super("MODULES", urls, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(URL url) {
|
||||
super.addURL(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
import java.security.cert.CertificateException;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -27,6 +28,7 @@ public abstract class ClientJSONPoint implements WebSocket.Listener {
|
|||
protected boolean ssl = false;
|
||||
protected int port;
|
||||
private final Object syncObject = new Object();
|
||||
private final Object sendSyncObject = new Object();
|
||||
private volatile StringBuilder builder = new StringBuilder();
|
||||
|
||||
public ClientJSONPoint(final String uri) throws SSLException {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import pro.gravit.launcher.base.modules.LauncherModule;
|
||||
import pro.gravit.launcher.base.modules.impl.SimpleModuleManager;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -33,6 +34,11 @@ public List<LauncherModule> getModules() {
|
|||
return Collections.unmodifiableList(modules);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModulesClassLoader createClassLoader() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
return result.type == LauncherTrustManager.CheckClassResultType.SUCCESS;
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
sourceCompatibility = '17'
|
||||
targetCompatibility = '17'
|
||||
|
||||
dependencies {
|
||||
api project(':LauncherCore')
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
jar {
|
||||
archiveClassifier.set('clean')
|
||||
manifest.attributes("Multi-Release": "true")
|
||||
}
|
||||
|
||||
tasks.register('sourcesJar', Jar) {
|
||||
from sourceSets.main.allJava
|
||||
archiveClassifier.set('sources')
|
||||
}
|
||||
|
||||
tasks.register('javadocJar', Jar) {
|
||||
from javadoc
|
||||
archiveClassifier.set('javadoc')
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
launchermoderncore(MavenPublication) {
|
||||
artifactId = 'launcher-modern-core'
|
||||
artifact(jar) {
|
||||
classifier ""
|
||||
}
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
pom {
|
||||
name = 'GravitLauncher Core Utils with Java 17+'
|
||||
description = 'GravitLauncher Core Utils'
|
||||
url = 'https://gravitlauncher.com'
|
||||
licenses {
|
||||
license {
|
||||
name = 'GNU General Public License, Version 3.0'
|
||||
url = 'https://www.gnu.org/licenses/gpl-3.0.html'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = 'gravita'
|
||||
name = 'Gravita'
|
||||
email = 'gravita@gravit.pro'
|
||||
}
|
||||
developer {
|
||||
id = 'zaxar163'
|
||||
name = 'Zaxar163'
|
||||
email = 'zahar.vcherachny@yandex.ru'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = 'scm:git:https://github.com/GravitLauncher/Launcher.git'
|
||||
developerConnection = 'scm:git:ssh://git@github.com:GravitLauncher/Launcher.git'
|
||||
url = 'https://gravitlauncher.com/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
sign publishing.publications.launchermoderncore
|
||||
}
|
|
@ -38,6 +38,11 @@ public boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult resu
|
|||
return result.type == LauncherTrustManager.CheckClassResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModulesClassLoader createClassLoader() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void callWrapper(ClientLauncherWrapper.ClientLauncherWrapperContext context) {
|
||||
for (LauncherModule module : modules) {
|
||||
if (module instanceof ClientWrapperModule) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -22,7 +23,7 @@
|
|||
|
||||
public class ServerWrapperSetup {
|
||||
public ServerWrapperCommands commands;
|
||||
public PublicURLClassLoader urlClassLoader;
|
||||
public URLClassLoader urlClassLoader;
|
||||
|
||||
public ServerWrapperSetup() throws IOException {
|
||||
commands = new ServerWrapperCommands();
|
||||
|
@ -37,7 +38,7 @@ public void run() throws Exception {
|
|||
String agentClassName;
|
||||
try (JarFile file = new JarFile(jarPath.toFile())) {
|
||||
URL jarURL = jarPath.toUri().toURL();
|
||||
urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL});
|
||||
urlClassLoader = new URLClassLoader(new URL[]{jarURL});
|
||||
LogHelper.info("Check server jar MainClass");
|
||||
mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class");
|
||||
agentClassName = file.getManifest().getMainAttributes().getValue("Premain-Class");
|
||||
|
|
Loading…
Reference in a new issue