[FEATURE] Окончательный переход на новую систему props (часть 2).

Список props(текущий тип и значение):
String launcher.projectName; // Название проекта
String launcher.address; // Адрес сервера
int launcher.port; // Порт клиента (рандом) используется для передачи параметров запуска
String launcher.guardType; // Тип защиты (java, wrapper, no и т. д.)
String runtimeconfig.secretKeyClient; // Секретный ключ
String runtimeconfig.oemUnlockKey; // Ключ разблокировки консоли ввода команд в лаунчере...
String runtimeconfig.secureCheckHash; // Проверки безопасности лаунчера (хеш)
String runtimeconfig.secureCheckSalt; // Это же но соль...
String runtimeconfig.passwordEncryptKey; // Ключ для шифровки пароля...
int launchercore.env; // Среда лаунчсервера (0=DEV,1=DEBUG,2=STD,3=PROD, остальное = так же STD)
boolean launcher.isWarningMissArchJava; // Выводить ли предупреждение о os.bits!= java.bits
List<byte[]> launchercore.certificates; // EC-сертификаты в формате byte[]
List<Class<?>> launcher.modules; // Список классов модулей лаунчера.
This commit is contained in:
Zaxar163 2020-01-31 19:21:24 +01:00
parent 554ca54c4a
commit 6b7468e366
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B
5 changed files with 23 additions and 17 deletions

View file

@ -2,6 +2,7 @@
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
@ -14,7 +15,6 @@
import pro.gravit.launchserver.binary.BuildContext; import pro.gravit.launchserver.binary.BuildContext;
import pro.gravit.utils.HookException; import pro.gravit.utils.HookException;
import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JarHelper;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.SecurityHelper;
@ -170,7 +170,7 @@ public Path process(Path inputJar) throws IOException {
//LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash)); //LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash));
if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken();
properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey); properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey);
context.clientModules.forEach(launcherConfigurator::addModuleClass); properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
reader.getCp().add(new JarFile(inputJar.toFile())); reader.getCp().add(new JarFile(inputJar.toFile()));
server.launcherBinary.coreLibs.forEach(e -> { server.launcherBinary.coreLibs.forEach(e -> {
try { try {

View file

@ -31,7 +31,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
EnvHelper.checkDangerousParams(); EnvHelper.checkDangerousParams();
LauncherConfig config = Launcher.getConfig(); LauncherConfig config = Launcher.getConfig();
LauncherEngine.modulesManager = new ClientModuleManager(); LauncherEngine.modulesManager = new ClientModuleManager();
LauncherConfig.initModules(); LauncherConfig.initModules(LauncherEngine.modulesManager);
LogHelper.info("Launcher for project %s", config.projectName); LogHelper.info("Launcher for project %s", config.projectName);
if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) {

View file

@ -80,7 +80,7 @@ public static void main(String... args) throws Throwable {
LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(LauncherAgent.class);
LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.checkClass(ClientLauncher.class);
LauncherEngine.modulesManager = new ClientModuleManager(); LauncherEngine.modulesManager = new ClientModuleManager();
LauncherConfig.initModules(); LauncherConfig.initModules(LauncherEngine.modulesManager);
LauncherEngine.modulesManager.initModules(null); LauncherEngine.modulesManager.initModules(null);
// Start Launcher // Start Launcher
initGson(LauncherEngine.modulesManager); initGson(LauncherEngine.modulesManager);

View file

@ -443,7 +443,7 @@ public static void main(String... args) throws Throwable {
LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(LauncherAgent.class);
LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.checkClass(ClientLauncher.class);
LauncherEngine.modulesManager = new ClientModuleManager(); LauncherEngine.modulesManager = new ClientModuleManager();
LauncherConfig.initModules(); //INIT LauncherConfig.initModules(LauncherEngine.modulesManager); //INIT
LauncherEngine.modulesManager.initModules(null); LauncherEngine.modulesManager.initModules(null);
initGson(LauncherEngine.modulesManager); initGson(LauncherEngine.modulesManager);
LauncherEngine.verifyNoAgent(); LauncherEngine.verifyNoAgent();

View file

@ -1,12 +1,17 @@
package pro.gravit.launcher; package pro.gravit.launcher;
import pro.gravit.launcher.modules.LauncherModule;
import pro.gravit.launcher.modules.LauncherModulesManager;
import pro.gravit.launcher.serialize.HInput; import pro.gravit.launcher.serialize.HInput;
import pro.gravit.launcher.serialize.HOutput; import pro.gravit.launcher.serialize.HOutput;
import pro.gravit.launcher.serialize.stream.StreamObject; import pro.gravit.launcher.serialize.stream.StreamObject;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.VerifyHelper; import pro.gravit.utils.helper.VerifyHelper;
import java.io.IOException; import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.interfaces.ECPublicKey; import java.security.interfaces.ECPublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
@ -17,6 +22,8 @@ public final class LauncherConfig extends StreamObject {
private static final int cenv = -1; private static final int cenv = -1;
@LauncherInject("launchercore.certificates") @LauncherInject("launchercore.certificates")
private static final List<byte[]> secureConfigCertificates = null; private static final List<byte[]> secureConfigCertificates = null;
@LauncherInject("launcher.modules")
private static final List<Class<?>> modulesClasses = null;
@LauncherInject("launcher.address") @LauncherInject("launcher.address")
public String address; public String address;
@LauncherInject("launcher.projectName") @LauncherInject("launcher.projectName")
@ -118,17 +125,16 @@ public enum LauncherEnvironment {
DEV, DEBUG, STD, PROD DEV, DEBUG, STD, PROD
} }
public static void initModules() { private static final MethodType VOID_TYPE = MethodType.methodType(void.class);
// TODO Fill
/* public static void initModules(LauncherModulesManager modulesManager) {
* Old filler for (Class<?> clazz : modulesClasses)
public void addModuleClass(String fullName) { try {
initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc)); modulesManager.loadModule((LauncherModule) MethodHandles.publicLookup().findConstructor(clazz, VOID_TYPE).invokeWithArguments(Collections.emptyList()));
initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/'))); } catch (Throwable e) {
initModuleMethod.instructions.add(new InsnNode(Opcodes.DUP)); LogHelper.error(e);
initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "<init>", "()V")); }
initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "loadModule", registerModDesc)); // This method should be called once at exec time.
} modulesClasses.clear();
*/
} }
} }