From 3d8700d727f5aca1c4f9e5fad3ed8957527c5b64 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Thu, 3 Jan 2019 11:27:08 +0300 Subject: [PATCH 1/6] AsmFix (#118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * AsmFix P1 * ASMFix P2 или как asm 7 тупит. --- .../ru/gravit/launchserver/asm/ClassMetadataReader.java | 9 ++++++--- .../gravit/launchserver/manangers/NodeTransformer.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java index 53cf3e89..c1f07859 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java @@ -23,7 +23,7 @@ private class CheckSuperClassVisitor extends ClassVisitor { String superClassName; public CheckSuperClassVisitor() { - super(Opcodes.ASM5); + super(Opcodes.ASM7); } @Override @@ -57,10 +57,13 @@ public void acceptVisitor(String className, ClassVisitor visitor) throws IOExcep public byte[] getClassData(String className) throws IOException { for (JarFile f : cp) { - if (f.getEntry(className + ".class") != null) + if (f.getEntry(className + ".class") != null) { + byte[] bytes = null; try (InputStream in = f.getInputStream(f.getEntry(className + ".class"))) { - return IOHelper.read(in); + bytes = IOHelper.read(in); } + return bytes; + } } return IOHelper.read(IOHelper.getResourceURL(className + ".class")); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java index 59dbd2b4..f90f0a1d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java @@ -33,7 +33,7 @@ public byte[] transform(byte[] input, String classname, JARLauncherBinary data) ClassNode cn = new ClassNode(); cr.accept(cn, ClassReader.SKIP_DEBUG); for (ClassNodeTransformer tr : transLst) tr.transform(cn, classname, data); - ClassWriter cw = new SafeClassWriter(data.reader, ClassWriter.COMPUTE_FRAMES); + ClassWriter cw = new SafeClassWriter(data.reader, ClassWriter.COMPUTE_MAXS); cn.accept(cw); return cw.toByteArray(); } From f812129d81a67228eff401d151f82caa98391887 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Thu, 3 Jan 2019 12:33:14 +0300 Subject: [PATCH 2/6] Modules upd + Integer -> int. (#117) --- .../ru/gravit/launchserver/socket/ServerSocketHandler.java | 4 ++-- modules | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java index f80075e6..93fb1ce3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java @@ -27,7 +27,7 @@ public interface Listener { void onDisconnect(Exception e); - boolean onHandshake(long session, Integer type); + boolean onHandshake(long session, int type); } private static final ThreadFactory THREAD_FACTORY = r -> CommonHelper.newThread("Network Thread", true, r); @@ -76,7 +76,7 @@ public void close() { listener.onDisconnect(e); } - /*package*/ boolean onHandshake(long session, Integer type) { + /*package*/ boolean onHandshake(long session, int type) { return listener == null || listener.onHandshake(session, type); } diff --git a/modules b/modules index eec958f2..ec143160 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit eec958f2c5edbc7c053686ab7cebaab8dbca2778 +Subproject commit ec1431605c4951ace5cbd2ab392b67cea25bddd5 From bac74a7d4fd5398ab76fc50fbae96c9777b103ea Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:22:59 +0700 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20ServerWrap?= =?UTF-8?q?per?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/server/ServerWrapper.java | 4 +++- modules | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index e42b62a7..8fcdeada 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -87,6 +87,7 @@ public static void main(String[] args) throws Throwable { modulesManager.preInitModules(); LogHelper.debug("Read ServerWrapperConfig.json"); gsonBuiler = new GsonBuilder(); + gsonBuiler.setPrettyPrinting(); gson = gsonBuiler.create(); generateConfigIfNotExists(); try(Reader reader = IOHelper.newReader(configFile)) @@ -99,7 +100,7 @@ public static void main(String[] args) throws Throwable { else CommonHelper.newThread("Server Auth Thread", true, () -> ServerWrapper.loopAuth(wrapper, config.reconnectCount, config.reconnectSleep)); modulesManager.initModules(); - String classname = config.mainclass.isEmpty() ? args[0] : config.mainclass; + String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass; if (classname.length() == 0) { LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.cfg or first commandline argument"); } @@ -152,6 +153,7 @@ private static void generateConfigIfNotExists() throws IOException { newConfig.port = 7240; newConfig.login = "login"; newConfig.password = "password"; + newConfig.mainclass = ""; //try(Reader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launcher/server/ServerWrapper.cfg"))) //{ // newConfig = gson.fromJson(reader,Config.class); diff --git a/modules b/modules index ec143160..eec958f2 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit ec1431605c4951ace5cbd2ab392b67cea25bddd5 +Subproject commit eec958f2c5edbc7c053686ab7cebaab8dbca2778 From baaf2ec74e7f3aa2281cd5519139c23f4e7bf85d Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:26:54 +0700 Subject: [PATCH 4/6] =?UTF-8?q?STACKTRACE=5FPROPERTY=20=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java | 1 + .../src/main/java/ru/gravit/launcher/client/ClientLauncher.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 932dc823..c8b4c21f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -30,6 +30,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep args.add(javaBin.toString()); String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index ed888a74..e61306d3 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -358,6 +358,7 @@ public static Process launch( args.add("-Xmx" + params.ram + 'M'); } args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); if (LauncherConfig.ADDRESS_OVERRIDE != null) args.add(JVMHelper.jvmProperty(LauncherConfig.ADDRESS_OVERRIDE_PROPERTY, LauncherConfig.ADDRESS_OVERRIDE)); if (JVMHelper.OS_TYPE == OS.MUSTDIE) { From e525842d24dd695b1a97db6c8d3e2795ed85d302 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:31:26 +0700 Subject: [PATCH 5/6] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=20debug=20=D0=B4=D0=BB=D1=8F=20stacktrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/LaunchServer.java | 1 - .../launchserver/command/basic/DebugCommand.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 58237d2b..88af9d57 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -374,7 +374,6 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { modulesManager.autoload(dir.resolve("modules")); modulesManager.preInitModules(); initGson(); - LogHelper.setStacktraceEnabled(true); // Read LaunchServer config generateConfigIfNotExists(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java index 19adc8b6..89c6a12a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java @@ -11,22 +11,29 @@ public DebugCommand(LaunchServer server) { @Override public String getArgsDescription() { - return "[true/false]"; + return "[true/false] (true/false)"; } @Override public String getUsageDescription() { - return "Enable or disable debug logging at runtime"; + return "Enable or disable debug and stacktrace logging at runtime"; } @Override public void invoke(String... args) { - boolean newValue; + boolean newValue, newTraceValue; if (args.length >= 1) { newValue = Boolean.parseBoolean(args[0]); + if(args.length >= 2) newTraceValue = Boolean.parseBoolean(args[1]); + else newTraceValue = newValue; LogHelper.setDebugEnabled(newValue); + LogHelper.setStacktraceEnabled(newTraceValue); } else + { newValue = LogHelper.isDebugEnabled(); + newTraceValue = LogHelper.isStacktraceEnabled(); + } LogHelper.subInfo("Debug enabled: " + newValue); + LogHelper.subInfo("Stacktrace enabled: " + newTraceValue); } } From 7ed237c5676f7f1ff0e7fac09600bbaaf08e43f5 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:46:45 +0700 Subject: [PATCH 6/6] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index eec958f2..ec143160 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit eec958f2c5edbc7c053686ab7cebaab8dbca2778 +Subproject commit ec1431605c4951ace5cbd2ab392b67cea25bddd5