diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9379d45a..fd5ef96f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,9 +42,9 @@ jobs: cd ../../../LauncherAuthlib/build/libs cp LauncherAuthlib.jar ../../../artifacts/LauncherAuthlib.jar cd ../../../ - cp modules/*_module/build/libs/*.jar artifacts/modules - cp modules/*_swmodule/build/libs/*.jar artifacts/modules - cp modules/*_lmodule/build/libs/*.jar artifacts/modules + cp modules/*_module/build/libs/*.jar artifacts/modules || true + cp modules/*_swmodule/build/libs/*.jar artifacts/modules || true + cp modules/*_lmodule/build/libs/*.jar artifacts/modules || true - name: Upload artifacts uses: actions/upload-artifact@v1 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 d792cde5..fe86458a 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 @@ -1,12 +1,16 @@ package pro.gravit.launchserver.auth.protect; import pro.gravit.launcher.events.request.GetSecureLevelInfoRequestEvent; +import pro.gravit.launcher.events.request.HardwareReportRequestEvent; +import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent; +import pro.gravit.launchserver.auth.protect.interfaces.HardwareProtectHandler; import pro.gravit.launchserver.auth.protect.interfaces.SecureProtectHandler; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse; -public class AdvancedProtectHandler extends ProtectHandler implements SecureProtectHandler { - +public class AdvancedProtectHandler extends StdProtectHandler implements SecureProtectHandler, HardwareProtectHandler { + public boolean enableHardwareFeature; @Override public boolean allowGetAccessToken(AuthResponse.AuthContext context) { return (context.authType == AuthResponse.ConnectTypes.CLIENT) && context.client.checkSign; @@ -26,4 +30,24 @@ public GetSecureLevelInfoRequestEvent onGetSecureLevelInfo(GetSecureLevelInfoReq public boolean allowGetSecureLevelInfo(Client client) { return client.checkSign; } + + @Override + public void onHardwareReport(HardwareReportResponse response, Client client) { + if(!enableHardwareFeature) + { + response.sendResult(new HardwareReportRequestEvent()); + return; + } + + response.sendResult(new HardwareReportRequestEvent()); + } + + @Override + public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { + if(enableHardwareFeature) + { + return new VerifySecureLevelKeyRequestEvent(true); + } + return new VerifySecureLevelKeyRequestEvent(); + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/HardwareProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/HardwareProtectHandler.java new file mode 100644 index 00000000..7f2621ec --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/HardwareProtectHandler.java @@ -0,0 +1,8 @@ +package pro.gravit.launchserver.auth.protect.interfaces; + +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse; + +public interface HardwareProtectHandler { + void onHardwareReport(HardwareReportResponse response, Client client); +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java index 26b5e810..d19b9538 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java @@ -2,6 +2,7 @@ import pro.gravit.launcher.events.request.GetSecureLevelInfoRequestEvent; import pro.gravit.launcher.events.request.SecurityReportRequestEvent; +import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.utils.helper.SecurityHelper; @@ -31,4 +32,8 @@ default void verifySecureLevelKey(byte[] publicKey, byte[] data, byte[] signatur default SecurityReportRequestEvent onSecurityReport(SecurityReportResponse report, Client client) { return new SecurityReportRequestEvent(); } + default VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) + { + return new VerifySecureLevelKeyRequestEvent(); + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java index 47451bf0..9e5a1af4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java @@ -50,6 +50,9 @@ public String getName() { public Path process(Path inputFile) throws IOException { if (signedDataGenerator != null) return inputFile; try { + LogHelper.warning("You are using an auto-generated certificate (sign.enabled false). It is not good"); + LogHelper.warning("It is highly recommended that you use the correct certificate (sign.enabled true)"); + LogHelper.warning("You can use GenerateCertificateModule or your own certificate."); X500NameBuilder subject = new X500NameBuilder(); subject.addRDN(BCStyle.CN, server.config.projectName.concat(" Autogenerated")); subject.addRDN(BCStyle.O, server.config.projectName); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java index 3fc2636c..af4f2d8b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/ProGuardBuildTask.java @@ -2,6 +2,7 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.utils.helper.IOHelper; +import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; import proguard.Configuration; import proguard.ConfigurationParser; @@ -10,6 +11,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.nio.file.Paths; public class ProGuardBuildTask implements LauncherBuildTask { private final LaunchServer server; @@ -30,6 +32,21 @@ public Path process(Path inputFile) throws IOException { Configuration proguard_cfg = new Configuration(); ConfigurationParser parser = new ConfigurationParser(server.proguardConf.buildConfig(inputFile, outputJar), server.proguardConf.proguard.toFile(), System.getProperties()); + if (JVMHelper.JVM_VERSION >= 9) + { + Path javaJModsPath = Paths.get(System.getProperty("java.home")).resolve("jmods"); + if(!IOHelper.exists(javaJModsPath)) + { + LogHelper.warning("Directory %s not found. It is not good", javaJModsPath); + } + else + { + //Find javaFX libraries + if(!IOHelper.exists(javaJModsPath.resolve("javafx.base.jmod"))) LogHelper.warning("javafx.base.jmod not found. Launcher can be assembled incorrectly. Maybe you need to install OpenJFX?"); + if(!IOHelper.exists(javaJModsPath.resolve("javafx.graphics.jmod"))) LogHelper.warning("javafx.graphics.jmod not found. Launcher can be assembled incorrectly. Maybe you need to install OpenJFX?"); + if(!IOHelper.exists(javaJModsPath.resolve("javafx.controls.jmod"))) LogHelper.warning("javafx.controls.jmod not found. Launcher can be assembled incorrectly. Maybe you need to install OpenJFX?"); + } + } try { parser.parse(proguard_cfg); ProGuard proGuard = new ProGuard(proguard_cfg); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java index 4996ab05..89433a37 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java @@ -17,7 +17,7 @@ public LaunchServerModulesManager(Path modulesDir, Path configDir, LauncherTrust super(modulesDir, configDir, trustManager); coreModule = new LaunchServerCoreModule(); checkMode = LauncherTrustManager.CheckMode.NONE_IN_NOT_SIGNED; - modules.add(coreModule); + loadModule(coreModule); } public void fullInitializedLaunchServer(LaunchServer server) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java index 889e349c..a51182c2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java @@ -8,6 +8,8 @@ import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.NettyConnectContext; import pro.gravit.launchserver.socket.WebSocketService; +import pro.gravit.utils.BiHookSet; +import pro.gravit.utils.HookSet; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; @@ -22,6 +24,7 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler hooks = new BiHookSet<>(); private Client client; public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) { @@ -58,6 +61,7 @@ public void channelActive(ChannelHandlerContext ctx) { @Override protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) { // ping and pong frames already handled + if(hooks.hook(ctx, frame)) return; if (frame instanceof TextWebSocketFrame) { service.process(ctx, (TextWebSocketFrame) frame, client, context.ip); } else if ((frame instanceof PingWebSocketFrame)) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java index c9aa8db2..c5414576 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -1,7 +1,9 @@ package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launcher.events.request.HardwareReportRequestEvent; import pro.gravit.launcher.request.secure.HardwareReportRequest; +import pro.gravit.launchserver.auth.protect.interfaces.HardwareProtectHandler; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; @@ -15,6 +17,13 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception { - + if(server.config.protectHandler instanceof HardwareProtectHandler) + { + ((HardwareProtectHandler) server.config.protectHandler).onHardwareReport(this, client); + } + else + { + sendResult(new HardwareReportRequestEvent()); + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java index bd4c95e8..8037a821 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java @@ -39,6 +39,6 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { } client.trustLevel.keyChecked = true; client.trustLevel.publicKey = publicKey; - sendResult(new VerifySecureLevelKeyRequestEvent()); + sendResult(secureProtectHandler.onSuccessVerify(client)); } } diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index 9e7232ed..1b3bcdf3 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -1,9 +1,6 @@ package pro.gravit.launcher; -import pro.gravit.launcher.client.ClientLauncherEntryPoint; -import pro.gravit.launcher.client.ClientLauncherProcess; -import pro.gravit.launcher.client.ClientModuleManager; -import pro.gravit.launcher.client.DirBridge; +import pro.gravit.launcher.client.*; import pro.gravit.launcher.client.events.ClientEngineInitPhase; import pro.gravit.launcher.client.events.ClientExitPhase; import pro.gravit.launcher.client.events.ClientPreGuiPhase; @@ -93,6 +90,7 @@ public static void main(String... args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncherEntryPoint.class); LauncherEngine.modulesManager = new ClientModuleManager(); + LauncherEngine.modulesManager.loadModule(new ClientLauncherCoreModule()); LauncherConfig.initModules(LauncherEngine.modulesManager); LauncherEngine.modulesManager.initModules(null); // Start Launcher diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherCoreModule.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherCoreModule.java new file mode 100644 index 00000000..21e3c8af --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherCoreModule.java @@ -0,0 +1,17 @@ +package pro.gravit.launcher.client; + +import pro.gravit.launcher.modules.LauncherInitContext; +import pro.gravit.launcher.modules.LauncherModule; +import pro.gravit.launcher.modules.LauncherModuleInfo; +import pro.gravit.utils.Version; + +public class ClientLauncherCoreModule extends LauncherModule { + public ClientLauncherCoreModule() { + super(new LauncherModuleInfo("ClientLauncherCore", Version.getVersion())); + } + + @Override + public void init(LauncherInitContext initContext) { + + } +} 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 b8735a44..b61d9d89 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -67,6 +67,7 @@ public static void main(String[] args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncherEntryPoint.class); LauncherEngine.modulesManager = new ClientModuleManager(); + LauncherEngine.modulesManager.loadModule(new ClientLauncherCoreModule()); LauncherConfig.initModules(LauncherEngine.modulesManager); //INIT LauncherEngine.modulesManager.initModules(null); initGson(LauncherEngine.modulesManager); 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 785c3f53..c6a63041 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 @@ -3,6 +3,15 @@ import pro.gravit.launcher.events.RequestEvent; public class VerifySecureLevelKeyRequestEvent extends RequestEvent { + public boolean needHardwareInfo; + + public VerifySecureLevelKeyRequestEvent() { + } + + public VerifySecureLevelKeyRequestEvent(boolean needHardwareInfo) { + this.needHardwareInfo = needHardwareInfo; + } + @Override public String getType() { return "verifySecureLevelKey"; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 706b2a80..614cc940 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -6,7 +6,7 @@ public final class Version { public static final int MAJOR = 5; public static final int MINOR = 1; - public static final int PATCH = 4; + public static final int PATCH = 5; public static final int BUILD = 1; public static final Version.Type RELEASE = Type.STABLE; public final int major; diff --git a/build.gradle b/build.gradle index 6869c62b..b507c090 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.8' apply false } group = 'pro.gravit.launcher' -version = '5.1.4' +version = '5.1.5' apply from: 'props.gradle' diff --git a/modules b/modules index b3e50712..04984c3c 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit b3e50712f6a01f6ea4f0d7772371f9c01c309438 +Subproject commit 04984c3c75c484671e5b286527403ab55da28a01