From 6663f382419e069c9c97dcfadd254e6be826c434 Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 22 Mar 2022 15:36:26 +0700 Subject: [PATCH 01/20] [FEATURE] LwjglDownloadCommand, modules and modulePath --- .../client/ClientLauncherProcess.java | 21 +++++++++++++------ .../launcher/profiles/ClientProfile.java | 17 ++++++++++++++- .../profiles/ClientProfileBuilder.java | 14 ++++++++++++- modules | 2 +- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index 2f51f73b..ecd35d1f 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -20,6 +20,7 @@ import pro.gravit.utils.Version; import pro.gravit.utils.helper.*; +import java.io.File; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; @@ -33,7 +34,7 @@ public class ClientLauncherProcess { public final ClientParams params = new ClientParams(); public final List jvmArgs = new LinkedList<>(); public final List jvmModules = new LinkedList<>(); - public final List jvmModulesPaths = new LinkedList<>(); + public final List jvmModulesPaths = new LinkedList<>(); public final List systemClientArgs = new LinkedList<>(); public final List systemClassPath = new LinkedList<>(); public final Map systemEnv = new HashMap<>(); @@ -127,7 +128,8 @@ private void applyClientProfile() { this.params.oauthExpiredTime = Request.getTokenExpiredTime(); this.params.extendedTokens = Request.getExtendedTokens(); } - + this.jvmModules.addAll(this.params.profile.getModules()); + this.jvmModulesPaths.addAll(this.params.profile.getModulePath()); if (this.params.profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) { jvmModules.add("javafx.base"); jvmModules.add("javafx.graphics"); @@ -137,6 +139,7 @@ private void applyClientProfile() { jvmModules.add("javafx.media"); jvmModules.add("javafx.web"); } + LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderCreateEvent(this)); } @@ -187,20 +190,26 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { } private void applyJava9Params(List processArgs) { - jvmModulesPaths.add(javaVersion.jvmDir); + /*jvmModulesPaths.add(javaVersion.jvmDir); jvmModulesPaths.add(javaVersion.jvmDir.resolve("jre")); Path openjfxPath = JavaHelper.tryGetOpenJFXPath(javaVersion.jvmDir); if (openjfxPath != null) { jvmModulesPaths.add(openjfxPath); - } + }*/ // TODO: fix runtime in client StringBuilder modulesPath = new StringBuilder(); StringBuilder modulesAdd = new StringBuilder(); for (String moduleName : jvmModules) { - boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath); + /*boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath); if (success) { if (modulesAdd.length() > 0) modulesAdd.append(","); modulesAdd.append(moduleName); - } + }*/ + if (modulesAdd.length() > 0) modulesAdd.append(","); + modulesAdd.append(moduleName); + } + for(String modulePath : jvmModulesPaths) { + if (modulesPath.length() > 0) modulesPath.append(File.pathSeparator); + modulesPath.append(modulePath); } if (modulesAdd.length() > 0) { processArgs.add("--add-modules"); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 89a1d4d4..b3fa2761 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -48,6 +48,10 @@ public final class ClientProfile implements Comparable { @LauncherNetworkAPI private List classPath; @LauncherNetworkAPI + private List modulePath; + @LauncherNetworkAPI + private List modules; + @LauncherNetworkAPI private List altClassPath; @LauncherNetworkAPI private List clientArgs; @@ -91,6 +95,7 @@ public ClientProfile() { updateOptional = new HashSet<>(); jvmArgs = new ArrayList<>(); classPath = new ArrayList<>(); + modulePath = new ArrayList<>(); altClassPath = new ArrayList<>(); clientArgs = new ArrayList<>(); compatClasses = new ArrayList<>(); @@ -102,7 +107,7 @@ public ClientProfile() { runtimeInClientConfig = RuntimeInClientConfig.NONE; } - public ClientProfile(List update, List updateExclusions, List updateShared, List updateVerify, Set updateOptional, List jvmArgs, List classPath, List altClassPath, List clientArgs, List compatClasses, Map properties, List servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) { + public ClientProfile(List update, List updateExclusions, List updateShared, List updateVerify, Set updateOptional, List jvmArgs, List classPath, List modulePath, List modules, List altClassPath, List clientArgs, List compatClasses, Map properties, List servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) { this.update = update; this.updateExclusions = updateExclusions; this.updateShared = updateShared; @@ -110,6 +115,8 @@ public ClientProfile(List update, List updateExclusions, List getModulePath() { + return Collections.unmodifiableList(modulePath); + } + + public List getModules() { + return Collections.unmodifiableList(modules); + } + public String[] getAlternativeClassPath() { return altClassPath.toArray(new String[0]); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java index 32a17dd6..052e2f67 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java @@ -12,6 +12,8 @@ public class ClientProfileBuilder { private Set updateOptional = new HashSet<>(); private List jvmArgs = new ArrayList<>(); private List classPath = new ArrayList<>(); + private List modulePath = new ArrayList<>(); + private List modules = new ArrayList<>(); private List altClassPath = new ArrayList<>(); private List clientArgs = new ArrayList<>(); private List compatClasses = new ArrayList<>(); @@ -142,6 +144,16 @@ public ClientProfileBuilder setRecommendJavaVersion(int recommendJavaVersion) { return this; } + public ClientProfileBuilder setModulePath(List modulePath) { + this.modulePath = modulePath; + return this; + } + + public ClientProfileBuilder setModules(List modules) { + this.modules = modules; + return this; + } + public ClientProfileBuilder setMinJavaVersion(int minJavaVersion) { this.minJavaVersion = minJavaVersion; return this; @@ -193,6 +205,6 @@ public ClientProfileBuilder setMainClass(String mainClass) { } public ClientProfile createClientProfile() { - return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass); + return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, modulePath, modules, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass); } } \ No newline at end of file diff --git a/modules b/modules index aea93d68..a1318b09 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit aea93d6803e4770f23ff4a2ea4b5f8752d053d8b +Subproject commit a1318b09c1f5657ad60eaee362746cd493d38c8a From b67ae753f0f8d82158a85b7b60d4db30b5bfb9a8 Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 22 Mar 2022 15:37:21 +0700 Subject: [PATCH 02/20] [ANY] 5.2.10-dev --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 1065b502..c03226ed 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -6,9 +6,9 @@ public final class Version implements Comparable { public static final int MAJOR = 5; public static final int MINOR = 2; - public static final int PATCH = 9; + public static final int PATCH = 10; public static final int BUILD = 1; - public static final Version.Type RELEASE = Type.STABLE; + public static final Version.Type RELEASE = Type.DEV; public final int major; public final int minor; public final int patch; diff --git a/build.gradle b/build.gradle index c908ad13..247dc6d4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.10' apply false } group = 'pro.gravit.launcher' -version = '5.2.9' +version = '5.2.10-SNAPSHOT' apply from: 'props.gradle' From 67a53218d452723bd727febffbf5ec208508a0bd Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 24 Mar 2022 16:49:50 +0700 Subject: [PATCH 03/20] [FIX] Old profiles crash --- .../main/java/pro/gravit/launcher/profiles/ClientProfile.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index b3fa2761..de75f5c7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -48,9 +48,9 @@ public final class ClientProfile implements Comparable { @LauncherNetworkAPI private List classPath; @LauncherNetworkAPI - private List modulePath; + private List modulePath = new ArrayList<>(); @LauncherNetworkAPI - private List modules; + private List modules = new ArrayList<>(); @LauncherNetworkAPI private List altClassPath; @LauncherNetworkAPI From 7522e156aeaf05a010520c48f187cfa8aaae7442 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 24 Mar 2022 16:51:50 +0700 Subject: [PATCH 04/20] [ANY] Remove signedClientConfig and securityManagerConfig --- .../pro/gravit/launcher/api/SystemService.java | 10 ---------- .../gravit/launcher/profiles/ClientProfile.java | 16 ---------------- 2 files changed, 26 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/api/SystemService.java b/Launcher/src/main/java/pro/gravit/launcher/api/SystemService.java index 427c6275..57c60481 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/api/SystemService.java +++ b/Launcher/src/main/java/pro/gravit/launcher/api/SystemService.java @@ -12,14 +12,4 @@ private SystemService() { public static void exit(int code) { LauncherEngine.exitLauncher(code); } - - public static void setSecurityManager(SecurityManager s) { - LogHelper.debug("Try set security manager %s", s == null ? "null" : s.getClass().getName()); - if (AuthService.profile == null || AuthService.profile.getSecurityManagerConfig() == ClientProfile.SecurityManagerConfig.NONE) - return; - if (AuthService.profile.getSecurityManagerConfig() == ClientProfile.SecurityManagerConfig.CLIENT) { - System.setSecurityManager(s); - } - //TODO NEXT - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index de75f5c7..162b22c8 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -426,14 +426,6 @@ public int hashCode() { return Objects.hash(uuid); } - public SecurityManagerConfig getSecurityManagerConfig() { - return securityManagerConfig; - } - - public void setSecurityManagerConfig(SecurityManagerConfig securityManagerConfig) { - this.securityManagerConfig = securityManagerConfig; - } - public ClassLoaderConfig getClassLoaderConfig() { return classLoaderConfig; } @@ -442,14 +434,6 @@ public void setClassLoaderConfig(ClassLoaderConfig classLoaderConfig) { this.classLoaderConfig = classLoaderConfig; } - public SignedClientConfig getSignedClientConfig() { - return signedClientConfig; - } - - public void setSignedClientConfig(SignedClientConfig signedClientConfig) { - this.signedClientConfig = signedClientConfig; - } - public RuntimeInClientConfig getRuntimeInClientConfig() { return runtimeInClientConfig; } From c42f410bc4b79f132ba7a33f9d88e7e154fc8d1d Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 28 Mar 2022 22:44:43 +0700 Subject: [PATCH 05/20] [FIX] ServerWrapper main class lookup --- .../src/main/java/pro/gravit/launcher/server/ServerWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 5400b2b4..a07766f2 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -167,7 +167,7 @@ public void run(String... args) throws Throwable { } if (loader != null) mainClass = Class.forName(classname, true, loader); else mainClass = Class.forName(classname); - MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); + MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); LogHelper.info("ServerWrapper: LaunchServer address: %s. Title: %s", config.address, Launcher.profile != null ? Launcher.profile.getTitle() : "unknown"); LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name); LogHelper.info("Start Minecraft Server"); From 8afa630546248cc086f55394ec356ea5f8e7f1da Mon Sep 17 00:00:00 2001 From: Gravita Date: Wed, 30 Mar 2022 15:52:28 +0700 Subject: [PATCH 06/20] [FIX] Bad login (MySQL + HWID) --- .../launchserver/auth/protect/AdvancedProtectHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java index a74aa9c4..86410ced 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java @@ -103,7 +103,7 @@ public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { @Override public boolean onJoinServer(String serverID, String username, Client client) { - return !enableHardwareFeature || (client.trustLevel != null && client.trustLevel.hardwareInfo != null); + return !enableHardwareFeature || (client.trustLevel != null && client.trustLevel.publicKey != null); } @Override From 7bfa4ebdabd238b924ed32ce984e12a62c00cab6 Mon Sep 17 00:00:00 2001 From: Gravita Date: Wed, 30 Mar 2022 16:39:48 +0700 Subject: [PATCH 07/20] [FIX] Bad login (MySQL + HWID) --- .../launchserver/auth/protect/AdvancedProtectHandler.java | 4 ++-- .../events/request/VerifySecureLevelKeyRequestEvent.java | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java index 86410ced..e65e25cd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java @@ -93,17 +93,17 @@ public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { } client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); authSupportHardware.connectUserAndHardware(client.sessionObject, hardware); + return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey), createHardwareToken(client.username, client.trustLevel.hardwareInfo)); } else { logger.warn("AuthCoreProvider not supported hardware. HardwareInfo not checked!"); } - return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey)); } return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey)); } @Override public boolean onJoinServer(String serverID, String username, Client client) { - return !enableHardwareFeature || (client.trustLevel != null && client.trustLevel.publicKey != null); + return !enableHardwareFeature || (client.trustLevel != null && client.trustLevel.hardwareInfo != null); } @Override diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java index ff7085e5..0c40dccd 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java @@ -6,6 +6,7 @@ public class VerifySecureLevelKeyRequestEvent extends RequestEvent { public boolean needHardwareInfo; public boolean onlyStatisticInfo; public String extendedToken; + public String hardwareExtendedToken; public VerifySecureLevelKeyRequestEvent() { } @@ -20,6 +21,13 @@ public VerifySecureLevelKeyRequestEvent(boolean needHardwareInfo, boolean onlySt this.extendedToken = extendedToken; } + public VerifySecureLevelKeyRequestEvent(boolean needHardwareInfo, boolean onlyStatisticInfo, String extendedToken, String hardwareExtendedToken) { + this.needHardwareInfo = needHardwareInfo; + this.onlyStatisticInfo = onlyStatisticInfo; + this.extendedToken = extendedToken; + this.hardwareExtendedToken = hardwareExtendedToken; + } + @Override public String getType() { return "verifySecureLevelKey"; From 7cd6b9c1d95fdf1606216748e3b7eba408fb540b Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 3 Apr 2022 15:08:15 +0700 Subject: [PATCH 08/20] [FIX] Bad login (MySQL + HWID) --- .../auth/protect/AdvancedProtectHandler.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java index e65e25cd..3e7fd4e4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java @@ -51,7 +51,7 @@ public boolean allowGetSecureLevelInfo(Client client) { @Override public void onHardwareReport(HardwareReportResponse response, Client client) { if (!enableHardwareFeature) { - response.sendResult(new HardwareReportRequestEvent(createHardwareToken(client.username, response.hardware))); + response.sendResult(new HardwareReportRequestEvent(null)); return; } if (!client.isAuth || client.trustLevel == null || client.trustLevel.publicKey == null) { @@ -73,11 +73,14 @@ public void onHardwareReport(HardwareReportResponse response, Client client) { throw new SecurityException("Your hardware banned"); } client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); + response.sendResult(new HardwareReportRequestEvent(createHardwareToken(client.username, hardware))); + return; } else { logger.error("AuthCoreProvider not supported hardware"); + response.sendError("AuthCoreProvider not supported hardware"); + return; } } - response.sendResult(new HardwareReportRequestEvent(createHardwareToken(client.username, response.hardware))); } @Override @@ -93,7 +96,7 @@ public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { } client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); authSupportHardware.connectUserAndHardware(client.sessionObject, hardware); - return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey), createHardwareToken(client.username, client.trustLevel.hardwareInfo)); + return new VerifySecureLevelKeyRequestEvent(false, false, createPublicKeyToken(client.username, client.trustLevel.publicKey), createHardwareToken(client.username, hardware)); } else { logger.warn("AuthCoreProvider not supported hardware. HardwareInfo not checked!"); } @@ -115,12 +118,12 @@ public void init(LaunchServer server) { public void close() { } - public String createHardwareToken(String username, HardwareReportRequest.HardwareInfo info) { + public String createHardwareToken(String username, UserHardware hardware) { return Jwts.builder() .setIssuer("LaunchServer") .setSubject(username) .setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 8)) - .claim("hardware", info) + .claim("hardware", hardware.getId()) .signWith(server.keyAgreementManager.ecdsaPrivateKey) .compact(); } @@ -152,10 +155,14 @@ public HardwareInfoTokenVerifier(LaunchServer server) { public boolean accept(Client client, AuthProviderPair pair, String extendedToken) { try { var parse = parser.parseClaimsJws(extendedToken); - HardwareReportRequest.HardwareInfo hardwareInfo = parse.getBody().get("hardware", HardwareReportRequest.HardwareInfo.class); - if (hardwareInfo == null) return false; + String hardwareInfoId = parse.getBody().get("hardware", String.class); + if (hardwareInfoId == null) return false; + if(client.auth == null) return false; + var hardwareSupport = client.auth.core.isSupport(AuthSupportHardware.class); + if(hardwareSupport == null) return false; + UserHardware hardware = hardwareSupport.getHardwareInfoById(hardwareInfoId); if (client.trustLevel == null) client.trustLevel = new Client.TrustLevel(); - client.trustLevel.hardwareInfo = hardwareInfo; + client.trustLevel.hardwareInfo = hardware.getHardwareInfo(); return true; } catch (Throwable e) { logger.error("Hardware JWT error", e); From b1355351475d6f12e97b7e154f6e3793424a2942 Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 3 Apr 2022 15:44:57 +0700 Subject: [PATCH 09/20] Upgrade dependencies --- LaunchServer/build.gradle | 8 +++----- .../components/ProGuardComponent.java | 2 +- props.gradle | 18 +++++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index baadb9cd..d57c46c5 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -75,7 +75,7 @@ task cleanjar(type: Jar, dependsOn: jar) { dependencies { pack project(':LauncherAPI') bundle group: 'me.tongfei', name: 'progressbar', version: '0.9.2' - bundle group: 'com.github.Marcono1234', name: 'gson-record-type-adapter-factory', version: 'v0.1.0' + bundle group: 'com.github.Marcono1234', name: 'gson-record-type-adapter-factory', version: 'v0.2.0' 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-reader', version: rootProject['verJline'] @@ -84,8 +84,6 @@ pack project(':LauncherAPI') bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm'] bundle group: 'io.netty', name: 'netty-all', version: rootProject['verNetty'] bundle group: 'org.slf4j', name: 'slf4j-api', version: rootProject['verSlf4j'] - bundle group: 'org.hibernate', name: 'hibernate-core', version: rootProject['verHibernate'] - bundle group: 'org.hibernate', name: 'hibernate-hikaricp', version: rootProject['verHibernate'] bundle group: 'mysql', name: 'mysql-connector-java', version: rootProject['verMySQLConn'] bundle group: 'org.postgresql', name: 'postgresql', version: rootProject['verPostgreSQLConn'] bundle group: 'com.guardsquare', name: 'proguard-base', version: rootProject['verProguard'] @@ -96,8 +94,8 @@ pack project(':LauncherAPI') bundle group: 'io.jsonwebtoken', name: 'jjwt-gson', version: rootProject['verJwt'] testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit'] - hikari 'io.micrometer:micrometer-core:1.7.2' - hikari('com.zaxxer:HikariCP:5.0.0') { + hikari 'io.micrometer:micrometer-core:1.8.4' + hikari('com.zaxxer:HikariCP:5.0.1') { exclude group: 'javassist' exclude group: 'io.micrometer' exclude group: 'org.slf4j' diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java index a28b65d3..d01bf131 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java @@ -152,7 +152,7 @@ public Path process(Path inputFile) throws IOException { parser.parse(proguard_cfg); ProGuard proGuard = new ProGuard(proguard_cfg); proGuard.execute(); - } catch (ParseException e) { + } catch (Exception e) { logger.error(e); } } else diff --git a/props.gradle b/props.gradle index 6d5b39ab..df4cfa2f 100644 --- a/props.gradle +++ b/props.gradle @@ -1,20 +1,20 @@ project.ext { verAsm = '9.2' - verNetty = '4.1.70.Final' - verOshiCore = '6.0.0' + verNetty = '4.1.75.Final' + verOshiCore = '6.1.5' verJunit = '5.8.2' verGuavaC = '30.1.1-jre' - verJansi = '2.3.4' + verJansi = '2.4.0' verJline = '3.21.0' verJwt = '0.11.2' verBcprov = '1.70' - verGson = '2.8.9' + verGson = '2.9.0' verBcpkix = '1.70' - verSlf4j = '1.7.32' - verLog4j = '2.17.1' - verMySQLConn = '8.0.27' - verPostgreSQLConn = '42.3.1' - verProguard = '7.2.0-beta2' + verSlf4j = '1.7.36' + verLog4j = '2.17.2' + verMySQLConn = '8.0.28' + verPostgreSQLConn = '42.3.3' + verProguard = '7.2.1' verLaunch4j = '3.14' verHibernate = '5.5.6.Final' } From 7cedaef90a84911857404e1dd21dec02fd369f38 Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 3 Apr 2022 15:46:59 +0700 Subject: [PATCH 10/20] [ANY] Gradle upgrade --- gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae8848c63b8b4dea2cb829da983f2fa..41d9927a4d4fb3f96a785543079b8df6723c946b 100644 GIT binary patch delta 8958 zcmY+KWl$VIlZIh&f(Hri?gR<$?iyT!TL`X;1^2~W7YVSq1qtqM!JWlDxLm%}UESUM zndj}Uny%^UnjhVhFb!8V3s(a#fIy>`VW15{5nuy;_V&a5O#0S&!a4dSkUMz_VHu3S zGA@p9Q$T|Sj}tYGWdjH;Mpp8m&yu&YURcrt{K;R|kM~(*{v%QwrBJIUF+K1kX5ZmF zty3i{d`y0;DgE+de>vN@yYqFPe1Ud{!&G*Q?iUc^V=|H%4~2|N zW+DM)W!`b&V2mQ0Y4u_)uB=P@-2`v|Wm{>CxER1P^ z>c}ZPZ)xxdOCDu59{X^~2id7+6l6x)U}C4Em?H~F`uOxS1?}xMxTV|5@}PlN%Cg$( zwY6c}r60=z5ZA1L zTMe;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AWLCHe@DcDeB2}fl7#=0+#<05c3=VqM*O3bkr@9X4nO|)q0hU;Gye{L8ZN*NH8Id@mP-u;Fmb8YuorjLrW&ndip8CN%_qp982r w1WEnz9^$&s1hkp_3#lPJQ~!HI7WYYjA7>z!`?f%npAh2%rB@vD|Lau$2O)#1n*aa+ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071a..d7e66b5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From be565e22188b0f83acd8fefe643c30c4cdf4ee18 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 7 Apr 2022 01:34:58 +0700 Subject: [PATCH 11/20] [FEATURE][EXPERIMENTAL] ServerWrapper launch methods --- .../launcher/profiles/ClientProfile.java | 2 +- ServerWrapper/build.gradle | 23 +++++- .../gravit/launcher/server/ServerWrapper.java | 69 +++++++++--------- .../server/launch/ClasspathLaunch.java | 23 ++++++ .../gravit/launcher/server/launch/Launch.java | 7 ++ .../launcher/server/launch/ModuleLaunch.java | 10 +++ .../launcher/server/launch/SimpleLaunch.java | 17 +++++ .../launcher/server/launch/ModuleLaunch.java | 70 +++++++++++++++++++ modules | 2 +- 9 files changed, 188 insertions(+), 35 deletions(-) create mode 100644 ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ClasspathLaunch.java create mode 100644 ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/Launch.java create mode 100644 ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ModuleLaunch.java create mode 100644 ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/SimpleLaunch.java create mode 100644 ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 162b22c8..1190994a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -516,7 +516,7 @@ public enum SecurityManagerConfig { } public enum ClassLoaderConfig { - AGENT, LAUNCHER, SYSTEM_ARGS + AGENT, LAUNCHER, MODULE, SYSTEM_ARGS } public enum SignedClientConfig { diff --git a/ServerWrapper/build.gradle b/ServerWrapper/build.gradle index 4094ccba..ff62dd0a 100644 --- a/ServerWrapper/build.gradle +++ b/ServerWrapper/build.gradle @@ -14,16 +14,37 @@ } } +sourceSets { + java11 { + java { + srcDirs = ['src/main/java11'] + } + dependencies { + java11Implementation project(':LauncherAPI') + java11Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava } + } + } +} + sourceCompatibility = '1.8' targetCompatibility = '1.8' +compileJava11Java { + sourceCompatibility = 11 + targetCompatibility = 11 +} + jar { + into('META-INF/versions/11') { + from sourceSets.java11.output + } archiveClassifier.set('clean') manifest.attributes("Main-Class": mainClassName, "Premain-Class": mainAgentName, "Can-Redefine-Classes": "true", "Can-Retransform-Classes": "true", - "Can-Set-Native-Method-Prefix": "true") + "Can-Set-Native-Method-Prefix": "true", + "Multi-Release": "true") } task sourcesJar(type: Jar) { diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index a07766f2..396bd8c6 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -18,6 +18,10 @@ import pro.gravit.launcher.request.auth.RestoreRequest; import pro.gravit.launcher.request.update.ProfilesRequest; import pro.gravit.launcher.request.websockets.StdWebSocketService; +import pro.gravit.launcher.server.launch.ClasspathLaunch; +import pro.gravit.launcher.server.launch.Launch; +import pro.gravit.launcher.server.launch.ModuleLaunch; +import pro.gravit.launcher.server.launch.SimpleLaunch; import pro.gravit.launcher.server.setup.ServerWrapperSetup; import pro.gravit.utils.PublicURLClassLoader; import pro.gravit.utils.helper.IOHelper; @@ -139,22 +143,6 @@ public void run(String... args) throws Throwable { LogHelper.error("Auth not configured. Please use 'java -jar ServerWrapper.jar setup'"); System.exit(-1); } - Class mainClass; - if (config.classpath != null && !config.classpath.isEmpty()) { - if(config.classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER) { - URL[] urls = config.classpath.stream().map(Paths::get).map(IOHelper::toURL).toArray(URL[]::new); - ucp = new PublicURLClassLoader(urls); - Thread.currentThread().setContextClassLoader(ucp); - loader = ucp; - } else if(config.classLoaderConfig == ClientProfile.ClassLoaderConfig.AGENT) { - if (!ServerAgent.isAgentStarted()) { - LogHelper.error("JavaAgent not found"); - System.exit(-1); - } - for (String c : config.classpath) - ServerAgent.addJVMClassPath(c); - } - } if (config.autoloadLibraries) { if (!ServerAgent.isAgentStarted()) { throw new UnsupportedOperationException("JavaAgent not found, autoloadLibraries not available"); @@ -165,24 +153,34 @@ public void run(String... args) throws Throwable { LogHelper.info("Load libraries"); ServerAgent.loadLibraries(librariesDir); } - if (loader != null) mainClass = Class.forName(classname, true, loader); - else mainClass = Class.forName(classname); - MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); LogHelper.info("ServerWrapper: LaunchServer address: %s. Title: %s", config.address, Launcher.profile != null ? Launcher.profile.getTitle() : "unknown"); LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name); - LogHelper.info("Start Minecraft Server"); - LogHelper.debug("Invoke main method %s", mainClass.getName()); - if (config.args == null) { - String[] real_args; - if (args.length > 0) { - real_args = new String[args.length - 1]; - System.arraycopy(args, 1, real_args, 0, args.length - 1); - } else real_args = args; - - mainMethod.invoke(real_args); - } else { - mainMethod.invoke(config.args.toArray(new String[0])); + String[] real_args; + if (args.length > 0) { + real_args = new String[args.length - 1]; + System.arraycopy(args, 1, real_args, 0, args.length - 1); + } else real_args = args; + Launch launch; + switch (config.classLoaderConfig) { + case LAUNCHER: + launch = new ClasspathLaunch(); + break; + case MODULE: + launch = new ModuleLaunch(); + break; + default: + launch = new SimpleLaunch(); + break; } + LogHelper.info("Start Minecraft Server"); + LogHelper.debug("Invoke main method %s with %s", config.mainclass, launch.getClass().getName()); + try { + launch.run(config, real_args); + } catch (Throwable e) { + LogHelper.error(e); + System.exit(-1); + } + System.exit(0); } public void updateLauncherConfig() { @@ -231,8 +229,15 @@ public static final class Config { public long oauthExpireTime; public Map extendedTokens; public LauncherConfig.LauncherEnvironment env; + public ModuleConf moduleConf = new ModuleConf(); } - public static final class WebSocketConf { + public static final class ModuleConf { + public List modules = new ArrayList<>(); + public List modulePath = new ArrayList<>(); + public String mainModule = ""; + public Map exports = new HashMap<>(); + public Map opens = new HashMap<>(); + public Map reads = new HashMap<>(); } } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ClasspathLaunch.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ClasspathLaunch.java new file mode 100644 index 00000000..05173094 --- /dev/null +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ClasspathLaunch.java @@ -0,0 +1,23 @@ +package pro.gravit.launcher.server.launch; + +import pro.gravit.launcher.server.ServerWrapper; +import pro.gravit.utils.PublicURLClassLoader; +import pro.gravit.utils.helper.IOHelper; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.net.URL; +import java.nio.file.Paths; + +public class ClasspathLaunch implements Launch { + @Override + @SuppressWarnings("ConfusingArgumentToVarargsMethod") + public void run(ServerWrapper.Config config, String[] args) throws Throwable { + URL[] urls = config.classpath.stream().map(Paths::get).map(IOHelper::toURL).toArray(URL[]::new); + ClassLoader ucl = new PublicURLClassLoader(urls); + Class mainClass = Class.forName(config.mainclass, true, ucl); + MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); + mainMethod.invoke(args); + } +} diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/Launch.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/Launch.java new file mode 100644 index 00000000..becc49f8 --- /dev/null +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/Launch.java @@ -0,0 +1,7 @@ +package pro.gravit.launcher.server.launch; + +import pro.gravit.launcher.server.ServerWrapper; + +public interface Launch { + void run(ServerWrapper.Config config, String[] args) throws Throwable; +} diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ModuleLaunch.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ModuleLaunch.java new file mode 100644 index 00000000..2cb55ad7 --- /dev/null +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/ModuleLaunch.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.server.launch; + +import pro.gravit.launcher.server.ServerWrapper; + +public class ModuleLaunch implements Launch { + @Override + public void run(ServerWrapper.Config config, String[] args) throws Throwable { + throw new UnsupportedOperationException("Module system not supported"); + } +} diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/SimpleLaunch.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/SimpleLaunch.java new file mode 100644 index 00000000..192f95dc --- /dev/null +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/launch/SimpleLaunch.java @@ -0,0 +1,17 @@ +package pro.gravit.launcher.server.launch; + +import pro.gravit.launcher.server.ServerWrapper; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +public class SimpleLaunch implements Launch { + @Override + @SuppressWarnings("ConfusingArgumentToVarargsMethod") + public void run(ServerWrapper.Config config, String[] args) throws Throwable { + Class mainClass = Class.forName(config.mainclass); + MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); + mainMethod.invoke(args); + } +} diff --git a/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java b/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java new file mode 100644 index 00000000..ffe102a6 --- /dev/null +++ b/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java @@ -0,0 +1,70 @@ +package pro.gravit.launcher.server.launch; + +import pro.gravit.launcher.server.ServerWrapper; +import pro.gravit.utils.PublicURLClassLoader; +import pro.gravit.utils.helper.IOHelper; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.module.Configuration; +import java.lang.module.ModuleFinder; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Collectors; + +public class ModuleLaunch implements Launch { + @Override + @SuppressWarnings("ConfusingArgumentToVarargsMethod") + public void run(ServerWrapper.Config config, String[] args) throws Throwable { + URL[] urls = config.classpath.stream().map(Paths::get).map(IOHelper::toURL).toArray(URL[]::new); + ClassLoader ucl = new PublicURLClassLoader(urls); + // Create Module Layer + ModuleFinder finder = ModuleFinder.of(config.moduleConf.modulePath.stream().map(Paths::get).toArray(Path[]::new)); + ModuleLayer bootLayer = ModuleLayer.boot(); + Configuration configuration = bootLayer.configuration() + .resolveAndBind(ModuleFinder.of(), finder, config.moduleConf.modules); + ModuleLayer.Controller controller = ModuleLayer.defineModulesWithOneLoader(configuration, List.of(bootLayer), ucl); + ModuleLayer layer = controller.layer(); + // Configure exports / opens + for(var e : config.moduleConf.exports.entrySet()) { + String[] split = e.getKey().split("\\\\"); + Module source = layer.findModule(split[0]).orElseThrow(); + String pkg = split[1]; + Module target = layer.findModule(e.getValue()).orElseThrow(); + controller.addExports(source, pkg, target); + } + for(var e : config.moduleConf.opens.entrySet()) { + String[] split = e.getKey().split("\\\\"); + Module source = layer.findModule(split[0]).orElseThrow(); + String pkg = split[1]; + Module target = layer.findModule(e.getValue()).orElseThrow(); + controller.addOpens(source, pkg, target); + } + for(var e : config.moduleConf.reads.entrySet()) { + Module source = layer.findModule(e.getKey()).orElseThrow(); + Module target = layer.findModule(e.getValue()).orElseThrow(); + controller.addReads(source, target); + } + Module mainModule = layer.findModule(config.moduleConf.mainModule).orElseThrow(); + Module unnamed = ModuleLaunch.class.getClassLoader().getUnnamedModule(); + if(unnamed != null) { + controller.addOpens(mainModule, getPackageFromClass(config.mainclass), unnamed); + } + // Start main class + ClassLoader loader = mainModule.getClassLoader(); + Class mainClass = Class.forName(config.mainclass, true, loader); + MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); + mainMethod.invoke(args); + } + + private static String getPackageFromClass(String clazz) { + int index = clazz.indexOf("."); + if(index >= 0) { + return clazz.substring(0, index); + } + return clazz; + } +} diff --git a/modules b/modules index a1318b09..2d9466cd 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit a1318b09c1f5657ad60eaee362746cd493d38c8a +Subproject commit 2d9466cd82b1a6c916f045851021585e6e831bd5 From 2709cbe95fd4e9ced9695103427bc37039f1b6a3 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 7 Apr 2022 01:39:40 +0700 Subject: [PATCH 12/20] [FIX] getPackageFromClass --- .../java11/pro/gravit/launcher/server/launch/ModuleLaunch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java b/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java index ffe102a6..2539d3dd 100644 --- a/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java +++ b/ServerWrapper/src/main/java11/pro/gravit/launcher/server/launch/ModuleLaunch.java @@ -61,7 +61,7 @@ public void run(ServerWrapper.Config config, String[] args) throws Throwable { } private static String getPackageFromClass(String clazz) { - int index = clazz.indexOf("."); + int index = clazz.lastIndexOf("."); if(index >= 0) { return clazz.substring(0, index); } From dc27fc04aa3d1b5dbb6e8eb9c35bcbd223923076 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 7 Apr 2022 22:09:20 +0700 Subject: [PATCH 13/20] [FIX] Forge 1.17+ exit crash --- .../client/ClientLauncherEntryPoint.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 44d2c495..af76d9f9 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -349,19 +349,19 @@ private static void launch(ClientProfile profile, ClientLauncherProcess.ClientPa } FMLPatcher.apply(); LauncherEngine.modulesManager.invokeEvent(new ClientProcessPreInvokeMainClassEvent(params, profile, args)); - { - List compatClasses = profile.getCompatClasses(); - for (String e : compatClasses) { - Class clazz = classLoader.loadClass(e); - MethodHandle runMethod = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class)); - runMethod.invoke(); - } - } - MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity(); - Launcher.LAUNCHED.set(true); - JVMHelper.fullGC(); // Invoke main method try { + { + List compatClasses = profile.getCompatClasses(); + for (String e : compatClasses) { + Class clazz = classLoader.loadClass(e); + MethodHandle runMethod = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class)); + runMethod.invoke(); + } + } + MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity(); + Launcher.LAUNCHED.set(true); + JVMHelper.fullGC(); mainMethod.invokeWithArguments((Object) args.toArray(new String[0])); LogHelper.debug("Main exit successful"); } catch (Throwable e) { From a20b70e2a11d5d887b89367d556410a31c009efc Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 7 Apr 2022 22:16:25 +0700 Subject: [PATCH 14/20] [FEATURE] HttpAuthCoreProvider toString() methods --- .../auth/core/HttpAuthCoreProvider.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java index c4539c03..c2ca5844 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java @@ -363,6 +363,19 @@ public Map getProperties() { } return properties; } + + @Override + public String toString() { + return "HttpUser{" + + "username='" + username + '\'' + + ", uuid=" + uuid + + ", serverId='" + serverId + '\'' + + ", accessToken='" + accessToken + '\'' + + ", permissions=" + permissions + + ", assets=" + getAssets() + + ", properties=" + properties + + '}'; + } } public static class HttpUserSession implements UserSession { @@ -393,5 +406,14 @@ public User getUser() { public long getExpireIn() { return expireIn; } + + @Override + public String toString() { + return "HttpUserSession{" + + "id='" + id + '\'' + + ", user=" + user + + ", expireIn=" + expireIn + + '}'; + } } } From b614ae6d69c27962946dcfeb6b75612b69b4fed8 Mon Sep 17 00:00:00 2001 From: Gravit'a Date: Sat, 9 Apr 2022 18:02:26 +0700 Subject: [PATCH 15/20] [ANY] Update modules --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 2d9466cd..976f4130 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 2d9466cd82b1a6c916f045851021585e6e831bd5 +Subproject commit 976f41301ebffabbc438cd77fabb573836ce0893 From b8b841cdd946f57e0f08e76d1c8aed1975c3457e Mon Sep 17 00:00:00 2001 From: Gravit'a Date: Sat, 9 Apr 2022 20:40:58 +0700 Subject: [PATCH 16/20] [ANY] Update modules --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 976f4130..9aa46289 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 976f41301ebffabbc438cd77fabb573836ce0893 +Subproject commit 9aa462893af47926a7bdaa957fdb354856cbc141 From 89b800c124dd706177afbd3402c9081aa234fc36 Mon Sep 17 00:00:00 2001 From: Gravit'a Date: Sun, 10 Apr 2022 01:26:42 +0700 Subject: [PATCH 17/20] [ANY] Update modules --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 9aa46289..af6e144e 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 9aa462893af47926a7bdaa957fdb354856cbc141 +Subproject commit af6e144e4234851bfc5fd27b56584f510bc58bf6 From 5e6ab3763e380b2769e2b2c7a50a891ddbbdb261 Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 10 Apr 2022 22:14:55 +0700 Subject: [PATCH 18/20] [FIX] DiscordBotConsole --- .../java/pro/gravit/launchserver/manangers/AuthManager.java | 1 + .../gravit/launchserver/manangers/hook/AuthHookManager.java | 3 +++ .../launchserver/socket/response/auth/CheckServerResponse.java | 1 + modules | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java index f494f990..a419b494 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java @@ -84,6 +84,7 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken if(client.permissions == null) client.permissions = new ClientPermissions(); client.permissions.addPerm("launchserver.checkserver"); client.permissions.addPerm(String.format("launchserver.profile.%s.show", info.serverName)); + client.setSerializableProperty("launchserver.serverName", info.serverName); return true; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java index a8f97153..2947cbcd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java @@ -1,5 +1,7 @@ package pro.gravit.launchserver.manangers.hook; +import pro.gravit.launchserver.auth.core.User; +import pro.gravit.launchserver.manangers.AuthManager; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.launchserver.socket.response.auth.CheckServerResponse; @@ -12,6 +14,7 @@ public class AuthHookManager { public final BiHookSet preHook = new BiHookSet<>(); public final BiHookSet postHook = new BiHookSet<>(); public final BiHookSet checkServerHook = new BiHookSet<>(); + public final BiHookSet postCheckServerHook = new BiHookSet<>(); public final BiHookSet joinServerHook = new BiHookSet<>(); public final BiHookSet setProfileHook = new BiHookSet<>(); public final HookSet registraion = new HookSet<>(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java index 9d41b9f0..dad489fe 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java @@ -37,6 +37,7 @@ public void execute(ChannelHandlerContext ctx, Client pClient) { } result.playerProfile = report.playerProfile; result.uuid = report.uuid; + server.authHookManager.postCheckServerHook.hook(report, pClient); logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile == null ? null : result.playerProfile.username, result.uuid, serverID); } catch (AuthException | HookException e) { sendError(e.getMessage()); diff --git a/modules b/modules index af6e144e..75fd808a 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit af6e144e4234851bfc5fd27b56584f510bc58bf6 +Subproject commit 75fd808a24a390907333e62076ee8e1556424e6b From fa50a6f64cfe15f4ca76ada7ab7f470a9bbd9e2e Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 10 Apr 2022 23:23:51 +0700 Subject: [PATCH 19/20] [ANY] Update modules --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 75fd808a..4319cabb 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 75fd808a24a390907333e62076ee8e1556424e6b +Subproject commit 4319cabbeb0abbb1c6bc76f23c16b7902b2be500 From f4280b89f44dd028460ceefb1cebb0d823196571 Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 11 Apr 2022 17:11:53 +0700 Subject: [PATCH 20/20] [ANY] 5.2.10 stable --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index c03226ed..dae735bc 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -8,7 +8,7 @@ public final class Version implements Comparable { public static final int MINOR = 2; public static final int PATCH = 10; public static final int BUILD = 1; - public static final Version.Type RELEASE = Type.DEV; + public static final Version.Type RELEASE = Type.STABLE; public final int major; public final int minor; public final int patch; diff --git a/build.gradle b/build.gradle index 247dc6d4..97f3a3ce 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.10' apply false } group = 'pro.gravit.launcher' -version = '5.2.10-SNAPSHOT' +version = '5.2.10' apply from: 'props.gradle'