From d2858f7c3773cc863843bcd05ae111474b9cbb3a Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 6 Jan 2019 19:20:25 +0700 Subject: [PATCH 1/4] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BB=D0=B5=D0=B3=D0=B0=D1=81=D0=B8=20=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/JARLauncherBinary.java | 92 ------------------- .../manangers/NodeTransformer.java | 43 --------- .../manangers/hook/BuildHookManager.java | 18 +--- 3 files changed, 1 insertion(+), 152 deletions(-) delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 93adb743..00dccfe0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -1,52 +1,18 @@ package ru.gravit.launchserver.binary; -import static ru.gravit.utils.helper.IOHelper.newZipEntry; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -import javassist.CannotCompileException; -import javassist.NotFoundException; -import proguard.Configuration; -import proguard.ConfigurationParser; -import proguard.ParseException; -import proguard.ProGuard; -import ru.gravit.launcher.AutogenConfig; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.asm.ClassMetadataReader; import ru.gravit.launchserver.binary.tasks.LauncherBuildTask; import ru.gravit.launchserver.binary.tasks.MainBuildTask; import ru.gravit.launchserver.binary.tasks.ProGuardBuildTask; import ru.gravit.launchserver.binary.tasks.UnpackBuildTask; -import ru.gravit.launchserver.manangers.hook.BuildHookManager.ZipBuildHook; -import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; -import ru.gravit.utils.helper.UnpackHelper; public final class JARLauncherBinary extends LauncherBinary { - //public ClassMetadataReader reader; public ArrayList tasks; public JARLauncherBinary(LaunchServer server) throws IOException { super(server); @@ -55,16 +21,6 @@ public JARLauncherBinary(LaunchServer server) throws IOException { tasks.add(new MainBuildTask()); if(server.config.enabledProGuard) tasks.add(new ProGuardBuildTask()); syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar"); - /*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); - guardDir = server.dir.resolve(Launcher.GUARD_DIR); - initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE); - obfJar = server.dir.resolve(server.config.binaryName + "-obfPre.jar"); - obfOutJar = server.config.buildPostTransform.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar") - : syncBinaryFile; - cleanJar = server.dir.resolve(server.config.binaryName + "-clean.jar"); - reader = new ClassMetadataReader(); - UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), cleanJar); - reader.getCp().add(new JarFile(cleanJar.toFile()));*/ } @Override @@ -90,53 +46,5 @@ public void build() throws IOException { long time_end = System.currentTimeMillis(); IOHelper.move(thisPath, syncBinaryFile); LogHelper.info("Build successful from %d millis",time_end - time_start); - - // ProGuard - - /*for (Runnable r : server.buildHookManager.getPostProguardRunHooks()) - r.run(); - try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(obfJar)); - ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(obfOutJar))) { - ZipEntry e = input.getNextEntry(); - while (e != null) { - String filename = e.getName(); - output.putNextEntry(IOHelper.newZipEntry(e)); - if (filename.endsWith(".class")) { - String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length()); - byte[] bytes; - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { - IOHelper.transfer(input, outputStream); - bytes = outputStream.toByteArray(); - } - //bytes = server.buildHookManager.proGuardClassTransform(bytes, classname, this); - try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { - IOHelper.transfer(inputStream, output); - } - } else - IOHelper.transfer(input, output); - e = input.getNextEntry(); - } - for (ZipBuildHook h : server.buildHookManager.getProguardBuildHooks()) - h.build(output); - } - if (server.config.buildPostTransform.enabled) - transformedBuild();*/ - } - - private void transformedBuild() throws IOException { - /*List cmd = new ArrayList<>(1); - for (String v : server.config.buildPostTransform.script) - cmd.add(CommonHelper.replace(v, "launcher-output", IOHelper.toAbsPathString(syncBinaryFile), "launcher-obf", - IOHelper.toAbsPathString(obfJar), "launcher-nonObf", IOHelper.toAbsPathString(binaryFile))); - ProcessBuilder builder = new ProcessBuilder(); - builder.directory(IOHelper.toAbsPath(server.dir).toFile()); - builder.inheritIO(); - builder.command(cmd); - Process proc = builder.start(); - try { - LogHelper.debug("Transformer process return code: " + proc.waitFor()); - } catch (InterruptedException e) { - LogHelper.error(e); - }*/ } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java deleted file mode 100644 index aa5b2986..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java +++ /dev/null @@ -1,43 +0,0 @@ -package ru.gravit.launchserver.manangers; - -import java.util.ArrayList; -import java.util.List; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launchserver.asm.SafeClassWriter; -import ru.gravit.launchserver.binary.JARLauncherBinary; -import ru.gravit.launchserver.binary.tasks.MainBuildTask; -import ru.gravit.launchserver.manangers.hook.BuildHookManager.Transformer; - -public class NodeTransformer implements Transformer { - @FunctionalInterface - public interface ClassNodeTransformer { - void transform(ClassNode node, String classname, JARLauncherBinary data); - } - - private final List transLst; - - public List getTransLst() { - return transLst; - } - - public NodeTransformer() { - transLst = new ArrayList<>(); - } - - @Override - public byte[] transform(byte[] input, String classname, MainBuildTask data) { - //ClassReader cr = new ClassReader(input); - //ClassNode cn = new ClassNode(); - //cr.accept(cn, data.server.config.env.equals(LauncherConfig.LauncherEnvironment.PROD) || data.server.config.env.equals(LauncherConfig.LauncherEnvironment.STD) ? ClassReader.SKIP_DEBUG : 0); - //for (ClassNodeTransformer tr : transLst) tr.transform(cn, classname, data); - //ClassWriter cw = new SafeClassWriter(data.reader, ClassWriter.COMPUTE_MAXS); - //cn.accept(cw); - //return cw.toByteArray(); - return null; - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java index e5c33d2b..c3d40fae 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java @@ -10,9 +10,7 @@ import ru.gravit.launcher.modules.TestClientModule; import ru.gravit.launchserver.binary.BuildContext; import ru.gravit.launchserver.binary.JAConfigurator; -import ru.gravit.launchserver.binary.JARLauncherBinary; import ru.gravit.launchserver.binary.tasks.MainBuildTask; -import ru.gravit.launchserver.manangers.NodeTransformer; public class BuildHookManager { @FunctionalInterface @@ -40,8 +38,6 @@ public interface Transformer { private final Set CLASS_BLACKLIST; private final Set MODULE_CLASS; private final Map INCLUDE_CLASS; - private final NodeTransformer noder; - private final NodeTransformer proguardNoder; public BuildHookManager() { POST_HOOKS = new HashSet<>(4); @@ -59,18 +55,6 @@ public BuildHookManager() { registerIgnoredClass("META-INF/LICENSE"); registerIgnoredClass("META-INF/NOTICE"); registerClientModuleClass(TestClientModule.class.getName()); - noder = new NodeTransformer(); - registerClassTransformer(noder); - proguardNoder = new NodeTransformer(); - registerProGuardHook(proguardNoder); - } - - public NodeTransformer getProguardNoder() { - return proguardNoder; - } - - public NodeTransformer getNoder() { - return noder; } public Set getProguardBuildHooks() { @@ -157,7 +141,7 @@ public void registerProGuardHook(Transformer hook) { } public boolean isNeedPostProguardHook() { - return POST_PROGUARD_HOOKS.size() > 1 || !POST_PROGUARDRUN_HOOKS.isEmpty() || !POST_PROGUARD_BUILDHOOKS.isEmpty() || !proguardNoder.getTransLst().isEmpty(); + return POST_PROGUARD_HOOKS.size() > 1 || !POST_PROGUARDRUN_HOOKS.isEmpty() || !POST_PROGUARD_BUILDHOOKS.isEmpty(); } public void registerPreHook(BuildHook hook) { From 5af607327bf1cc9fb483e74975d6a26cbd369402 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 6 Jan 2019 19:35:07 +0700 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BF=D0=B0=D0=BA=D0=BE=D0=B2=D0=BA=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D0=B9=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/tasks/MainBuildTask.java | 20 +++++-------------- .../binary/tasks/UnpackBuildTask.java | 11 ++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 4389c636..7848ecb8 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -33,8 +33,6 @@ public class MainBuildTask implements LauncherBuildTask { public static LaunchServer server = LaunchServer.server; - public final Path runtimeDir; - public final Path guardDir; public final Path binaryFile; public Path cleanJar; private final class RuntimeDirVisitor extends SimpleFileVisitor { @@ -48,14 +46,14 @@ private RuntimeDirVisitor(ZipOutputStream output, Map runtime) { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(runtimeDir.relativize(dir)); + String dirName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(dir)); output.putNextEntry(newEntry(dirName + '/')); return super.preVisitDirectory(dir, attrs); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(runtimeDir.relativize(file)); + String fileName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(file)); runtime.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file)); // Create zip entry and transfer contents @@ -80,14 +78,14 @@ private GuardDirVisitor(ZipOutputStream output, Map guard) { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(guardDir.relativize(dir)); + String dirName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(dir)); output.putNextEntry(newGuardEntry(dirName + '/')); return super.preVisitDirectory(dir, attrs); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(guardDir.relativize(file)); + String fileName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(file)); guard.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file)); // Create zip entry and transfer contents @@ -107,8 +105,6 @@ private static ZipEntry newGuardEntry(String fileName) { return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName); } public MainBuildTask() { - runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); - guardDir = server.dir.resolve(Launcher.GUARD_DIR); binaryFile = server.dir.resolve(server.config.binaryName + "-main.jar"); } @@ -176,7 +172,7 @@ public Path process(Path cleanJar) throws IOException { Map runtime = new HashMap<>(256); if (server.buildHookManager.buildRuntime()) { // Write launcher guard dir - IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false); + IOHelper.walk(UnpackBuildTask.runtimeDir, new RuntimeDirVisitor(output, runtime), false); // IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); } // Create launcher config file @@ -207,10 +203,4 @@ public Path process(Path cleanJar) throws IOException { public boolean allowDelete() { return true; } - - public void tryUnpack() throws IOException { - LogHelper.info("Unpacking launcher native guard files and runtime"); - UnpackHelper.unpackZipNoCheck("guard.zip", guardDir); - UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir); - } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java index 95242ede..22999d31 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java @@ -1,7 +1,9 @@ package ru.gravit.launchserver.binary.tasks; +import ru.gravit.launcher.Launcher; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.UnpackHelper; import java.io.IOException; @@ -9,7 +11,10 @@ import java.nio.file.Path; public class UnpackBuildTask implements LauncherBuildTask { + public static final Path runtimeDir = LaunchServer.server.dir.resolve(Launcher.RUNTIME_DIR); + public static final Path guardDir = LaunchServer.server.dir.resolve(Launcher.GUARD_DIR); public static LaunchServer server = LaunchServer.server; + @Override public String getName() { return "UnpackFromResources"; @@ -27,4 +32,10 @@ public Path process(Path inputFile) throws IOException { public boolean allowDelete() { return false; } + + public void tryUnpack() throws IOException { + LogHelper.info("Unpacking launcher native guard files and runtime"); + UnpackHelper.unpackZipNoCheck("guard.zip", guardDir); + UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir); + } } From 742e4326579548bd710ecf46840014d0a440a498 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 6 Jan 2019 22:15:31 +0700 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B2=D1=8F=D0=B7=D0=BA=D0=B8=20=D0=BA=20ASF?= =?UTF-8?q?ramework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compat/auth/asframework.php | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 compat/auth/asframework.php diff --git a/compat/auth/asframework.php b/compat/auth/asframework.php new file mode 100644 index 00000000..829189fd --- /dev/null +++ b/compat/auth/asframework.php @@ -0,0 +1,56 @@ +auth($args['login'],$args['pass']); + echo 'OK:'.$acc->login.''; + app::stop(); + } catch (AccountException $e) { + $msg = $e->getMessage(); + if ($msg == AccountException::AuthError) { + echo 'Login or password is incorrect'; + app::stop(); + } + if ($msg == AccountException::NoLoginError) { + echo 'This account is not allowed to sign in'; + app::stop(); + } + if ($msg == AccountException::FatalBanError) { + echo 'You are permanently banned'; + app::stop(); + } + } + } +} From dece60b8f8ba0f14f2523725e39981765be4e101 Mon Sep 17 00:00:00 2001 From: Yaroslavik Date: Sun, 6 Jan 2019 17:25:48 +0200 Subject: [PATCH 4/4] Clearing the old code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Как я понимаю, оно уже не нужно. Что-бы не вводить в заблуждение пользователей. Теперь все эти настройки в профайле клиента. ``` "updateOptional": [ { "file": "mods/modname.jar", "info":"Описание модификации", "name":"Имя модификации", "dependenciesFile": ["mods/dependMod.jar"], "conflictFile": ["mods/conflictMod.jar"], "mark": true, "subTreeLevel": 1, "isAdminOnly": false } ] ``` --- Launcher/runtime/config.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Launcher/runtime/config.js b/Launcher/runtime/config.js index 2acf6dba..9d8062d0 100644 --- a/Launcher/runtime/config.js +++ b/Launcher/runtime/config.js @@ -42,16 +42,3 @@ var serversConfig = { return serversConfig[profile][property]; } }; - -var optModNames = { - optAutoModName: true,//Попытатся автоматически создать представляемое имя модификации - modInfo: {//"Путь до опц. модификации" : "Отображаемый клиенту контент" - /*"mods/ModName-1.1.jar": { - name: "ModName", //Наименование модификации (Отображаемое в лаунчере) [Можно не указывать] - description:"Лучший в своём роде ModName.", //Описание модификации [Можно не указывать] - subTreeLevel: 1, //Уровень вложенности модификации (Ядро - 1, Мод - 2, Аддон - 3 и т.д...) (будет произведён отступ от левого края для выделения) [Можно не указывать, по умолчанию: 1] - onlyOne: true, //Для выбора только одной из группы модификаций [Можно не указывать] - onlyOneGroup: 1 //Используется в совокупности с onlyOne. Определяет ту самую группу, из которой производится выбор. - },*/ - } -}