From 084b84a6a24cf74c4a819bc6593d711855f91982 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 10:41:10 +0300 Subject: [PATCH 01/70] =?UTF-8?q?[HOTFIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20?= =?UTF-8?q?=D0=B4=D0=B5=D1=81=D0=B5=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D1=85?= =?UTF-8?q?=20byte[].?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/utils/helper/CommonHelper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 9a731b20..7c546ae2 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -13,6 +13,7 @@ import javax.script.ScriptEngineManager; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -144,6 +145,14 @@ private static class ByteArrayToBase64TypeAdapter implements JsonSerializer Date: Tue, 11 Jun 2019 11:41:22 +0300 Subject: [PATCH 02/70] =?UTF-8?q?[FIX]=20=D0=90=D0=B3=D0=B5=D0=BD=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B0=20VM=20=D0=BE=D1=82=D0=BB=D0=B8=D1=87=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BE=D1=82=20HotSpot.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pro/gravit/launcher/LauncherAgent.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java index 0ff8845d..05581b5e 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java @@ -10,6 +10,7 @@ import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.jar.JarFile; import org.objectweb.asm.ClassReader; @@ -54,13 +55,14 @@ public static void premain(String agentArgument, Instrumentation instrumentation if (trimmedArg.contains("r")) rt = false; } } - try { - if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt); - else replaceClasses(false, false); - } catch (Error e) { - NativeJVMHalt.haltA(294); - throw e; - } + if (System.getProperty("java.vm.name").toUpperCase(Locale.US).indexOf("HOTSPOT") != -1) + try { + if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt); + else replaceClasses(false, false); + } catch (Error e) { + NativeJVMHalt.haltA(294); + throw e; + } } public static boolean isStarted() { From af421c3e961060428f5f884b981ff0dcfb0a2bc5 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 11:56:53 +0300 Subject: [PATCH 03/70] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D1=87=D0=B8=D0=BD?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BB=D0=B0=D1=83=D0=BD?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/binary/LauncherBinary.java | 11 ++++++++++- .../pro/gravit/utils/helper/CommonHelper.java | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index c63ffd18..d09db69c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -5,6 +5,7 @@ import pro.gravit.launcher.serialize.signed.DigestBytesHolder; import pro.gravit.launchserver.LaunchServer; +import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -40,9 +41,17 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); + if (sign != null) + CommonHelper.removeExc(sign); + if (binary != null) { + CommonHelper.removeExc(binary.getBytes()); + CommonHelper.removeExc(binary.getDigest()); + } binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; - + CommonHelper.addExc(sign); + CommonHelper.addExc(binary.getBytes()); + CommonHelper.addExc(binary.getDigest()); return exists; } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 7c546ae2..d822dcb7 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -5,6 +5,8 @@ import java.util.Collection; import java.util.LinkedList; import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -140,10 +142,21 @@ public static GsonBuilder newBuilder() { ByteArrayToBase64TypeAdapter.INSTANCE); } + public static void addExc(byte[] exclusion) { + JsonArray add = new JsonArray(exclusion.length); + for (byte b : exclusion) add.add(new JsonPrimitive(b)); + ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); + } + + public static void removeExc(byte[] exclusion) { + ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); + } + private static class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); - private Base64.Decoder decoder = Base64.getUrlDecoder(); - private Base64.Encoder encoder = Base64.getUrlEncoder(); + private static final Map exclusions = new ConcurrentHashMap<>(); + private final Base64.Decoder decoder = Base64.getUrlDecoder(); + private final Base64.Encoder encoder = Base64.getUrlEncoder(); public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonArray()) { JsonArray byteArr = json.getAsJsonArray(); From 408da409df251f9f147728af97d2bb2a537e73e5 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 11:58:21 +0300 Subject: [PATCH 04/70] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20base64=20=D0=B2=20CommonHelper.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/utils/helper/CommonHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index d822dcb7..18e4a1de 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -154,7 +154,7 @@ public static void removeExc(byte[] exclusion) { private static class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); - private static final Map exclusions = new ConcurrentHashMap<>(); + private static final Map exclusions = new ConcurrentHashMap<>(); private final Base64.Decoder decoder = Base64.getUrlDecoder(); private final Base64.Encoder encoder = Base64.getUrlEncoder(); public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { @@ -170,7 +170,7 @@ public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationCon } public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(encoder.encodeToString(src)); + return exclusions.getOrDefault(src, new JsonPrimitive(encoder.encodeToString(src))); } } } From d1132806da1158da73da9bf0c14a71beed124c24 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 12:04:22 +0300 Subject: [PATCH 05/70] =?UTF-8?q?[FIX]=20NPE=20=D0=BF=D1=80=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B5=20LaunchServer`=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/binary/LauncherBinary.java | 11 ++++++----- .../java/pro/gravit/utils/helper/CommonHelper.java | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index d09db69c..238e9de3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -41,8 +41,7 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); - if (sign != null) - CommonHelper.removeExc(sign); + CommonHelper.removeExc(sign); if (binary != null) { CommonHelper.removeExc(binary.getBytes()); CommonHelper.removeExc(binary.getDigest()); @@ -50,9 +49,11 @@ public final boolean sync() throws IOException { binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; CommonHelper.addExc(sign); - CommonHelper.addExc(binary.getBytes()); - CommonHelper.addExc(binary.getDigest()); - return exists; + if (binary != null) { + CommonHelper.addExc(binary.getBytes()); + CommonHelper.addExc(binary.getDigest()); + } + return exists; } public static Path resolve(LaunchServer server, String ext) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 18e4a1de..b0000ead 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -143,12 +143,14 @@ public static GsonBuilder newBuilder() { } public static void addExc(byte[] exclusion) { + if (exclusion == null) return; JsonArray add = new JsonArray(exclusion.length); for (byte b : exclusion) add.add(new JsonPrimitive(b)); ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); } public static void removeExc(byte[] exclusion) { + if (exclusion == null) return; ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); } From 0b6f4e516b8bdbeef0e1261a1d82b4a3f2c05f70 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 12:14:08 +0300 Subject: [PATCH 06/70] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BE=D1=81=D1=82=D1=8B=D0=BB=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/binary/LauncherBinary.java | 14 ++----------- .../pro/gravit/utils/helper/CommonHelper.java | 21 +++---------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index 238e9de3..c63ffd18 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -5,7 +5,6 @@ import pro.gravit.launcher.serialize.signed.DigestBytesHolder; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -41,19 +40,10 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); - CommonHelper.removeExc(sign); - if (binary != null) { - CommonHelper.removeExc(binary.getBytes()); - CommonHelper.removeExc(binary.getDigest()); - } binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; - CommonHelper.addExc(sign); - if (binary != null) { - CommonHelper.addExc(binary.getBytes()); - CommonHelper.addExc(binary.getDigest()); - } - return exists; + + return exists; } public static Path resolve(LaunchServer server, String ext) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index b0000ead..7c546ae2 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -5,8 +5,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -142,23 +140,10 @@ public static GsonBuilder newBuilder() { ByteArrayToBase64TypeAdapter.INSTANCE); } - public static void addExc(byte[] exclusion) { - if (exclusion == null) return; - JsonArray add = new JsonArray(exclusion.length); - for (byte b : exclusion) add.add(new JsonPrimitive(b)); - ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); - } - - public static void removeExc(byte[] exclusion) { - if (exclusion == null) return; - ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); - } - private static class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); - private static final Map exclusions = new ConcurrentHashMap<>(); - private final Base64.Decoder decoder = Base64.getUrlDecoder(); - private final Base64.Encoder encoder = Base64.getUrlEncoder(); + private Base64.Decoder decoder = Base64.getUrlDecoder(); + private Base64.Encoder encoder = Base64.getUrlEncoder(); public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonArray()) { JsonArray byteArr = json.getAsJsonArray(); @@ -172,7 +157,7 @@ public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationCon } public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { - return exclusions.getOrDefault(src, new JsonPrimitive(encoder.encodeToString(src))); + return new JsonPrimitive(encoder.encodeToString(src)); } } } From bbc48ec2393511bafd7f28c32b8fc6c469e7b1bf Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 12:18:25 +0300 Subject: [PATCH 07/70] =?UTF-8?q?[FIX]=20=D0=9C=D0=BE=D0=B4=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=20final=20=D0=B2=D1=81?= =?UTF-8?q?=D1=91=20=D1=80=D0=B0=D0=B2=D0=BD=D0=BE=20=D0=BD=D1=83=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B2=20ByteArrayToBase64TypeAdapter.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/utils/helper/CommonHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 7c546ae2..a7dc68a1 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -142,8 +142,8 @@ public static GsonBuilder newBuilder() { private static class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); - private Base64.Decoder decoder = Base64.getUrlDecoder(); - private Base64.Encoder encoder = Base64.getUrlEncoder(); + private final Base64.Decoder decoder = Base64.getUrlDecoder(); + private final Base64.Encoder encoder = Base64.getUrlEncoder(); public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonArray()) { JsonArray byteArr = json.getAsJsonArray(); From 8e6f1334e298c42a833f34adf3b76fa70c7c3b71 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 14 Jun 2019 13:27:31 +0300 Subject: [PATCH 08/70] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D0=BA=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9=20=D1=81=20vaargs?= =?UTF-8?q?=20=D0=B2=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D1=85=20main=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launcher/client/ClientLauncher.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index c6a6dd38..5674255a 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -148,7 +148,6 @@ public void write(HOutput output) throws IOException { } } - private static final String[] EMPTY_ARRAY = new String[0]; private static final String SOCKET_HOST = "127.0.0.1"; private static final int SOCKET_PORT = Launcher.getConfig().clientPort; private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"; @@ -277,21 +276,22 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl Collection args = new LinkedList<>(); if (profile.getVersion().compareTo(ClientProfile.Version.MC164) >= 0) addClientArgs(args, profile, params); - else + else { addClientLegacyArgs(args, profile, params); + System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString()); + } Collections.addAll(args, profile.getClientArgs()); LogHelper.debug("Args: " + args); // Resolve main class and method Class mainClass = classLoader.loadClass(profile.getMainClass()); - MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); - // Invoke main method with exception wrapping + MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity(); Launcher.LAUNCHED.set(true); JVMHelper.fullGC(); - System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString()); // For 1.5.2 - mainMethod.invoke((Object) args.toArray(EMPTY_ARRAY)); + // Invoke main method + mainMethod.invoke((Object) args.toArray(new String[0])); } - private static Process process = null; + private static Process process = null; private static boolean clientStarted = false; private static Thread writeParamsThread; From 80925b6366cf3f6b9144a7d16ca996bf9044a360 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 14 Jun 2019 15:57:26 +0300 Subject: [PATCH 09/70] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D0=BF=D1=8B=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=84=D0=B8=D0=BA=D1=81=D0=B0=20gitlab=20CI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b6ba3cc..511511e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: java:8-jdk +image: azul/zulu-openjdk:8 stages: - build From 068e2c6d64c8ceff8b51b394a7f6b1874bf8ef74 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sun, 16 Jun 2019 16:08:14 +0300 Subject: [PATCH 10/70] =?UTF-8?q?[FIX][EXP]=20=D0=A4=D0=B8=D0=BA=D1=81=20?= =?UTF-8?q?=D0=B2=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=84=D0=B0=D0=B9=D0=BB=D1=81=D0=B5=D1=80=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/websocket/fileserver/FileServerHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java index 8c2d713d..a3b761f6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java @@ -55,6 +55,7 @@ public class FileServerHandler extends SimpleChannelInboundHandler Date: Mon, 17 Jun 2019 11:40:16 +0300 Subject: [PATCH 11/70] =?UTF-8?q?[FIX][EXP]=20=D0=A4=D0=B8=D0=BA=D1=81=20p?= =?UTF-8?q?rev=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/websocket/fileserver/FileServerHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java index a3b761f6..3a3af245 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java @@ -55,7 +55,7 @@ public class FileServerHandler extends SimpleChannelInboundHandler Date: Mon, 17 Jun 2019 13:07:37 +0300 Subject: [PATCH 12/70] =?UTF-8?q?[FIX]=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20permissions=20=D0=B2=20runtime=20(#286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/scenes/options/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Launcher/runtime/dialog/scenes/options/options.js b/Launcher/runtime/dialog/scenes/options/options.js index 88fa0b9c..b235e862 100644 --- a/Launcher/runtime/dialog/scenes/options/options.js +++ b/Launcher/runtime/dialog/scenes/options/options.js @@ -100,7 +100,7 @@ var options = { return; } - if(modFile.permissions != 0 && ((loginData.permissions.toLong() & modFile.permissions) != 0)) + if(modFile.permissions != 0 && ((loginData.permissions.toLong() & modFile.permissions) = 0)) { LogHelper.debug("optionalMod %s permissions deny",modFile.name); return; From 52319393026be5233350467be4df7290af0c2927 Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Mon, 17 Jun 2019 14:00:06 +0300 Subject: [PATCH 13/70] =?UTF-8?q?[FIX]=20prev=20commit(=D0=B7=D0=B0=D0=B1?= =?UTF-8?q?=D1=8B=D0=BB=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B5=D1=89=D1=91=20=D0=BE=D0=B4=D0=BD=D0=BE=20=3D)=20(#287?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/scenes/options/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Launcher/runtime/dialog/scenes/options/options.js b/Launcher/runtime/dialog/scenes/options/options.js index b235e862..112c8c9c 100644 --- a/Launcher/runtime/dialog/scenes/options/options.js +++ b/Launcher/runtime/dialog/scenes/options/options.js @@ -100,7 +100,7 @@ var options = { return; } - if(modFile.permissions != 0 && ((loginData.permissions.toLong() & modFile.permissions) = 0)) + if(modFile.permissions != 0 && ((loginData.permissions.toLong() & modFile.permissions) == 0)) { LogHelper.debug("optionalMod %s permissions deny",modFile.name); return; From 0048b00658aa9ea5dc75196a834ea223ed4224ac Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 15:48:00 +0300 Subject: [PATCH 14/70] =?UTF-8?q?[FIX]=D0=92=D1=82=D0=BE=D1=80=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- .travis.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 511511e3..c9a2bf26 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: azul/zulu-openjdk:8 +image: frekele/java stages: - build diff --git a/.travis.yml b/.travis.yml index 9ce4fe87..e73f2373 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: java +jdk: + - oraclejdk8 # Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior! # disable the default submodule logic git: From 2f345f78a80f917d76c2a87afed0e39190218bf8 Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 16:07:38 +0300 Subject: [PATCH 15/70] =?UTF-8?q?[FIX]=20=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D0=BE=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20travis=20ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e73f2373..b195f4ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: java -jdk: - - oraclejdk8 +dist: trusty # Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior! # disable the default submodule logic git: From d2b7a114562363cdd4ffb4594b94f61648ab2f8a Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 18:07:44 +0300 Subject: [PATCH 16/70] =?UTF-8?q?[FIX]=20=D0=A1=D0=BD=D0=BE=D0=B2=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=B8=20=D1=81=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0...=20=D1=84=D0=B8=D0=BA=D1=81=20gitlab=20ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9a2bf26..c35bcdfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ before_script: # - echo `pwd` # debug # - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug - export GRADLE_USER_HOME=`pwd`/.gradle + - apt-get update -qq && apt-get install -y -qq git git-core cache: paths: From ae51eb3b6ca4ab0d9a2889829ae39e854c5b13a6 Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 19:02:37 +0300 Subject: [PATCH 17/70] =?UTF-8?q?[FIX]=20=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BD=D1=83=D0=B6=D0=BD=D1=8B=D0=B9=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=20=D0=B2=20gitlab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c35bcdfb..885fad99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,6 @@ image: frekele/java stages: - build - - test - deploy before_script: @@ -29,10 +28,5 @@ build: - ServerWrapper/build/libs/*.jar expire_in: 1 week -test: - stage: test - script: - - ./gradlew check - after_script: - echo "End CI" From 3201be72cc887b3e0ebdbdf055456f9b09416e0c Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 17:40:49 +0300 Subject: [PATCH 18/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20clear=20=D0=B2=20std?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 3 +++ .../utils/command/StdCommandHandler.java | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index acd7ba4b..1fda230e 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -136,6 +136,9 @@ function initConsoleScene() { var appendFunction = function(line) javafx.application.Platform.runLater(function() output.appendText(line)); consoleMenu.lookup("#send").setOnAction(function(){ execCommand(text.getText()); + if (text.getText() == "clear") { + output.setText(""); + } text.setText(""); }); FunctionalBridge.addPlainOutput(function(string) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java index c744be50..3d817c7b 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java @@ -2,7 +2,7 @@ import java.io.BufferedReader; import java.io.IOException; - +import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.IOHelper; public class StdCommandHandler extends CommandHandler { @@ -18,8 +18,21 @@ public void bell() { } @Override - public void clear() { - throw new UnsupportedOperationException("clear terminal"); + public void clear() throws IOException { + System.out.flush(); + if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) + { + try { + new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); + } catch (InterruptedException ex) { + throw new IOException(ex); + } + } + else + { + System.out.print("\033[H\033[2J"); + System.out.flush(); + } } @Override From bf28c66e2bfe13edccce9b7740138662dc3054bf Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 20:28:54 +0300 Subject: [PATCH 19/70] =?UTF-8?q?[FEUTURE]=20=D0=A3=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20jfoenix=20=D0=B8=D0=B7=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B5?= =?UTF-8?q?=D0=B9,=20=D0=B8=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D1=85=20=D0=B5=D0=B3=D0=BE=20=D1=84=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D0=B9=20=D0=BD=D0=B0=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/build.gradle | 1 - Launcher/runtime/dialog/dialog.js | 2 +- .../runtime/dialog/overlay/debug/debug.fxml | 12 +++--- .../dialog/overlay/processing/processing.fxml | 4 +- .../dialog/overlay/settings/settings.fxml | 26 ++++++------- .../runtime/dialog/overlay/update/update.fxml | 4 +- .../dialog/scenes/console/console.fxml | 28 +++++++------- .../runtime/dialog/scenes/login/login.fxml | 37 +++++++++---------- .../dialog/scenes/mainmenu/mainmenu.fxml | 36 +++++++++--------- .../dialog/scenes/options/options.fxml | 14 +++---- .../runtime/dialog/scenes/options/options.js | 4 +- 11 files changed, 83 insertions(+), 85 deletions(-) diff --git a/Launcher/build.gradle b/Launcher/build.gradle index 6e1553e9..1cd76ea4 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -39,7 +39,6 @@ dependencies { pack project(':LauncherAuthlib') bundle 'com.github.oshi:oshi-core:3.13.0' - bundle 'com.jfoenix:jfoenix:8.0.8' bundle 'de.jensd:fontawesomefx:8.9' bundle 'org.apache.httpcomponents:httpclient:4.5.7' pack 'io.netty:netty-codec-http:4.1.36.Final' diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index acd7ba4b..f1e11f91 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -255,7 +255,7 @@ function verifyLauncher(e) { var iter = 0; authTypes = {}; result.list.forEach(function(auth_type, i, arr) { - var serverAuth = new com.jfoenix.controls.JFXComboBox(); + var serverAuth = new javafx.scene.control.ComboBox(); serverAuth.getStyleClass().add("authOptions"); authOptions.getItems().add(auth_type.displayName); authTypes[auth_type.displayName] = auth_type.name; diff --git a/Launcher/runtime/dialog/overlay/debug/debug.fxml b/Launcher/runtime/dialog/overlay/debug/debug.fxml index 89efbb21..9666c28e 100644 --- a/Launcher/runtime/dialog/overlay/debug/debug.fxml +++ b/Launcher/runtime/dialog/overlay/debug/debug.fxml @@ -1,7 +1,7 @@ - - + + @@ -16,12 +16,12 @@ - + + - + + - - + + + + diff --git a/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml b/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml index 70e6b20c..c5dd660f 100644 --- a/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml +++ b/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml @@ -1,6 +1,6 @@ - + @@ -22,10 +22,10 @@ - + @@ -46,15 +46,15 @@ - + + - + + + + + diff --git a/Launcher/runtime/dialog/scenes/options/options.fxml b/Launcher/runtime/dialog/scenes/options/options.fxml index a0bb1ef0..4884c670 100644 --- a/Launcher/runtime/dialog/scenes/options/options.fxml +++ b/Launcher/runtime/dialog/scenes/options/options.fxml @@ -1,6 +1,6 @@ - + @@ -38,21 +38,21 @@ - + + + diff --git a/Launcher/runtime/dialog/scenes/options/options.js b/Launcher/runtime/dialog/scenes/options/options.js index 112c8c9c..98c28232 100644 --- a/Launcher/runtime/dialog/scenes/options/options.js +++ b/Launcher/runtime/dialog/scenes/options/options.js @@ -83,7 +83,7 @@ var options = { var nodelist = new java.util.ArrayList; modlist.getChildren().forEach(function(node,i,arr) { - if(node instanceof com.jfoenix.controls.JFXCheckBox) + if(node instanceof javafx.scene.control.CheckBox) nodelist.add(node); }); nodelist.forEach(function(node,i,arr) { @@ -109,7 +109,7 @@ var options = { modDescription = modFile.info; if(modFile.subTreeLevel != null && modFile.subTreeLevel > 1) subLevel = modFile.subTreeLevel; - var testMod = new com.jfoenix.controls.JFXCheckBox(modName); + var testMod = new javafx.scene.control.CheckBox(modName); testMod.getStyleClass().add("checkboxOpt"); if(subLevel > 1) From 8b0a53032470313c088590cd2609ad79aed87dc4 Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 21:00:56 +0300 Subject: [PATCH 20/70] =?UTF-8?q?[FIX]=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB?= =?UTF-8?q?=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D1=87=D0=BA=D0=B0=D0=BC=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B7=D1=80=D0=B0=D1=87=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/styles.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Launcher/runtime/dialog/styles.css b/Launcher/runtime/dialog/styles.css index d26cc8e4..7fe88772 100644 --- a/Launcher/runtime/dialog/styles.css +++ b/Launcher/runtime/dialog/styles.css @@ -2,7 +2,11 @@ Button, CheckBox, ComboBox, RadioButton { -fx-cursor: hand; } - +Button { + -fx-background-color: TRANSPARENT, TRANSPARENT, TRANSPARENT, TRANSPARENT; + -fx-background-radius: 3px; + -fx-background-insets: 0px; +} /* Backgrounds */ #layout { From 2828a6df64a96fb6845ca3bbafb4fac992745539 Mon Sep 17 00:00:00 2001 From: Alex Dev Sm Date: Tue, 18 Jun 2019 21:37:34 +0300 Subject: [PATCH 21/70] =?UTF-8?q?[FIX]=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB?= =?UTF-8?q?=20=D0=B3=D0=B0=D0=BB=D0=BE=D1=87=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/styles.css | 66 ++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/Launcher/runtime/dialog/styles.css b/Launcher/runtime/dialog/styles.css index 7fe88772..b2b2f356 100644 --- a/Launcher/runtime/dialog/styles.css +++ b/Launcher/runtime/dialog/styles.css @@ -1,13 +1,66 @@ -/*-- DrLeonardo Design --*/ -Button, CheckBox, ComboBox, RadioButton { - -fx-cursor: hand; -} +/*-- Without jfoenix --*/ Button { -fx-background-color: TRANSPARENT, TRANSPARENT, TRANSPARENT, TRANSPARENT; -fx-background-radius: 3px; -fx-background-insets: 0px; } +CheckBox .box-container { + -fx-shape: "M 400 100 L 400 100 A 50 50 0 1 1 400 250 A 50 50 0 1 1 400 100 "; + -fx-padding: 10; +} + +CheckBox .box, +CheckBox:indeterminate .box, +CheckBox:indeterminate:selected .box{ + -fx-pref-width: 18; + -fx-pref-height: 18; + + -fx-background-color: TRANSPARENT; + -fx-background-radius: 2; + + -fx-border-color: #909090; + -fx-border-style: solid; + -fx-border-radius: 2; + -fx-border-width: 2; +} + +CheckBox:selected .box { + -fx-border-color: #5fd97a; + -fx-background-color: #5fd97a; +} + +CheckBox .mark { + -fx-background-color: TRANSPARENT; +} + +CheckBox:selected .mark { + -fx-shape: "M384 690l452-452 60 60-512 512-238-238 60-60z"; + -fx-max-width: 15; + -fx-max-height: 12; + + -fx-background-color: WHITE; + + -fx-border-color: WHITE; + -fx-border-width: 2; + -fx-border-radius: 2; +} + +CheckBox .indeterminate-mark{ + -fx-background-color: #5fd97a; + -fx-background-radius: 2; + -fx-border-width: 0; + -fx-max-width: 10; + -fx-max-height: 10; +} + + +/*-- DrLeonardo Design --*/ +Button, CheckBox, ComboBox, RadioButton { + -fx-cursor: hand; +} + + /* Backgrounds */ #layout { -fx-background-color: transparent; @@ -317,11 +370,6 @@ .description-text { -fx-font-size: 12px; } -.checkboxOpt { - -jfx-checked-color: #5fd97a; - -jfx-unchecked-color: #909090; -} - .modname { -fx-text-fill: #323232; } From 6e1750d25c456ad67a96e877367507f87df3760e Mon Sep 17 00:00:00 2001 From: Egor Koleda Date: Thu, 20 Jun 2019 00:55:18 +0300 Subject: [PATCH 22/70] fix RequestAuthProvider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Рекомендую посадить на кол автора этого шедевра! --- .../gravit/launchserver/auth/provider/RequestAuthProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RequestAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RequestAuthProvider.java index 97211b83..723d3a26 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RequestAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RequestAuthProvider.java @@ -33,7 +33,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws // Match username Matcher matcher = pattern.matcher(currentResponse); return matcher.matches() && matcher.groupCount() >= 1 ? - new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : srv.config.permissionsHandler.getPermissions(login)) : + new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.parseLong(matcher.group("permission"))) : srv.config.permissionsHandler.getPermissions(login)) : authError(currentResponse); } From 155e3ff3670c5c3823d91176a96a00605759ddcd Mon Sep 17 00:00:00 2001 From: Egor Koleda Date: Wed, 26 Jun 2019 17:57:17 +0300 Subject: [PATCH 23/70] fix bad security check --- .../websocket/fileserver/FileServerHandler.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java index 3a3af245..290b745d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java @@ -17,6 +17,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -189,15 +190,7 @@ private static String sanitizeUri(String uri) { // Convert file separators. uri = uri.replace(File.separatorChar, '/'); - // Simplistic dumb security check. - // You will have to do something serious in the production environment. - if (uri.contains(File.separator + '.') || - uri.contains('.' + File.separator) || - uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' || - INSECURE_URI.matcher(uri).matches()) { - return null; - } - return uri.substring(1); + return Paths.get(uri).normalize().toString().substring(1); } private static final Pattern ALLOWED_FILE_NAME = Pattern.compile("[^-\\._]?[^<>&\\\"]*"); From 2a56594534524fbde6adbd830b64c2e0069c69a5 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 14:23:12 +0700 Subject: [PATCH 24/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=BB=D0=B2=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=20=D0=B2?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=BD=D1=8B=D0=BC=20ProGua?= =?UTF-8?q?rd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launcher/events/request/AuthRequestEvent.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java index 6bf07b01..7665c4f2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java @@ -14,8 +14,6 @@ public class AuthRequestEvent extends RequestEvent implements EventInterface { public AuthRequestEvent() { } - @LauncherNetworkAPI - public String error; @LauncherNetworkAPI public ClientPermissions permissions; @LauncherNetworkAPI @@ -40,8 +38,7 @@ public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfi this.protectToken = protectToken; } - public AuthRequestEvent(String error, ClientPermissions permissions, PlayerProfile playerProfile, String accessToken, String protectToken, long session) { - this.error = error; + public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfile, String accessToken, String protectToken, long session) { this.permissions = permissions; this.playerProfile = playerProfile; this.accessToken = accessToken; From ae34a06a5f3aecba933fb0ce8f683359cef81367 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 14:36:58 +0700 Subject: [PATCH 25/70] [FIX] IDEA Code Inspect --- .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 6 ------ .../pro/gravit/launchserver/asm/ClassMetadataReader.java | 2 +- .../launchserver/binary/tasks/AdditionalFixesApplyTask.java | 2 +- .../launchserver/command/dump/DumpEntryCacheCommand.java | 4 ++-- .../launchserver/command/dump/DumpSessionsCommand.java | 2 +- .../pro/gravit/launchserver/websocket/WebSocketService.java | 1 - .../websocket/fileserver/FileServerHandler.java | 1 - .../src/main/java/pro/gravit/launcher/LauncherAgent.java | 4 ++-- .../gravit/launcher/request/websockets/ClientJSONPoint.java | 2 +- .../request/websockets/StandartClientWebSocketService.java | 3 +-- .../main/java/pro/gravit/launcher/server/ServerAgent.java | 2 +- .../gravit/launcher/server/setup/ServerWrapperSetup.java | 2 +- 12 files changed, 11 insertions(+), 20 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 1dc4f34c..67cedd26 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -954,9 +954,6 @@ public void registerObject(String name, Object object) { if (object instanceof NeedGarbageCollection) { GarbageManager.registerNeedGC((NeedGarbageCollection) object); } - if (object instanceof JsonConfigurable) { - - } } public void unregisterObject(String name, Object object) { @@ -969,9 +966,6 @@ public void unregisterObject(String name, Object object) { if (object instanceof NeedGarbageCollection) { GarbageManager.unregisterNeedGC((NeedGarbageCollection) object); } - if (object instanceof JsonConfigurable) { - - } } public void fullyRestart() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java index d6865874..d347dea7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java @@ -59,7 +59,7 @@ 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) { - byte[] bytes = null; + byte[] bytes; try (InputStream in = f.getInputStream(f.getEntry(className + ".class"))) { bytes = IOHelper.read(in); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java index 0ad88cbd..bae3a847 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java @@ -68,7 +68,7 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L String filename = e.getName(); output.putNextEntry(IOHelper.newZipEntry(e)); if (filename.endsWith(".class")) { - byte[] bytes = null; + byte[] bytes; try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { IOHelper.transfer(input, outputStream); bytes = outputStream.toByteArray(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java index bd133cb7..4fe70d76 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java @@ -50,8 +50,8 @@ public void invoke(String... args) throws Exception { LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size()); } else if (args[0].equals("load")) { LogHelper.info("CachedAuthHandler read from %s", args[1]); - int size_entry = 0; - int size_username = 0; + int size_entry; + int size_username; try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) { EntryAndUsername entryAndUsername = Launcher.gsonManager.configGson.fromJson(reader, EntryAndUsername.class); size_entry = entryAndUsername.entryCache.size(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java index 17c816a2..234b72d2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java @@ -43,7 +43,7 @@ public void invoke(String... args) throws Exception { LogHelper.subInfo("Write %d sessions", clientSet.size()); } else if (args[0].equals("load")) { LogHelper.info("Sessions read from %s", args[1]); - int size = 0; + int size; try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) { Type setType = new TypeToken>() { }.getType(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java index 4ff1fe56..034c4732 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java @@ -69,7 +69,6 @@ public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder private final Gson gson; private final GsonBuilder gsonBuiler; - @SuppressWarnings("unchecked") void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) { String request = frame.text(); JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java index 290b745d..a058581a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java @@ -46,7 +46,6 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpUtil; import io.netty.handler.codec.http.LastHttpContent; -import io.netty.handler.ssl.SslHandler; import io.netty.handler.stream.ChunkedFile; import io.netty.util.CharsetUtil; diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java index 05581b5e..4a4329a1 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherAgent.java @@ -55,7 +55,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation if (trimmedArg.contains("r")) rt = false; } } - if (System.getProperty("java.vm.name").toUpperCase(Locale.US).indexOf("HOTSPOT") != -1) + if (System.getProperty("java.vm.name").toUpperCase(Locale.US).contains("HOTSPOT")) try { if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt); else replaceClasses(false, false); @@ -170,7 +170,7 @@ private static byte[] transformClass(String className, byte[] classBytes) { private static byte[] getClassFile(Class clazz) throws IOException { try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class"); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - int r = 0; + int r; byte[] buffer = new byte[8192]; while ((r = is.read(buffer)) >= 0) { baos.write(buffer, 0, r); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java index db4506b1..7451afa8 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -33,7 +33,7 @@ public abstract class ClientJSONPoint { protected WebSocketClientHandler webSocketClientHandler; protected Bootstrap bootstrap = new Bootstrap(); protected boolean ssl = false; - protected int port = -1; + protected int port; public boolean isClosed; public ClientJSONPoint(final String uri) throws SSLException { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java index aa34cd00..e2866a07 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -111,8 +111,7 @@ public static StandartClientWebSocketService initWebSockets(String address, bool try { service = new StandartClientWebSocketService(CommonHelper.newBuilder(), address, 5000); } catch (SSLException e) { - LogHelper.error(e); - return null; + throw new SecurityException(e); } service.registerResults(); service.registerRequests(); diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java index 449b1f71..40113014 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java @@ -63,7 +63,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation proxyClass = Class.forName(proxyClassName); MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(proxyClass, "premain", MethodType.methodType(void.class, String.class, Instrumentation.class)); Object[] args = {agentArgument, instrumentation}; - mainMethod.invoke(args); + mainMethod.invoke(null, args); } catch (Throwable e) { LogHelper.error(e); } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/setup/ServerWrapperSetup.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/setup/ServerWrapperSetup.java index ed2b5c8d..ad6c0174 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/setup/ServerWrapperSetup.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/setup/ServerWrapperSetup.java @@ -23,7 +23,7 @@ public void run() throws IOException { System.out.println("Print jar filename:"); String jarName = commands.commandHandler.readLine(); Path jarPath = Paths.get(jarName); - String mainClassName = null; + String mainClassName; try (JarFile file = new JarFile(jarPath.toFile())) { URL jarURL = jarPath.toUri().toURL(); urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL}); From 992247931498789ead0a0fe21b08164d4f23f7fa Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 14:50:22 +0700 Subject: [PATCH 26/70] =?UTF-8?q?[FEATURE]=20=D0=9E=D0=B1=D0=BD=D0=B0?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20HTTP=20Error=20Cod?= =?UTF-8?q?e,=20=D1=87=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=87=D0=BA=D0=B0=20ZIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/LauncherUpdateController.java | 2 +- .../launcher/downloader/ListDownloader.java | 19 ++++++++++++++++--- .../events/request/UpdateRequestEvent.java | 2 ++ .../request/update/UpdateRequest.java | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/LauncherUpdateController.java b/Launcher/src/main/java/pro/gravit/launcher/client/LauncherUpdateController.java index 8bba2200..3e5333a4 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/LauncherUpdateController.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/LauncherUpdateController.java @@ -33,7 +33,7 @@ public void preDiff(UpdateRequest request, UpdateRequestEvent e) { @Override public void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff diff) throws IOException { - if (e.zip) return; + if (e.zip && e.fullDownload) return; if (SettingsManager.settings.featureStore) { LogHelper.info("Enabled HStore feature. Find"); AtomicReference lastEn = new AtomicReference<>(null); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java index cf836ff9..5f795bc7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java @@ -64,7 +64,7 @@ public void download(String base, List applies, Path dstDirFile, D } } - public void downloadZip(String base, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException, URISyntaxException { + public void downloadZip(String base, List applies, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback, boolean fullDownload) throws IOException, URISyntaxException { /*try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { @@ -81,8 +81,11 @@ public void downloadZip(String base, Path dstDirFile, DownloadCallback callback, // Unpack entry String name = entry.getName(); LogHelper.subInfo("Downloading file: '%s'", name); - Path fileName = IOHelper.toPath(name); - transfer(input, dstDirFile.resolve(fileName), fileName.toString(), entry.getSize(), callback, totalCallback); + if(fullDownload || applies.stream().anyMatch((t) -> t.apply.equals(name))) + { + Path fileName = IOHelper.toPath(name); + transfer(input, dstDirFile.resolve(fileName), fileName.toString(), entry.getSize(), callback, totalCallback); + } } } } @@ -134,6 +137,16 @@ public FileDownloadResponseHandler(Path target, DownloadCallback callback, Downl @Override public Path handleResponse(HttpResponse response) throws IOException { InputStream source = response.getEntity().getContent(); + int returnCode = response.getStatusLine().getStatusCode(); + if(returnCode != 200) + { + throw new IllegalStateException(String.format("Request download file %s return code %d", target.toString(), returnCode)); + } + long contentLength = response.getEntity().getContentLength(); + if (task != null && contentLength != task.size) + { + LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength); + } if (zip) { try (ZipInputStream input = IOHelper.newZipInput(source)) { ZipEntry entry = input.getNextEntry(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java index 06663771..5f997795 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java @@ -11,6 +11,8 @@ public class UpdateRequestEvent extends RequestEvent { public String url; @LauncherNetworkAPI public boolean zip; + @LauncherNetworkAPI + public boolean fullDownload; @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java index 8d77f7cf..bc372234 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java @@ -219,7 +219,7 @@ public UpdateRequestEvent requestDo(StandartClientWebSocketService service) thro ListDownloader listDownloader = new ListDownloader(); LogHelper.info("Download %s to %s", dirName, dir.toAbsolutePath().toString()); if (e.zip && !adds.isEmpty()) { - listDownloader.downloadZip(e.url, dir, this::updateState, (add) -> totalDownloaded += add); + listDownloader.downloadZip(e.url, adds, dir, this::updateState, (add) -> totalDownloaded += add, e.fullDownload); } else { listDownloader.download(e.url, adds, dir, this::updateState, (add) -> totalDownloaded += add); } From 94b2fb1424e97154416d4373a22653b10fa86674 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 15:01:18 +0700 Subject: [PATCH 27/70] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D1=81=D1=84=D0=B5=D1=80=D0=B0=20=D0=B0=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launcher/server/ServerAgent.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java index 40113014..8534bcdc 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java @@ -62,8 +62,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation try { proxyClass = Class.forName(proxyClassName); MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(proxyClass, "premain", MethodType.methodType(void.class, String.class, Instrumentation.class)); - Object[] args = {agentArgument, instrumentation}; - mainMethod.invoke(null, args); + mainMethod.invoke(agentArgument, instrumentation); } catch (Throwable e) { LogHelper.error(e); } From 96c2aac84957f1e0ee299eb8fe11918d1c49a47a Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 15:59:42 +0700 Subject: [PATCH 28/70] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=20=D1=81=D1=82=D0=B0=D1=80=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BF=D1=80=D0=BE=D1=82=D0=BE=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20Sashok?= =?UTF-8?q?Support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 29 ---- .../command/basic/LogConnectionsCommand.java | 32 ---- .../command/basic/RebindCommand.java | 25 --- .../command/handler/CommandHandler.java | 4 - .../launchserver/legacy/PingResponse.java | 20 --- .../gravit/launchserver/legacy/Response.java | 88 ----------- .../legacy/update/LauncherResponse.java | 40 ----- .../legacy/update/LegacyLauncherResponse.java | 38 ----- .../manangers/hook/SocketHookManager.java | 86 ----------- .../launchserver/socket/ResponseThread.java | 144 ------------------ .../socket/ServerSocketHandler.java | 125 --------------- .../launchserver/socket/SocketContext.java | 13 -- .../websocket/NettyServerSocketHandler.java | 57 +------ modules | 2 +- 14 files changed, 2 insertions(+), 701 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/LogConnectionsCommand.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/RebindCommand.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/legacy/PingResponse.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/legacy/Response.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LauncherResponse.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LegacyLauncherResponse.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/SocketHookManager.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/ResponseThread.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/ServerSocketHandler.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketContext.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 67cedd26..8fe8b9b6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -7,8 +7,6 @@ import java.io.Writer; import java.lang.ProcessBuilder.Redirect; import java.lang.reflect.InvocationTargetException; -import java.net.InetSocketAddress; -import java.net.SocketAddress; import java.nio.file.DirectoryStream; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -38,7 +36,6 @@ import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherConfig; import pro.gravit.launcher.NeedGarbageCollection; -import pro.gravit.launcher.config.JsonConfigurable; import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.managers.ConfigManager; import pro.gravit.launcher.managers.GarbageManager; @@ -67,7 +64,6 @@ import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.config.LaunchServerRuntimeConfig; import pro.gravit.launchserver.dao.UserService; -import pro.gravit.launchserver.legacy.Response; import pro.gravit.launchserver.manangers.LaunchServerGsonManager; import pro.gravit.launchserver.manangers.MirrorManager; import pro.gravit.launchserver.manangers.ModulesManager; @@ -76,8 +72,6 @@ import pro.gravit.launchserver.manangers.SessionManager; import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.launchserver.manangers.hook.BuildHookManager; -import pro.gravit.launchserver.manangers.hook.SocketHookManager; -import pro.gravit.launchserver.socket.ServerSocketHandler; import pro.gravit.launchserver.websocket.NettyServerSocketHandler; import pro.gravit.utils.Version; import pro.gravit.utils.command.CommandHandler; @@ -197,11 +191,6 @@ public void setEnv(LauncherConfig.LauncherEnvironment env) { } - public SocketAddress getSocketAddress() { - return new InetSocketAddress(legacyBindAddress, legacyPort); - } - - public void setLegacyAddress(String legacyAddress) { this.legacyAddress = legacyAddress; } @@ -452,8 +441,6 @@ public static void main(String... args) throws Throwable { public final SessionManager sessionManager; - public final SocketHookManager socketHookManager; - public final AuthHookManager authHookManager; // Server @@ -477,8 +464,6 @@ public static void main(String... args) throws Throwable { public final CommandHandler commandHandler; - public final ServerSocketHandler serverSocketHandler; - public final NettyServerSocketHandler nettyServerSocketHandler; private final AtomicBoolean started = new AtomicBoolean(false); @@ -511,7 +496,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException TextureProvider.registerProviders(); HWIDHandler.registerHandlers(); PermissionsHandler.registerHandlers(); - Response.registerResponses(); Component.registerComponents(); ProtectHandler.registerHandlers(); //LaunchServer.server = this; @@ -611,7 +595,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException mirrorManager = new MirrorManager(); reloadManager = new ReloadManager(); reconfigurableManager = new ReconfigurableManager(); - socketHookManager = new SocketHookManager(); authHookManager = new AuthHookManager(); configManager = new ConfigManager(); userService = new UserService(this); @@ -657,10 +640,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException Files.createDirectory(profilesDir); syncProfilesDir(); - - // Set server socket thread - serverSocketHandler = new ServerSocketHandler(this, sessionManager); - // post init modules modulesManager.postInitModules(); if (config.components != null) { @@ -708,7 +687,6 @@ public void buildLauncherBinaries() throws IOException { } public void close() { - serverSocketHandler.close(); // Close handlers & providers config.close(); @@ -841,12 +819,6 @@ public Set>> getUpdateDirs() { return updatesDirMap.entrySet(); } - - public void rebindServerSocket() { - serverSocketHandler.close(); - CommonHelper.newThread("Server Socket Thread", false, serverSocketHandler).start(); - } - public void rebindNettyServerSocket() { nettyServerSocketHandler.close(); CommonHelper.newThread("Netty Server Socket Thread", false, nettyServerSocketHandler).start(); @@ -862,7 +834,6 @@ public void run() { JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close)); CommonHelper.newThread("Command Thread", true, commandHandler).start(); } - rebindServerSocket(); if (config.netty != null) rebindNettyServerSocket(); modulesManager.finishModules(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/LogConnectionsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/LogConnectionsCommand.java deleted file mode 100644 index 8e9b2505..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/LogConnectionsCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -package pro.gravit.launchserver.command.basic; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.LogHelper; - -public final class LogConnectionsCommand extends Command { - public LogConnectionsCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return "[true/false]"; - } - - @Override - public String getUsageDescription() { - return "Enable or disable logging connections"; - } - - @Override - public void invoke(String... args) { - boolean newValue; - if (args.length >= 1) { - newValue = Boolean.parseBoolean(args[0]); - server.serverSocketHandler.logConnections = newValue; - } else - newValue = server.serverSocketHandler.logConnections; - LogHelper.subInfo("Log connections: " + newValue); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/RebindCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/RebindCommand.java deleted file mode 100644 index 6d48ef08..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/RebindCommand.java +++ /dev/null @@ -1,25 +0,0 @@ -package pro.gravit.launchserver.command.basic; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; - -public final class RebindCommand extends Command { - public RebindCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return null; - } - - @Override - public String getUsageDescription() { - return "Rebind server socket"; - } - - @Override - public void invoke(String... args) { - server.rebindServerSocket(); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 89a03b32..88171bca 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -8,9 +8,7 @@ import pro.gravit.launchserver.command.auth.UnbanCommand; import pro.gravit.launchserver.command.auth.UsernameToUUIDCommand; import pro.gravit.launchserver.command.basic.BuildCommand; -import pro.gravit.launchserver.command.basic.LogConnectionsCommand; import pro.gravit.launchserver.command.basic.ProguardCleanCommand; -import pro.gravit.launchserver.command.basic.RebindCommand; import pro.gravit.launchserver.command.basic.RegenProguardDictCommand; import pro.gravit.launchserver.command.basic.RemoveMappingsProguardCommand; import pro.gravit.launchserver.command.basic.RestartCommand; @@ -60,14 +58,12 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand basic.registerCommand("build", new BuildCommand(server)); basic.registerCommand("stop", new StopCommand(server)); basic.registerCommand("restart", new RestartCommand(server)); - basic.registerCommand("rebind", new RebindCommand(server)); basic.registerCommand("debug", new DebugCommand()); basic.registerCommand("clear", new ClearCommand(handler)); basic.registerCommand("gc", new GCCommand()); basic.registerCommand("proguardClean", new ProguardCleanCommand(server)); basic.registerCommand("proguardDictRegen", new RegenProguardDictCommand(server)); basic.registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server)); - basic.registerCommand("logConnections", new LogConnectionsCommand(server)); basic.registerCommand("loadModule", new LoadModuleCommand(server)); basic.registerCommand("modules", new ModulesCommand(server)); basic.registerCommand("test", new TestCommand(server)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/PingResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/PingResponse.java deleted file mode 100644 index 87cc73ac..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/PingResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package pro.gravit.launchserver.legacy; - -import java.io.IOException; - -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; -import pro.gravit.launcher.serialize.SerializeLimits; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.socket.Client; - -public final class PingResponse extends Response { - public PingResponse(LaunchServer server, long id, HInput input, HOutput output, String ip, Client clientData) { - super(server, id, input, output, ip, clientData); - } - - @Override - public void reply() throws IOException { - output.writeUnsignedByte(SerializeLimits.EXPECTED_BYTE); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/Response.java b/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/Response.java deleted file mode 100644 index 6a7e0aa6..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/Response.java +++ /dev/null @@ -1,88 +0,0 @@ -package pro.gravit.launchserver.legacy; - -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import pro.gravit.launcher.request.RequestException; -import pro.gravit.launcher.request.RequestType; -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.legacy.update.LauncherResponse; -import pro.gravit.launchserver.legacy.update.LegacyLauncherResponse; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.utils.helper.LogHelper; - -public abstract class Response { - @FunctionalInterface - public interface Factory { - - Response newResponse(LaunchServer server, long id, HInput input, HOutput output, String ip, Client clientData); - } - - private static final Map> RESPONSES = new ConcurrentHashMap<>(8); - - public static Response getResponse(int type, LaunchServer server, long session, HInput input, HOutput output, String ip, Client clientData) { - return RESPONSES.get(type).newResponse(server, session, input, output, ip, clientData); - } - - public static void registerResponse(int type, Factory factory) { - RESPONSES.put(type, factory); - } - - public static void registerResponses() { - registerResponse(RequestType.PING.getNumber(), PingResponse::new); - registerResponse(RequestType.LEGACYLAUNCHER.getNumber(), LegacyLauncherResponse::new); - registerResponse(RequestType.LAUNCHER.getNumber(), LauncherResponse::new); - } - - - public static void requestError(String message) throws RequestException { - throw new RequestException(message); - } - - - protected final LaunchServer server; - - - protected final HInput input; - - - protected final HOutput output; - - - protected final String ip; - - protected final Client clientData; - - - protected final long session; - - protected Response(LaunchServer server, long session, HInput input, HOutput output, String ip, Client clientData) { - this.server = server; - this.input = input; - this.output = output; - this.ip = ip; - this.session = session; - this.clientData = clientData; - } - - - protected final void debug(String message) { - LogHelper.subDebug("#%d %s", session, message); - } - - - protected final void debug(String message, Object... args) { - debug(String.format(message, args)); - } - - - public abstract void reply() throws Exception; - - - protected static void writeNoError(HOutput output) throws IOException { - output.writeString("", 0); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LauncherResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LauncherResponse.java deleted file mode 100644 index 3673a271..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LauncherResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package pro.gravit.launchserver.legacy.update; - -import java.io.IOException; -import java.util.Arrays; - -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; -import pro.gravit.launcher.serialize.SerializeLimits; -import pro.gravit.launcher.serialize.signed.DigestBytesHolder; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.legacy.Response; -import pro.gravit.launchserver.socket.Client; - -public final class LauncherResponse extends Response { - - public LauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip, Client clientData) { - super(server, session, input, output, ip, clientData); - } - - @Override - public void reply() throws IOException { - // Resolve launcher binary - DigestBytesHolder bytes = (input.readBoolean() ? server.launcherEXEBinary : server.launcherBinary).getBytes(); - if (bytes == null) { - requestError("Missing launcher binary"); - return; - } - byte[] digest = input.readByteArray(SerializeLimits.MAX_DIGEST); - if (!Arrays.equals(bytes.getDigest(), digest)) { - writeNoError(output); - output.writeBoolean(true); - output.writeByteArray(bytes.getBytes(), 0); - clientData.checkSign = false; - return; - } - writeNoError(output); - output.writeBoolean(false); - clientData.checkSign = true; - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LegacyLauncherResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LegacyLauncherResponse.java deleted file mode 100644 index 00eff279..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/legacy/update/LegacyLauncherResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -package pro.gravit.launchserver.legacy.update; - -import java.io.IOException; - -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.binary.LauncherBinary; -import pro.gravit.launchserver.legacy.Response; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.utils.helper.SecurityHelper; - -public final class LegacyLauncherResponse extends Response { - - public LegacyLauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip, Client clientData) { - super(server, session, input, output, ip, clientData); - } - - @Override - public void reply() throws IOException { - // Resolve launcher binary - LauncherBinary bytes = (input.readBoolean() ? server.launcherEXEBinary : server.launcherBinary); - if (bytes == null) { - requestError("Missing launcher binary"); - return; - } - writeNoError(output); - - // Update launcher binary - output.writeByteArray(bytes.getSign(), -SecurityHelper.RSA_KEY_LENGTH); - output.flush(); - if (input.readBoolean()) { - output.writeByteArray(bytes.getBytes().getBytes(), 0); - return; // Launcher will be restarted - } - requestError("You must update"); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/SocketHookManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/SocketHookManager.java deleted file mode 100644 index 704ae554..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/SocketHookManager.java +++ /dev/null @@ -1,86 +0,0 @@ -package pro.gravit.launchserver.manangers.hook; - -import java.net.Socket; -import java.util.HashSet; -import java.util.Set; - -import pro.gravit.launcher.request.RequestException; -import pro.gravit.launchserver.socket.SocketContext; - -public class SocketHookManager { - @FunctionalInterface - public interface SocketPreHook { - boolean preHook(SocketContext context); //Вернуть true если необходимо продолжть обработку, false если остановить обработку - } - - @FunctionalInterface - public interface SocketPostHook { - void postHook(SocketContext context); - } - - @FunctionalInterface - public interface SocketErrorHook { - boolean errorHook(SocketContext context, RequestException e); //Вернуть true если необходимо продолжть обработку, false если остановить обработку - } - - @FunctionalInterface - public interface SocketFatalErrorHook { - boolean fatalErrorHook(Socket socket, Exception e); //Вернуть true если необходимо продолжть обработку, false если остановить обработку - } - - private Set POST_HOOKS; - private Set PRE_HOOKS; - private Set ERROR_HOOKS; - private Set FATALERROR_HOOKS; - - public void registerPostHook(SocketPostHook hook) { - if (POST_HOOKS == null) POST_HOOKS = new HashSet<>(); - POST_HOOKS.add(hook); - } - - public void registerPreHook(SocketPreHook hook) { - if (PRE_HOOKS == null) PRE_HOOKS = new HashSet<>(); - PRE_HOOKS.add(hook); - } - - public void registerErrorHook(SocketErrorHook hook) { - if (ERROR_HOOKS == null) ERROR_HOOKS = new HashSet<>(); - ERROR_HOOKS.add(hook); - } - - public void registerFatalErrorHook(SocketFatalErrorHook hook) { - if (FATALERROR_HOOKS == null) FATALERROR_HOOKS = new HashSet<>(); - FATALERROR_HOOKS.add(hook); - } - - public boolean preHook(SocketContext context) { - if (PRE_HOOKS == null) return true; - for (SocketPreHook preHook : PRE_HOOKS) { - if (!preHook.preHook(context)) return false; - } - return true; - } - - public void postHook(SocketContext context) { - if (POST_HOOKS == null) return; - for (SocketPostHook postHook : POST_HOOKS) { - postHook.postHook(context); - } - } - - public boolean errorHook(SocketContext context, RequestException e) { - if (ERROR_HOOKS == null) return true; - for (SocketErrorHook errorHook : ERROR_HOOKS) { - if (!errorHook.errorHook(context, e)) return false; - } - return true; - } - - public boolean fatalErrorHook(Socket socket, Exception e) { - if (FATALERROR_HOOKS == null) return true; - for (SocketFatalErrorHook errorHook : FATALERROR_HOOKS) { - if (!errorHook.fatalErrorHook(socket, e)) return false; - } - return true; - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ResponseThread.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ResponseThread.java deleted file mode 100644 index aa39ddcf..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ResponseThread.java +++ /dev/null @@ -1,144 +0,0 @@ -package pro.gravit.launchserver.socket; - -import java.io.IOException; -import java.math.BigInteger; -import java.net.Socket; -import java.net.SocketException; - -import pro.gravit.launcher.Launcher; -import pro.gravit.launcher.request.RequestException; -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.legacy.Response; -import pro.gravit.launchserver.manangers.SessionManager; -import pro.gravit.launchserver.manangers.hook.SocketHookManager; -import pro.gravit.utils.helper.IOHelper; -import pro.gravit.utils.helper.LogHelper; -import pro.gravit.utils.helper.SecurityHelper; - -public final class ResponseThread implements Runnable { - class Handshake { - int type; - long session; - - public Handshake(int type, long session) { - this.type = type; - this.session = session; - } - } - - private final LaunchServer server; - private final Socket socket; - - private final SessionManager sessions; - private final SocketHookManager socketHookManager; - - public ResponseThread(LaunchServer server, long id, Socket socket, SessionManager sessionManager, SocketHookManager socketHookManager) throws SocketException { - this.server = server; - this.socket = socket; - sessions = sessionManager; - this.socketHookManager = socketHookManager; - // Fix socket flags - IOHelper.setSocketFlags(socket); - } - - private Handshake readHandshake(HInput input, HOutput output) throws IOException { - boolean legacy = false; - long session = 0; - // Verify magic number - int magicNumber = input.readInt(); - if (magicNumber != Launcher.PROTOCOL_MAGIC) - if (magicNumber == Launcher.PROTOCOL_MAGIC_LEGACY - 1) { // Previous launcher protocol - session = 0; - legacy = true; - } else if (magicNumber == ServerSocketHandler.LEGACY_LAUNCHER_MAGIC) { // Previous launcher protocol - session = 0; - legacy = true; - } else if (magicNumber == Launcher.PROTOCOL_MAGIC_LEGACY) { - - } else - throw new IOException("Invalid Handshake"); - // Verify key modulus - BigInteger keyModulus = input.readBigInteger(SecurityHelper.RSA_KEY_LENGTH + 1); - if (!legacy) { - session = input.readLong(); - sessions.updateClient(session); - } - if (!keyModulus.equals(server.privateKey.getModulus())) { - output.writeBoolean(false); - throw new IOException(String.format("#%d Key modulus mismatch", session)); - } - // Read request type - int type = input.readVarInt(); - if (!server.serverSocketHandler.onHandshake(session, type)) { - output.writeBoolean(false); - return null; - } - - // Protocol successfully verified - output.writeBoolean(true); - output.flush(); - return new Handshake(type, session); - } - - private void respond(Integer type, HInput input, HOutput output, long session, String ip, Client clientData) throws Exception { - if (server.serverSocketHandler.logConnections) - LogHelper.info("Connection #%d from %s", session, ip); - - // Choose response based on type - Response response = Response.getResponse(type, server, session, input, output, ip, clientData); - - // Reply - response.reply(); - LogHelper.subDebug("#%d Replied", session); - } - - @Override - public void run() { - if (!server.serverSocketHandler.logConnections) - LogHelper.debug("Connection from %s", IOHelper.getIP(socket.getRemoteSocketAddress())); - - // Process connection - boolean cancelled = false; - Exception savedError = null; - try (HInput input = new HInput(socket.getInputStream()); - HOutput output = new HOutput(socket.getOutputStream())) { - Handshake handshake = readHandshake(input, output); - if (handshake == null) { // Not accepted - cancelled = true; - return; - } - SocketContext context = new SocketContext(); - context.input = input; - context.output = output; - context.ip = IOHelper.getIP(socket.getRemoteSocketAddress()); - context.session = handshake.session; - context.type = handshake.type; - Client clientData = server.sessionManager.getOrNewClient(context.session); - context.client = clientData; - - // Start response - if (socketHookManager.preHook(context)) { - try { - respond(handshake.type, input, output, handshake.session, context.ip, clientData); - socketHookManager.postHook(context); - } catch (RequestException e) { - if (server.socketHookManager.errorHook(context, e)) { - LogHelper.subDebug(String.format("#%d Request error: %s", handshake.session, e.getMessage())); - if (e.getMessage() == null) LogHelper.error(e); - output.writeString(e.getMessage(), 0); - } - } - } - } catch (Exception e) { - savedError = e; - if (server.socketHookManager.fatalErrorHook(socket, e)) - LogHelper.error(e); - } finally { - IOHelper.close(socket); - if (!cancelled) - server.serverSocketHandler.onDisconnect(savedError); - } - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ServerSocketHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ServerSocketHandler.java deleted file mode 100644 index e8cc30dc..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/ServerSocketHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -package pro.gravit.launchserver.socket; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - -import pro.gravit.launcher.Launcher; -import pro.gravit.launcher.managers.GarbageManager; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.manangers.SessionManager; -import pro.gravit.utils.helper.CommonHelper; -import pro.gravit.utils.helper.LogHelper; - -public final class ServerSocketHandler implements Runnable, AutoCloseable { - public interface Listener { - - boolean onConnect(InetAddress address); - - - void onDisconnect(Exception e); - - - boolean onHandshake(long session, int type); - } - - private static final ThreadFactory THREAD_FACTORY = r -> CommonHelper.newThread("Network Thread", true, r); - - - public volatile boolean logConnections = Boolean.getBoolean("launcher.logConnections"); - // Instance - private final LaunchServer server; - private final AtomicReference serverSocket = new AtomicReference<>(); - private final ExecutorService threadPool; - - public final SessionManager sessionManager; - private final AtomicLong idCounter = new AtomicLong(0L); - public static int LEGACY_LAUNCHER_MAGIC = Launcher.PROTOCOL_MAGIC_LEGACY - 2; - - private volatile Listener listener; - - public ServerSocketHandler(LaunchServer server) { - this(server, new SessionManager()); - GarbageManager.registerNeedGC(sessionManager); - } - - public ServerSocketHandler(LaunchServer server, SessionManager sessionManager) { - this.server = server; - threadPool = new ThreadPoolExecutor(server.config.threadCoreCount, Integer.MAX_VALUE, - server.config.threadCount, TimeUnit.SECONDS, - new SynchronousQueue<>(), - THREAD_FACTORY); - this.sessionManager = sessionManager; - } - - @Override - public void close() { - ServerSocket socket = serverSocket.getAndSet(null); - if (socket != null) { - LogHelper.info("Closing server socket listener"); - try { - socket.close(); - } catch (IOException e) { - LogHelper.error(e); - } - } - } - - /*package*/ void onDisconnect(Exception e) { - if (listener != null) - listener.onDisconnect(e); - } - - /*package*/ boolean onHandshake(long session, int type) { - return listener == null || listener.onHandshake(session, type); - } - - @Override - public void run() { - LogHelper.info("Starting server socket thread"); - try (ServerSocket serverSocket = new ServerSocket()) { - if (!this.serverSocket.compareAndSet(null, serverSocket)) - throw new IllegalStateException("Previous socket wasn't closed"); - - // Set socket params - serverSocket.setReuseAddress(true); - serverSocket.setPerformancePreferences(1, 0, 2); - //serverSocket.setReceiveBufferSize(0x10000); - serverSocket.bind(server.config.getSocketAddress()); - LogHelper.info("Server socket thread successfully started"); - - // Listen for incoming connections - while (serverSocket.isBound()) { - Socket socket = serverSocket.accept(); - - // Invoke pre-connect listener - long id = idCounter.incrementAndGet(); - if (listener != null && !listener.onConnect(socket.getInetAddress())) { - socket.close(); - continue; // Listener didn't accepted this connection - } - - - // Reply in separate thread - threadPool.execute(new ResponseThread(server, id, socket, sessionManager, server.socketHookManager)); - } - } catch (IOException e) { - // Ignore error after close/rebind - if (serverSocket.get() != null) - LogHelper.error(e); - } - } - - - public void setListener(Listener listener) { - this.listener = listener; - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketContext.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketContext.java deleted file mode 100644 index 31b8daf9..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketContext.java +++ /dev/null @@ -1,13 +0,0 @@ -package pro.gravit.launchserver.socket; - -import pro.gravit.launcher.serialize.HInput; -import pro.gravit.launcher.serialize.HOutput; - -public class SocketContext { - public HInput input; - public HOutput output; - public long session; - public String ip; - public Integer type; - public Client client; -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java index 79e7c791..09b353be 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java @@ -1,9 +1,7 @@ package pro.gravit.launchserver.websocket; import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.ServerSocket; import java.net.Socket; import java.security.KeyManagementException; import java.security.KeyStore; @@ -12,12 +10,7 @@ import java.security.SecureRandom; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; -import java.util.Map; -import java.util.Objects; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; @@ -27,9 +20,7 @@ import pro.gravit.launcher.ssl.LauncherKeyStore; import pro.gravit.launcher.ssl.LauncherTrustManager; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.legacy.Response; import pro.gravit.utils.helper.LogHelper; -import pro.gravit.utils.helper.VerifyHelper; @SuppressWarnings({"unused", "rawtypes"}) public final class NettyServerSocketHandler implements Runnable, AutoCloseable { @@ -39,13 +30,8 @@ public final class NettyServerSocketHandler implements Runnable, AutoCloseable { public LauncherNettyServer nettyServer; - private final AtomicReference serverSocket = new AtomicReference<>(); - // API - private final Map customResponses = new ConcurrentHashMap<>(2); - private final AtomicLong idCounter = new AtomicLong(0L); private Set sockets; - private volatile Listener listener; private transient final LaunchServer server; @@ -55,15 +41,7 @@ public NettyServerSocketHandler(LaunchServer server) { @Override public void close() { - ServerSocket socket = serverSocket.getAndSet(null); - if (socket != null) { - LogHelper.info("Closing server socket listener"); - try { - socket.close(); - } catch (IOException e) { - LogHelper.error(e); - } - } + //TODO: Close Impl } public SSLContext SSLContextInit() throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException, IOException, CertificateException { @@ -149,37 +127,4 @@ public void run() { } */ } - - - public void registerCustomResponse(String name, Response.Factory factory) { - VerifyHelper.verifyIDName(name); - VerifyHelper.putIfAbsent(customResponses, name, Objects.requireNonNull(factory, "factory"), - String.format("Custom response has been already registered: '%s'", name)); - } - - - public void setListener(Listener listener) { - this.listener = listener; - } - - /*package*/ void onDisconnect(long id, Exception e) { - if (listener != null) { - listener.onDisconnect(id, e); - } - } - - /*package*/ boolean onHandshake(long id, Integer type) { - return listener == null || listener.onHandshake(id, type); - } - - public interface Listener { - - boolean onConnect(long id, InetAddress address); - - - void onDisconnect(long id, Exception e); - - - boolean onHandshake(long id, Integer type); - } } diff --git a/modules b/modules index b9c9d267..2c4f44c3 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit b9c9d2675c081a8af2c54b00f5907e3c82f73c4d +Subproject commit 2c4f44c30106bfb83334d28ecb5aebbd58a62c08 From ddb4bc972813b4ac0178d0cc8e5c2981715a0773 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 16:08:29 +0700 Subject: [PATCH 29/70] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20legacyAddress/legacyPort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 8fe8b9b6..e9feddcb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -99,11 +99,6 @@ public void reload() throws Exception { public static final class Config { private transient LaunchServer server = null; - public int legacyPort; - - private String legacyAddress; - - private String legacyBindAddress; public String projectName; @@ -169,15 +164,6 @@ public AuthProviderPair getAuthProviderPair() { public String startScript; - public String getLegacyAddress() { - return legacyAddress; - } - - - public String getLegacyBindAddress() { - return legacyBindAddress; - } - public void setProjectName(String projectName) { this.projectName = projectName; } @@ -191,13 +177,7 @@ public void setEnv(LauncherConfig.LauncherEnvironment env) { } - public void setLegacyAddress(String legacyAddress) { - this.legacyAddress = legacyAddress; - } - - public void verify() { - VerifyHelper.verify(getLegacyAddress(), VerifyHelper.NOT_EMPTY, "LaunchServer address can't be empty"); if (auth == null || auth[0] == null) { throw new NullPointerException("AuthHandler must not be null"); } @@ -736,8 +716,6 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.protectHandler = new StdProtectHandler(); if (testEnv) newConfig.permissionsHandler = new DefaultPermissionsHandler(); else newConfig.permissionsHandler = new JsonFilePermissionsHandler(); - newConfig.legacyPort = 7240; - newConfig.legacyBindAddress = "0.0.0.0"; newConfig.binaryName = "Launcher"; newConfig.whitelistRejectString = "Вас нет в белом списке"; @@ -787,8 +765,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { LogHelper.error("ProjectName null. Using MineCraft"); newConfig.projectName = "MineCraft"; } - - newConfig.legacyAddress = address; + newConfig.netty.address = "ws://" + address + ":9274/api"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar"; From e556bd70e8aeac9c31713659cccd9eada02d2fcd Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 16:12:32 +0700 Subject: [PATCH 30/70] [ANY] Update modules --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 2c4f44c3..dba4f013 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 2c4f44c30106bfb83334d28ecb5aebbd58a62c08 +Subproject commit dba4f0132cdb49cbc6cb7356fb6a54a063aba8b5 From b93c7d33eb00e99f79ffc16ec436bea8a290163f Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 16:27:05 +0700 Subject: [PATCH 31/70] =?UTF-8?q?[FIX]=20json=20=D1=80=D0=B0=D1=81=D1=88?= =?UTF-8?q?=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=BE=20conf/cfg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 20 ++++++++++++++++--- .../command/hash/DownloadClientCommand.java | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index e9feddcb..d2408571 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -463,8 +463,22 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException launcherLibraries = dir.resolve("launcher-libraries"); launcherLibrariesCompile = dir.resolve("launcher-libraries-compile"); this.args = Arrays.asList(args); - configFile = dir.resolve("LaunchServer.conf"); - runtimeConfigFile = dir.resolve("RuntimeLaunchServer.conf"); + if(IOHelper.exists(dir.resolve("LaunchServer.conf"))) + { + configFile = dir.resolve("LaunchServer.conf"); + } + else + { + configFile = dir.resolve("LaunchServer.json"); + } + if(IOHelper.exists(dir.resolve("RuntimeLaunchServer.conf"))) + { + runtimeConfigFile = dir.resolve("RuntimeLaunchServer.conf"); + } + else + { + runtimeConfigFile = dir.resolve("RuntimeLaunchServer.json"); + } publicKeyFile = dir.resolve("public.key"); privateKeyFile = dir.resolve("private.key"); updatesDir = dir.resolve("updates"); @@ -765,7 +779,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { LogHelper.error("ProjectName null. Using MineCraft"); newConfig.projectName = "MineCraft"; } - + newConfig.netty.address = "ws://" + address + ":9274/api"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar"; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java index 2f32cf6e..26807bc4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -58,7 +58,7 @@ public void invoke(String... args) throws IOException, CommandException { client.setTitle(dirName); client.setDir(dirName); try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir, - dirName, "cfg"))) { + dirName, "json"))) { Launcher.gsonManager.configGson.toJson(client, writer); } From b40876734302d9debe089061ba052139bc527fe9 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 28 Jun 2019 16:33:26 +0700 Subject: [PATCH 32/70] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B1=D0=B5=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B2=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B0=D1=85=20?= =?UTF-8?q?updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/websocket/json/update/UpdateResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java index 029181db..a40ba1a4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java @@ -9,6 +9,7 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.utils.helper.IOHelper; public class UpdateResponse extends SimpleResponse { public String dirName; @@ -38,7 +39,7 @@ public void execute(ChannelHandlerContext ctx, Client client) { service.sendObject(ctx, new ErrorRequestEvent(String.format("Directory %s not found", dirName))); return; } - String url = server.config.netty.downloadURL.replace("%dirname%", dirName); + String url = server.config.netty.downloadURL.replace("%dirname%", IOHelper.urlEncode(dirName)); boolean zip = false; if (server.config.netty.bindings.get(dirName) != null) { LaunchServer.NettyUpdatesBind bind = server.config.netty.bindings.get(dirName); From 494e714bb334401732bfc1b8ef281d85c04f873f Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 14:37:01 +0700 Subject: [PATCH 33/70] =?UTF-8?q?[FIX]=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2=20websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 3 +- .../auth/protect/NoProtectHandler.java | 2 +- .../auth/protect/ProtectHandler.java | 2 +- .../auth/protect/StdProtectHandler.java | 2 +- .../command/basic/TestCommand.java | 2 +- .../components/AuthLimiterComponent.java | 2 +- .../manangers/hook/AuthHookManager.java | 8 ++-- .../LauncherNettyServer.java | 6 ++- .../NettyConnectContext.java | 2 +- .../WebSocketService.java | 47 +++++++++---------- .../handlers}/NettyIpForwardHandler.java | 3 +- .../handlers}/NettyServerSocketHandler.java | 3 +- .../handlers}/WebSocketFrameHandler.java | 4 +- .../ClosingChannelFutureListener.java | 2 +- .../fileserver/FileServerHandler.java | 2 +- .../response}/JsonResponseAdapter.java | 4 +- .../response}/JsonResponseInterface.java | 2 +- .../response}/SimpleResponse.java | 4 +- .../admin/AddLogListenerResponse.java | 4 +- .../response}/admin/ExecCommandResponse.java | 4 +- .../response}/admin/ProxyCommandResponse.java | 6 +-- .../response}/auth/AuthResponse.java | 6 +-- .../response}/auth/CheckServerResponse.java | 6 +-- .../auth/GetAvailabilityAuthResponse.java | 4 +- .../response}/auth/JoinServerResponse.java | 4 +- .../response}/auth/ProfilesResponse.java | 4 +- .../auth/RestoreSessionResponse.java | 6 +-- .../response}/auth/SetProfileResponse.java | 4 +- .../profile/BatchProfileByUsername.java | 4 +- .../profile/ProfileByUUIDResponse.java | 4 +- .../response}/profile/ProfileByUsername.java | 4 +- .../secure/GetSecureTokenResponse.java | 4 +- .../secure/VerifySecureTokenResponse.java | 4 +- .../response}/update/LauncherResponse.java | 4 +- .../response}/update/UpdateListResponse.java | 4 +- .../response}/update/UpdateResponse.java | 4 +- 36 files changed, 92 insertions(+), 88 deletions(-) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket}/LauncherNettyServer.java (93%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket}/NettyConnectContext.java (60%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket}/WebSocketService.java (84%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket/handlers}/NettyIpForwardHandler.java (92%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket/handlers}/NettyServerSocketHandler.java (97%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket/handlers}/WebSocketFrameHandler.java (94%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket/handlers}/fileserver/ClosingChannelFutureListener.java (89%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket => socket/handlers}/fileserver/FileServerHandler.java (99%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/JsonResponseAdapter.java (93%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/JsonResponseInterface.java (86%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/SimpleResponse.java (91%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/admin/AddLogListenerResponse.java (92%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/admin/ExecCommandResponse.java (84%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/admin/ProxyCommandResponse.java (78%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/AuthResponse.java (97%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/CheckServerResponse.java (88%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/GetAvailabilityAuthResponse.java (87%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/JoinServerResponse.java (92%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/ProfilesResponse.java (85%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/RestoreSessionResponse.java (81%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/auth/SetProfileResponse.java (91%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/profile/BatchProfileByUsername.java (91%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/profile/ProfileByUUIDResponse.java (94%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/profile/ProfileByUsername.java (88%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/secure/GetSecureTokenResponse.java (83%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/secure/VerifySecureTokenResponse.java (84%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/update/LauncherResponse.java (94%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/update/UpdateListResponse.java (88%) rename LaunchServer/src/main/java/pro/gravit/launchserver/{websocket/json => socket/response}/update/UpdateResponse.java (94%) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index d2408571..6799d7b7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -72,7 +72,7 @@ import pro.gravit.launchserver.manangers.SessionManager; import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.launchserver.manangers.hook.BuildHookManager; -import pro.gravit.launchserver.websocket.NettyServerSocketHandler; +import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; import pro.gravit.utils.Version; import pro.gravit.utils.command.CommandHandler; import pro.gravit.utils.command.JLineCommandHandler; @@ -82,7 +82,6 @@ import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; -import pro.gravit.utils.helper.VerifyHelper; public final class LaunchServer implements Runnable, AutoCloseable, Reloadable { @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java index 7f220703..7985c744 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java @@ -1,6 +1,6 @@ package pro.gravit.launchserver.auth.protect; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.utils.helper.SecurityHelper; public class NoProtectHandler extends ProtectHandler { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java index c96a15f6..9cd5a200 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java @@ -1,6 +1,6 @@ package pro.gravit.launchserver.auth.protect; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.utils.ProviderMap; public abstract class ProtectHandler { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java index d88e6163..0c37166e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java @@ -1,6 +1,6 @@ package pro.gravit.launchserver.auth.protect; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.utils.helper.SecurityHelper; public class StdProtectHandler extends ProtectHandler { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java index 7acf72b9..917b9f9b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java @@ -3,7 +3,7 @@ import pro.gravit.launcher.events.PingEvent; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; -import pro.gravit.launchserver.websocket.NettyServerSocketHandler; +import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; import pro.gravit.utils.helper.CommonHelper; public class TestCommand extends Command { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java index 61b889c4..844a9e56 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java @@ -7,7 +7,7 @@ import pro.gravit.launcher.NeedGarbageCollection; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.utils.BiHookSet.Hook; import pro.gravit.utils.HookException; 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 fa42d7bd..ef181c2f 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,10 +1,10 @@ package pro.gravit.launchserver.manangers.hook; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; -import pro.gravit.launchserver.websocket.json.auth.CheckServerResponse; -import pro.gravit.launchserver.websocket.json.auth.JoinServerResponse; -import pro.gravit.launchserver.websocket.json.auth.SetProfileResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.CheckServerResponse; +import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; +import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; import pro.gravit.utils.BiHookSet; public class AuthHookManager { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/LauncherNettyServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java similarity index 93% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/LauncherNettyServer.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java index d127069e..0c24db50 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket; import java.net.InetSocketAddress; @@ -19,7 +19,9 @@ import pro.gravit.launcher.request.auth.AuthRequest; import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.websocket.fileserver.FileServerHandler; +import pro.gravit.launchserver.socket.handlers.NettyIpForwardHandler; +import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; +import pro.gravit.launchserver.socket.handlers.fileserver.FileServerHandler; import pro.gravit.utils.helper.LogHelper; public class LauncherNettyServer implements AutoCloseable { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyConnectContext.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyConnectContext.java similarity index 60% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyConnectContext.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyConnectContext.java index c9f95cad..6b7297a7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyConnectContext.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyConnectContext.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket; public class NettyConnectContext { public String ip = null; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java similarity index 84% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 034c4732..e939c68d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket; import java.lang.reflect.Type; import java.util.HashMap; @@ -25,28 +25,27 @@ import pro.gravit.launcher.request.ResultInterface; import pro.gravit.launcher.request.admin.ProxyRequest; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.JsonResponseAdapter; -import pro.gravit.launchserver.websocket.json.JsonResponseInterface; -import pro.gravit.launchserver.websocket.json.SimpleResponse; -import pro.gravit.launchserver.websocket.json.admin.AddLogListenerResponse; -import pro.gravit.launchserver.websocket.json.admin.ExecCommandResponse; -import pro.gravit.launchserver.websocket.json.admin.ProxyCommandResponse; -import pro.gravit.launchserver.websocket.json.auth.AuthResponse; -import pro.gravit.launchserver.websocket.json.auth.CheckServerResponse; -import pro.gravit.launchserver.websocket.json.auth.GetAvailabilityAuthResponse; -import pro.gravit.launchserver.websocket.json.auth.JoinServerResponse; -import pro.gravit.launchserver.websocket.json.auth.ProfilesResponse; -import pro.gravit.launchserver.websocket.json.auth.RestoreSessionResponse; -import pro.gravit.launchserver.websocket.json.auth.SetProfileResponse; -import pro.gravit.launchserver.websocket.json.profile.BatchProfileByUsername; -import pro.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse; -import pro.gravit.launchserver.websocket.json.profile.ProfileByUsername; -import pro.gravit.launchserver.websocket.json.secure.GetSecureTokenResponse; -import pro.gravit.launchserver.websocket.json.secure.VerifySecureTokenResponse; -import pro.gravit.launchserver.websocket.json.update.LauncherResponse; -import pro.gravit.launchserver.websocket.json.update.UpdateListResponse; -import pro.gravit.launchserver.websocket.json.update.UpdateResponse; +import pro.gravit.launchserver.socket.response.JsonResponseAdapter; +import pro.gravit.launchserver.socket.response.JsonResponseInterface; +import pro.gravit.launchserver.socket.response.SimpleResponse; +import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse; +import pro.gravit.launchserver.socket.response.admin.ExecCommandResponse; +import pro.gravit.launchserver.socket.response.admin.ProxyCommandResponse; +import pro.gravit.launchserver.socket.response.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.auth.CheckServerResponse; +import pro.gravit.launchserver.socket.response.auth.GetAvailabilityAuthResponse; +import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; +import pro.gravit.launchserver.socket.response.auth.ProfilesResponse; +import pro.gravit.launchserver.socket.response.auth.RestoreSessionResponse; +import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; +import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername; +import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; +import pro.gravit.launchserver.socket.response.profile.ProfileByUsername; +import pro.gravit.launchserver.socket.response.secure.GetSecureTokenResponse; +import pro.gravit.launchserver.socket.response.secure.VerifySecureTokenResponse; +import pro.gravit.launchserver.socket.response.update.LauncherResponse; +import pro.gravit.launchserver.socket.response.update.UpdateListResponse; +import pro.gravit.launchserver.socket.response.update.UpdateResponse; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; @@ -69,7 +68,7 @@ public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder private final Gson gson; private final GsonBuilder gsonBuiler; - void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) { + public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) { String request = frame.text(); JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class); if (server.config.netty.proxy.enabled) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyIpForwardHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java similarity index 92% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyIpForwardHandler.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java index c9554763..4908b4e4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyIpForwardHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket.handlers; import java.util.List; @@ -7,6 +7,7 @@ import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpRequest; import io.netty.util.ReferenceCounted; +import pro.gravit.launchserver.socket.NettyConnectContext; import pro.gravit.utils.helper.LogHelper; public class NettyIpForwardHandler extends MessageToMessageDecoder { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java similarity index 97% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java index 09b353be..e87f814d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket.handlers; import java.io.IOException; import java.net.InetSocketAddress; @@ -20,6 +20,7 @@ import pro.gravit.launcher.ssl.LauncherKeyStore; import pro.gravit.launcher.ssl.LauncherTrustManager; import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.socket.LauncherNettyServer; import pro.gravit.utils.helper.LogHelper; @SuppressWarnings({"unused", "rawtypes"}) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketFrameHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java similarity index 94% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketFrameHandler.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java index e9c267d6..b27c9280 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket; +package pro.gravit.launchserver.socket.handlers; import java.util.concurrent.TimeUnit; @@ -15,6 +15,8 @@ import io.netty.util.concurrent.GlobalEventExecutor; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.NettyConnectContext; +import pro.gravit.launchserver.socket.WebSocketService; import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/ClosingChannelFutureListener.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/ClosingChannelFutureListener.java similarity index 89% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/ClosingChannelFutureListener.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/ClosingChannelFutureListener.java index a6396acc..987c6a2a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/ClosingChannelFutureListener.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/ClosingChannelFutureListener.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.fileserver; +package pro.gravit.launchserver.socket.handlers.fileserver; import java.io.Closeable; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java similarity index 99% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java index a058581a..88e762ac 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.fileserver; +package pro.gravit.launchserver.socket.handlers.fileserver; import static io.netty.handler.codec.http.HttpMethod.GET; import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseAdapter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java similarity index 93% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseAdapter.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java index df43e3be..0ebc0327 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseAdapter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json; +package pro.gravit.launchserver.socket.response; import java.lang.reflect.Type; @@ -11,7 +11,7 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import pro.gravit.launchserver.websocket.WebSocketService; +import pro.gravit.launchserver.socket.WebSocketService; public class JsonResponseAdapter implements JsonSerializer, JsonDeserializer { private final WebSocketService service; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseInterface.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java similarity index 86% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseInterface.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java index 7a0431fd..1e44ba4e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/JsonResponseInterface.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json; +package pro.gravit.launchserver.socket.response; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.request.websockets.RequestInterface; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/SimpleResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java similarity index 91% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/SimpleResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java index b7496b66..cd90c345 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/SimpleResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json; +package pro.gravit.launchserver.socket.response; import java.util.UUID; @@ -7,7 +7,7 @@ import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.WebSocketService; +import pro.gravit.launchserver.socket.WebSocketService; public abstract class SimpleResponse implements JsonResponseInterface { public UUID requestUUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java similarity index 92% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java index f8a321da..1a7ec741 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java @@ -1,9 +1,9 @@ -package pro.gravit.launchserver.websocket.json.admin; +package pro.gravit.launchserver.socket.response.admin; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.LogEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.LogHelper; public class AddLogListenerResponse extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ExecCommandResponse.java similarity index 84% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ExecCommandResponse.java index 1af1f411..9c7a3d44 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ExecCommandResponse.java @@ -1,9 +1,9 @@ -package pro.gravit.launchserver.websocket.json.admin; +package pro.gravit.launchserver.socket.response.admin; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.ExecCommandRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class ExecCommandResponse extends SimpleResponse { public String cmd; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ProxyCommandResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java similarity index 78% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ProxyCommandResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java index d13ede9e..356fd471 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/admin/ProxyCommandResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java @@ -1,9 +1,9 @@ -package pro.gravit.launchserver.websocket.json.admin; +package pro.gravit.launchserver.socket.response.admin; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.JsonResponseInterface; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.JsonResponseInterface; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class ProxyCommandResponse extends SimpleResponse { public JsonResponseInterface response; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java similarity index 97% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/AuthResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index 858550f2..c5f0d8e2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import java.security.SecureRandom; import java.util.Collection; @@ -18,8 +18,8 @@ import pro.gravit.launchserver.auth.provider.AuthProvider; import pro.gravit.launchserver.auth.provider.AuthProviderResult; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; -import pro.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; +import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.utils.HookException; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/CheckServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java similarity index 88% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/CheckServerResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java index 02f65056..f660672e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java @@ -1,11 +1,11 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.CheckServerRequestEvent; import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; -import pro.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; +import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.utils.HookException; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java similarity index 87% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java index 5a855a60..ffa5a032 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import java.util.ArrayList; import java.util.List; @@ -7,7 +7,7 @@ import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class GetAvailabilityAuthResponse extends SimpleResponse { @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/JoinServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java similarity index 92% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/JoinServerResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java index 24e814c3..c1a66a7f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java @@ -1,10 +1,10 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.JoinServerRequestEvent; import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.HookException; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/ProfilesResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ProfilesResponse.java similarity index 85% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/ProfilesResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ProfilesResponse.java index dfff2930..5c00006e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/ProfilesResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ProfilesResponse.java @@ -1,10 +1,10 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.ProfilesRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class ProfilesResponse extends SimpleResponse { @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java similarity index 81% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java index bff4b6ab..db432c09 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java @@ -1,11 +1,11 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.WebSocketFrameHandler; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class RestoreSessionResponse extends SimpleResponse { @LauncherNetworkAPI diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/SetProfileResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetProfileResponse.java similarity index 91% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/SetProfileResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetProfileResponse.java index 206ac069..9087369f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetProfileResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.auth; +package pro.gravit.launchserver.socket.response.auth; import java.util.Collection; @@ -6,7 +6,7 @@ import pro.gravit.launcher.events.request.SetProfileRequestEvent; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.HookException; public class SetProfileResponse extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java similarity index 91% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java index 7e8e86ad..bdb16f23 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.profile; +package pro.gravit.launchserver.socket.response.profile; import java.util.UUID; @@ -6,7 +6,7 @@ import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.LogHelper; public class BatchProfileByUsername extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java similarity index 94% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java index d2a23b7d..c782c297 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.profile; +package pro.gravit.launchserver.socket.response.profile; import java.io.IOException; import java.util.UUID; @@ -10,7 +10,7 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.LogHelper; public class ProfileByUUIDResponse extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUsername.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java similarity index 88% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUsername.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java index e50d5b9f..0f303e1c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/profile/ProfileByUsername.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java @@ -1,11 +1,11 @@ -package pro.gravit.launchserver.websocket.json.profile; +package pro.gravit.launchserver.socket.response.profile; import java.util.UUID; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.LogHelper; public class ProfileByUsername extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/GetSecureTokenResponse.java similarity index 83% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/GetSecureTokenResponse.java index 238683ca..9beb1ec5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/GetSecureTokenResponse.java @@ -1,9 +1,9 @@ -package pro.gravit.launchserver.websocket.json.secure; +package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class GetSecureTokenResponse extends SimpleResponse { @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureTokenResponse.java similarity index 84% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureTokenResponse.java index 44adff98..e59170c5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureTokenResponse.java @@ -1,9 +1,9 @@ -package pro.gravit.launchserver.websocket.json.secure; +package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class VerifySecureTokenResponse extends SimpleResponse { public String secureToken; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/LauncherResponse.java similarity index 94% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/LauncherResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/LauncherResponse.java index d029228f..765374f1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/LauncherResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.update; +package pro.gravit.launchserver.socket.response.update; import java.util.Arrays; import java.util.Base64; @@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.LauncherRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.Version; public class LauncherResponse extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateListResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java similarity index 88% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateListResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java index 59ab9b44..118d72ed 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateListResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.update; +package pro.gravit.launchserver.socket.response.update; import java.util.HashSet; import java.util.Map; @@ -8,7 +8,7 @@ import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.serialize.signed.SignedObjectHolder; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; public class UpdateListResponse extends SimpleResponse { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateResponse.java similarity index 94% rename from LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateResponse.java index a40ba1a4..6d4f8431 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/websocket/json/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateResponse.java @@ -1,4 +1,4 @@ -package pro.gravit.launchserver.websocket.json.update; +package pro.gravit.launchserver.socket.response.update; import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.ErrorRequestEvent; @@ -8,7 +8,7 @@ import pro.gravit.launcher.serialize.signed.SignedObjectHolder; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.websocket.json.SimpleResponse; +import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.IOHelper; public class UpdateResponse extends SimpleResponse { From 5df618787fb6ef7212ef23c407ddce47fad6ed1d Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 14:54:33 +0700 Subject: [PATCH 34/70] =?UTF-8?q?[FEATURE]=20=D0=A0=D0=B5=D0=B3=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B2=20=D0=BB?= =?UTF-8?q?=D0=B0=D1=83=D0=BD=D1=87=D0=B5=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/LaunchServerRuntimeConfig.java | 2 + .../launchserver/socket/WebSocketService.java | 9 +--- .../socket/response/SimpleResponse.java | 5 --- .../response/auth/RegisterResponse.java | 42 +++++++++++++++++++ .../events/request/RegisterRequestEvent.java | 10 +++++ .../websockets/ClientWebSocketService.java | 20 +-------- 6 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerRuntimeConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerRuntimeConfig.java index 434df53f..fdc4eb42 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerRuntimeConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerRuntimeConfig.java @@ -6,6 +6,7 @@ public class LaunchServerRuntimeConfig { public String clientToken; public String oemUnlockKey; + public String registerApiKey; public void verify() { if (clientToken == null) LogHelper.error("[RuntimeConfig] clientToken must not be null"); @@ -13,5 +14,6 @@ public void verify() { public void reset() { clientToken = SecurityHelper.randomStringToken(); + registerApiKey = SecurityHelper.randomStringToken(); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index e939c68d..8d149f62 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -31,13 +31,7 @@ import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse; import pro.gravit.launchserver.socket.response.admin.ExecCommandResponse; import pro.gravit.launchserver.socket.response.admin.ProxyCommandResponse; -import pro.gravit.launchserver.socket.response.auth.AuthResponse; -import pro.gravit.launchserver.socket.response.auth.CheckServerResponse; -import pro.gravit.launchserver.socket.response.auth.GetAvailabilityAuthResponse; -import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; -import pro.gravit.launchserver.socket.response.auth.ProfilesResponse; -import pro.gravit.launchserver.socket.response.auth.RestoreSessionResponse; -import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; +import pro.gravit.launchserver.socket.response.auth.*; import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUsername; @@ -183,6 +177,7 @@ public void registerResponses() { registerResponse("verifySecureToken", VerifySecureTokenResponse.class); registerResponse("getAvailabilityAuth", GetAvailabilityAuthResponse.class); registerResponse("proxy", ProxyCommandResponse.class); + registerResponse("register", RegisterResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java index cd90c345..783daaaf 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java @@ -31,9 +31,4 @@ public void sendError(String errorMessage) { event.requestUUID = requestUUID; service.sendObject(ctx, event); } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) throws Exception { - - } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java new file mode 100644 index 00000000..c1833660 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java @@ -0,0 +1,42 @@ +package pro.gravit.launchserver.socket.response.auth; + +import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launchserver.dao.User; +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.response.SimpleResponse; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.UUID; + +public class RegisterResponse extends SimpleResponse { + public String login; + public String password; + public byte[] verifyHash; + @Override + public void execute(ChannelHandlerContext ctx, Client client) throws Exception + { + byte[] normalHash = registerHash(login, server.runtime.registerApiKey); + if(!( client.isAuth && client.permissions.canAdmin ) && !Arrays.equals(normalHash, verifyHash)) + { + sendError("Hash invalid"); + return; + } + User user = new User(); + user.username = login; + user.setPassword(password); + user.uuid = UUID.randomUUID(); + server.userService.saveUser(user); + } + @Override + public String getType() { + return "register"; + } + public static byte[] registerHash(String login, String secret) throws NoSuchAlgorithmException { + String text = login.concat("+").concat(secret); + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + return digest.digest(text.getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java new file mode 100644 index 00000000..f08506c8 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.events.request; + +import pro.gravit.launcher.events.RequestEvent; + +public class RegisterRequestEvent extends RequestEvent { + @Override + public String getType() { + return "register"; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index f0e2ff5b..7e2217cc 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -12,24 +12,7 @@ import com.google.gson.GsonBuilder; import pro.gravit.launcher.events.ExceptionEvent; -import pro.gravit.launcher.events.request.AuthRequestEvent; -import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; -import pro.gravit.launcher.events.request.CheckServerRequestEvent; -import pro.gravit.launcher.events.request.ErrorRequestEvent; -import pro.gravit.launcher.events.request.ExecCommandRequestEvent; -import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; -import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent; -import pro.gravit.launcher.events.request.JoinServerRequestEvent; -import pro.gravit.launcher.events.request.LauncherRequestEvent; -import pro.gravit.launcher.events.request.LogEvent; -import pro.gravit.launcher.events.request.ProfileByUUIDRequestEvent; -import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; -import pro.gravit.launcher.events.request.ProfilesRequestEvent; -import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; -import pro.gravit.launcher.events.request.SetProfileRequestEvent; -import pro.gravit.launcher.events.request.UpdateListRequestEvent; -import pro.gravit.launcher.events.request.UpdateRequestEvent; -import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent; +import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.request.ResultInterface; @@ -138,6 +121,7 @@ public void registerResults() { registerResult("cmdExec", ExecCommandRequestEvent.class); registerResult("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); registerResult("exception", ExceptionEvent.class); + registerResult("register", RegisterRequestEvent.class); } public void registerHandler(EventHandler eventHandler) { From c8211ae7dd4b1a409c0bacf441e62170d4d9acec Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 15:04:28 +0700 Subject: [PATCH 35/70] =?UTF-8?q?[FEATURE][FIX]=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D0=B7=D0=B0=D1=80=D0=B5=D0=B3=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=BB?= =?UTF-8?q?=D0=B8=20=D1=83=D0=B6=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/socket/response/auth/RegisterResponse.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java index c1833660..b9508345 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java @@ -24,6 +24,12 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception sendError("Hash invalid"); return; } + User checkUser = server.userService.findUserByUsername(login); + if(checkUser != null) + { + sendError("User already register"); + return; + } User user = new User(); user.username = login; user.setPassword(password); From 8ef61b8673f7c882cc894820f26e3d8b32be07fb Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 15:22:48 +0700 Subject: [PATCH 36/70] [FEATURE] DaoProvider --- .../pro/gravit/launchserver/LaunchServer.java | 6 +-- .../auth/handler/HibernateAuthHandler.java | 12 +++--- .../HibernatePermissionsHandler.java | 6 +-- .../auth/provider/HibernateAuthProvider.java | 2 +- .../command/dao/GetAllUsersCommand.java | 2 +- .../command/dao/GetUserCommand.java | 2 +- .../command/dao/RegisterCommand.java | 2 +- .../command/dao/SetUserPasswordCommand.java | 4 +- .../launchserver/components/Component.java | 1 - .../dao/LaunchServerDaoFactory.java | 22 ----------- .../gravit/launchserver/dao/UserService.java | 4 +- .../dao/provider/DaoProvider.java | 17 +++++++++ .../provider/HibernateDaoProvider.java} | 38 +++++-------------- .../manangers/LaunchServerGsonManager.java | 2 + .../response/auth/RegisterResponse.java | 4 +- 15 files changed, 51 insertions(+), 73 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/dao/LaunchServerDaoFactory.java create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java rename LaunchServer/src/main/java/pro/gravit/launchserver/{components/HibernateConfiguratorComponent.java => dao/provider/HibernateDaoProvider.java} (60%) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 6799d7b7..6e7be2ce 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -64,6 +64,7 @@ import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.config.LaunchServerRuntimeConfig; import pro.gravit.launchserver.dao.UserService; +import pro.gravit.launchserver.dao.provider.DaoProvider; import pro.gravit.launchserver.manangers.LaunchServerGsonManager; import pro.gravit.launchserver.manangers.MirrorManager; import pro.gravit.launchserver.manangers.ModulesManager; @@ -113,6 +114,8 @@ public static final class Config { public AuthProviderPair[] auth; + public DaoProvider dao; + private transient AuthProviderPair authDefault; public AuthProviderPair getAuthProviderPair(String name) { @@ -425,8 +428,6 @@ public static void main(String... args) throws Throwable { public final ModulesManager modulesManager; - public final UserService userService; - public final MirrorManager mirrorManager; public final ReloadManager reloadManager; @@ -590,7 +591,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException reconfigurableManager = new ReconfigurableManager(); authHookManager = new AuthHookManager(); configManager = new ConfigManager(); - userService = new UserService(this); GarbageManager.registerNeedGC(sessionManager); reloadManager.registerReloadable("launchServer", this); registerObject("permissionsHandler", config.permissionsHandler); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java index 1dc4df16..883807e9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java @@ -8,31 +8,31 @@ public class HibernateAuthHandler extends CachedAuthHandler { @Override protected Entry fetchEntry(String username) throws IOException { - User user = srv.userService.findUserByUsername(username); + User user = srv.config.dao.userService.findUserByUsername(username); if(user == null) return null; return new Entry(user.uuid, username, user.getAccessToken(), user.serverID); } @Override protected Entry fetchEntry(UUID uuid) throws IOException { - User user = srv.userService.findUserByUUID(uuid); + User user = srv.config.dao.userService.findUserByUUID(uuid); if(user == null) return null; return new Entry(user.uuid, user.username, user.getAccessToken(), user.serverID); } @Override protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException { - User user = srv.userService.findUserByUUID(uuid); + User user = srv.config.dao.userService.findUserByUUID(uuid); user.setAccessToken(accessToken); - srv.userService.updateUser(user); + srv.config.dao.userService.updateUser(user); return true; } @Override protected boolean updateServerID(UUID uuid, String serverID) throws IOException { - User user = srv.userService.findUserByUUID(uuid); + User user = srv.config.dao.userService.findUserByUUID(uuid); user.serverID = serverID; - srv.userService.updateUser(user); + srv.config.dao.userService.updateUser(user); return true; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java index 8298b76a..2e1be761 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java @@ -7,17 +7,17 @@ public class HibernatePermissionsHandler extends PermissionsHandler { @Override public ClientPermissions getPermissions(String username) { - User user = srv.userService.findUserByUsername(username); + User user = srv.config.dao.userService.findUserByUsername(username); if(user == null) return ClientPermissions.DEFAULT; return user.getPermissions(); } @Override public void setPermissions(String username, ClientPermissions permissions) { - User user = srv.userService.findUserByUsername(username); + User user = srv.config.dao.userService.findUserByUsername(username); if(user == null) return; user.setPermissions(permissions); - srv.userService.updateUser(user); + srv.config.dao.userService.updateUser(user); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index b9ec6985..b737f79e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -9,7 +9,7 @@ public class HibernateAuthProvider extends AuthProvider { @Override public AuthProviderResult auth(String login, String password, String ip) throws Exception { - User user = srv.userService.findUserByUsername(login); + User user = srv.config.dao.userService.findUserByUsername(login); if(user == null || !user.verifyPassword(password)) { if(user ==null) throw new AuthException("Username incorrect"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java index e5aa13fa..c0664aca 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java @@ -23,7 +23,7 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { int count = 0; - for(User user : server.userService.findAllUsers()) + for(User user : server.config.dao.userService.findAllUsers()) { LogHelper.subInfo("[%s] UUID: %s", user.username, user.uuid.toString()); count++; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetUserCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetUserCommand.java index 1d681228..d5788850 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetUserCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetUserCommand.java @@ -24,7 +24,7 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { verifyArgs(args, 1); - User user = server.userService.findUserByUsername(args[0]); + User user = server.config.dao.userService.findUserByUsername(args[0]); if(user == null) { LogHelper.error("User %s not found", args[0]); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/RegisterCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/RegisterCommand.java index 40a43f80..04b759e3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/RegisterCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/RegisterCommand.java @@ -29,7 +29,7 @@ public void invoke(String... args) throws Exception { user.username = args[0]; user.setPassword(args[1]); user.uuid = UUID.randomUUID(); - server.userService.saveUser(user); + server.config.dao.userService.saveUser(user); LogHelper.info("User %s registered. UUID: %s", user.username, user.uuid.toString()); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/SetUserPasswordCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/SetUserPasswordCommand.java index e0b38d9c..75ef14ff 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/SetUserPasswordCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/SetUserPasswordCommand.java @@ -24,14 +24,14 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { verifyArgs(args, 2); - User user = server.userService.findUserByUsername(args[0]); + User user = server.config.dao.userService.findUserByUsername(args[0]); if(user == null) { LogHelper.error("User %s not found", args[1]); return; } user.setPassword(args[1]); - server.userService.updateUser(user); + server.config.dao.userService.updateUser(user); LogHelper.info("[%s] UUID: %s | New Password: %s", user.username, user.uuid.toString(), args[1]); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java index 966c3389..f19ebe1e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java @@ -11,7 +11,6 @@ public static void registerComponents() { if (!registredComp) { providers.register("authLimiter", AuthLimiterComponent.class); providers.register("commandRemover", CommandRemoverComponent.class); - providers.register("hibernate", HibernateConfiguratorComponent.class); registredComp = true; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/LaunchServerDaoFactory.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/LaunchServerDaoFactory.java deleted file mode 100644 index 9c5b39ef..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/LaunchServerDaoFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package pro.gravit.launchserver.dao; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.dao.impl.DefaultUserDAOImpl; - -public class LaunchServerDaoFactory { - private static final Function defDao = DefaultUserDAOImpl::new; - private static final Map> daos = new ConcurrentHashMap<>(); - - public static void setUserDaoProvider(LaunchServer srv, Function getDao) { - daos.put(srv, getDao); - } - - public static UserDAO createUserDao(LaunchServer srv) - { - return daos.getOrDefault(srv, defDao).apply(srv); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java index 57155f32..d2cef2a9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java @@ -9,8 +9,8 @@ public class UserService { private final UserDAO usersDao; - public UserService(LaunchServer server) { - usersDao = LaunchServerDaoFactory.createUserDao(server); + public UserService(UserDAO usersDAO) { + this.usersDao = usersDAO; } public User findUser(int id) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java new file mode 100644 index 00000000..ab5586cd --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java @@ -0,0 +1,17 @@ +package pro.gravit.launchserver.dao.provider; + +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.dao.UserDAO; +import pro.gravit.launchserver.dao.UserService; +import pro.gravit.utils.ProviderMap; + +public abstract class DaoProvider { + public static ProviderMap providers = new ProviderMap<>("DaoProvider"); + public UserDAO userDAO; + public UserService userService; + public static void registerProviders() + { + providers.register("hibernate", HibernateDaoProvider.class); + } + public abstract void init(LaunchServer server); +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/HibernateConfiguratorComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java similarity index 60% rename from LaunchServer/src/main/java/pro/gravit/launchserver/components/HibernateConfiguratorComponent.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java index 62818726..c000e80e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/HibernateConfiguratorComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java @@ -1,18 +1,17 @@ -package pro.gravit.launchserver.components; - -import java.nio.file.Paths; +package pro.gravit.launchserver.dao.provider; import org.hibernate.cfg.Configuration; - import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.dao.LaunchServerDaoFactory; import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.UserHWID; +import pro.gravit.launchserver.dao.UserService; import pro.gravit.launchserver.dao.impl.HibernateUserDAOImpl; import pro.gravit.launchserver.hibernate.SessionFactoryManager; import pro.gravit.utils.helper.CommonHelper; -public class HibernateConfiguratorComponent extends Component { +import java.nio.file.Paths; + +public class HibernateDaoProvider extends DaoProvider { public String driver; public String url; public String username; @@ -20,9 +19,11 @@ public class HibernateConfiguratorComponent extends Component { public String pool_size; public String hibernateConfig; public boolean parallelHibernateInit; + @Override - public void preInit(LaunchServer launchServer) { - LaunchServerDaoFactory.setUserDaoProvider(launchServer, HibernateUserDAOImpl::new); + public void init(LaunchServer server) { + userDAO = new HibernateUserDAOImpl(server); + userService = new UserService(userDAO); Runnable init = () -> { Configuration cfg = new Configuration() .addAnnotatedClass(User.class) @@ -34,30 +35,11 @@ public void preInit(LaunchServer launchServer) { .setProperty("hibernate.connection.pool_size", pool_size); if(hibernateConfig != null) cfg.configure(Paths.get(hibernateConfig).toFile()); - SessionFactoryManager.forLaunchServer(launchServer).fact = cfg.buildSessionFactory(); + SessionFactoryManager.forLaunchServer(server).fact = cfg.buildSessionFactory(); }; if(parallelHibernateInit) CommonHelper.newThread("Hibernate Thread", true, init); else init.run(); } - - @Override - public void init(LaunchServer launchServer) { - - } - - @Override - public void postInit(LaunchServer launchServer) { - //UserService service = new UserService(); - //List users = service.findAllUsers(); - //User newUser = new User(); - //newUser.username = "VeryTestUser"; - //newUser.setPassword("12345"); - //service.saveUser(newUser); - //for(User u : users) - //{ - // LogHelper.info("Found User %s", u.username); - //} - } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index b39a9a9a..cc07d782 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -10,6 +10,7 @@ import pro.gravit.launchserver.auth.provider.AuthProvider; import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.components.Component; +import pro.gravit.launchserver.dao.provider.DaoProvider; import pro.gravit.utils.UniversalJsonAdapter; public class LaunchServerGsonManager extends GsonManager { @@ -23,5 +24,6 @@ public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(HWIDHandler.class, new UniversalJsonAdapter<>(HWIDHandler.providers)); builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers)); builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers)); + builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers)); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java index b9508345..b5fae77e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java @@ -24,7 +24,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception sendError("Hash invalid"); return; } - User checkUser = server.userService.findUserByUsername(login); + User checkUser = server.config.dao.userService.findUserByUsername(login); if(checkUser != null) { sendError("User already register"); @@ -34,7 +34,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception user.username = login; user.setPassword(password); user.uuid = UUID.randomUUID(); - server.userService.saveUser(user); + server.config.dao.userService.saveUser(user); } @Override public String getType() { From c44208fed3b70fc204764af675478fee78d63710 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 15:27:55 +0700 Subject: [PATCH 37/70] =?UTF-8?q?[FEATURE]=20=D0=A3=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20SessionFactoryManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/impl/HibernateUserDAOImpl.java | 25 +++++++++---------- .../dao/provider/HibernateDaoProvider.java | 6 ++--- .../hibernate/SessionFactoryManager.java | 18 ------------- 3 files changed, 14 insertions(+), 35 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/hibernate/SessionFactoryManager.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java index 80246de1..1c29dfc3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java @@ -9,30 +9,29 @@ import javax.persistence.criteria.Root; import org.hibernate.Session; +import org.hibernate.SessionFactory; import org.hibernate.Transaction; import pro.gravit.launcher.OshiHWID; -import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.UserDAO; import pro.gravit.launchserver.dao.UserHWID; -import pro.gravit.launchserver.hibernate.SessionFactoryManager; public class HibernateUserDAOImpl implements UserDAO { - private final SessionFactoryManager manager; + private final SessionFactory factory; - public HibernateUserDAOImpl(LaunchServer srv) { - manager = SessionFactoryManager.forLaunchServer(srv); + public HibernateUserDAOImpl(SessionFactory factory) { + this.factory = factory; } public User findById(int id) { - try (Session s = manager.fact.openSession()) { + try (Session s = factory.openSession()) { return s.get(User.class, id); } } public User findByUsername(String username) { - EntityManager em = manager.fact.createEntityManager(); + EntityManager em = factory.createEntityManager(); em.getTransaction().begin(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery personCriteria = cb.createQuery(User.class); @@ -44,7 +43,7 @@ public User findByUsername(String username) { } public User findByUUID(UUID uuid) { - EntityManager em = manager.fact.createEntityManager(); + EntityManager em = factory.createEntityManager(); em.getTransaction().begin(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery personCriteria = cb.createQuery(User.class); @@ -57,7 +56,7 @@ public User findByUUID(UUID uuid) { @Override public List findHWID(OshiHWID hwid) { - EntityManager em = manager.fact.createEntityManager(); + EntityManager em = factory.createEntityManager(); em.getTransaction().begin(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery personCriteria = cb.createQuery(UserHWID.class); @@ -77,7 +76,7 @@ public List findHWID(OshiHWID hwid) { } public void save(User user) { - try (Session session = manager.fact.openSession()) { + try (Session session = factory.openSession()) { Transaction tx1 = session.beginTransaction(); session.save(user); tx1.commit(); @@ -85,7 +84,7 @@ public void save(User user) { } public void update(User user) { - try (Session session = manager.fact.openSession()) { + try (Session session = factory.openSession()) { Transaction tx1 = session.beginTransaction(); session.update(user); tx1.commit(); @@ -93,7 +92,7 @@ public void update(User user) { } public void delete(User user) { - try (Session session = manager.fact.openSession()) { + try (Session session = factory.openSession()) { Transaction tx1 = session.beginTransaction(); session.delete(user); tx1.commit(); @@ -102,7 +101,7 @@ public void delete(User user) { @SuppressWarnings("unchecked") public List findAll() { - try (Session s = manager.fact.openSession()) { + try (Session s = factory.openSession()) { return (List) s.createQuery("From User").list(); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java index c000e80e..541f43ed 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java @@ -6,7 +6,6 @@ import pro.gravit.launchserver.dao.UserHWID; import pro.gravit.launchserver.dao.UserService; import pro.gravit.launchserver.dao.impl.HibernateUserDAOImpl; -import pro.gravit.launchserver.hibernate.SessionFactoryManager; import pro.gravit.utils.helper.CommonHelper; import java.nio.file.Paths; @@ -22,8 +21,6 @@ public class HibernateDaoProvider extends DaoProvider { @Override public void init(LaunchServer server) { - userDAO = new HibernateUserDAOImpl(server); - userService = new UserService(userDAO); Runnable init = () -> { Configuration cfg = new Configuration() .addAnnotatedClass(User.class) @@ -35,7 +32,8 @@ public void init(LaunchServer server) { .setProperty("hibernate.connection.pool_size", pool_size); if(hibernateConfig != null) cfg.configure(Paths.get(hibernateConfig).toFile()); - SessionFactoryManager.forLaunchServer(server).fact = cfg.buildSessionFactory(); + userDAO = new HibernateUserDAOImpl(cfg.buildSessionFactory()); + userService = new UserService(userDAO); }; if(parallelHibernateInit) CommonHelper.newThread("Hibernate Thread", true, init); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/hibernate/SessionFactoryManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/hibernate/SessionFactoryManager.java deleted file mode 100644 index 978c8004..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/hibernate/SessionFactoryManager.java +++ /dev/null @@ -1,18 +0,0 @@ -package pro.gravit.launchserver.hibernate; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - -import org.hibernate.SessionFactory; - -import pro.gravit.launchserver.LaunchServer; - -public class SessionFactoryManager { - public SessionFactory fact; - private static final Map sessionFactories = new ConcurrentHashMap<>(); - private static final Function cr = e -> new SessionFactoryManager(); - public static SessionFactoryManager forLaunchServer(LaunchServer srv) { - return sessionFactories.computeIfAbsent(srv, cr); - } -} From 4bb5993ef082d0eec8bcbd9f01cd04912988f9d1 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 15:31:50 +0700 Subject: [PATCH 38/70] =?UTF-8?q?[FIX]=20=D0=98=D0=BD=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20DaoProvider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 6e7be2ce..47446b42 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -214,10 +214,12 @@ public void init() { } permissionsHandler.init(server); hwidHandler.init(); + dao.init(server); if (protectHandler != null) { protectHandler.checkLaunchServerLicense(); } server.registerObject("permissionsHandler", permissionsHandler); + server.registerObject("daoProvider", dao); for (AuthProviderPair pair : auth) { server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler); @@ -570,6 +572,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException } config.permissionsHandler.init(this); config.hwidHandler.init(); + config.dao.init(this); if (config.protectHandler != null) { config.protectHandler.checkLaunchServerLicense(); } From 2d887c86a97f69b0316bd984f97eb8c70ecc2b38 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 15:36:51 +0700 Subject: [PATCH 39/70] =?UTF-8?q?[FEATURE]=20=D0=90=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=B2=D1=85=D0=BE=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/provider/HibernateAuthProvider.java | 5 +++++ .../java/pro/gravit/launchserver/dao/UserService.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index b737f79e..4f878b27 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -7,9 +7,14 @@ import pro.gravit.utils.helper.SecurityHelper; public class HibernateAuthProvider extends AuthProvider { + public boolean autoReg; @Override public AuthProviderResult auth(String login, String password, String ip) throws Exception { User user = srv.config.dao.userService.findUserByUsername(login); + if(user == null && autoReg) + { + user = srv.config.dao.userService.registerNewUser(login, password); + } if(user == null || !user.verifyPassword(password)) { if(user ==null) throw new AuthException("Username incorrect"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java index d2cef2a9..3379ecd2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserService.java @@ -24,6 +24,15 @@ public User findUserByUUID(UUID uuid) { return usersDao.findByUUID(uuid); } + public User registerNewUser(String username, String password) + { + User user = new User(); + user.username = username; + user.setPassword(password); + user.uuid = UUID.randomUUID(); + return user; + } + public void saveUser(User user) { usersDao.save(user); } From 07dd7bcfc86368adb40b71f8a9c6c951bd68a01c Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 16:07:33 +0700 Subject: [PATCH 40/70] [FEATURE] RegLimiterComponent --- .../pro/gravit/launchserver/LaunchServer.java | 6 ++ .../auth/provider/HibernateAuthProvider.java | 11 ++- .../launchserver/components/Component.java | 1 + .../components/RegLimiterComponent.java | 76 +++++++++++++++++++ .../manangers/hook/AuthHookManager.java | 15 ++++ 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 47446b42..ca37d17e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -62,6 +62,7 @@ import pro.gravit.launchserver.binary.ProguardConf; import pro.gravit.launchserver.components.AuthLimiterComponent; import pro.gravit.launchserver.components.Component; +import pro.gravit.launchserver.components.RegLimiterComponent; import pro.gravit.launchserver.config.LaunchServerRuntimeConfig; import pro.gravit.launchserver.dao.UserService; import pro.gravit.launchserver.dao.provider.DaoProvider; @@ -761,6 +762,11 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { authLimiterComponent.rateLimitMilis = 8000; authLimiterComponent.message = "Превышен лимит авторизаций"; newConfig.components.put("authLimiter", authLimiterComponent); + RegLimiterComponent regLimiterComponent = new RegLimiterComponent(); + regLimiterComponent.rateLimit = 3; + regLimiterComponent.rateLimitMilis = 1000 * 60 * 60 * 10; //Блок на 10 часов + regLimiterComponent.message = "Превышен лимит регистраций"; + newConfig.components.put("regLimiter", regLimiterComponent); // Set server address String address; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index 4f878b27..f29ffc63 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -4,6 +4,7 @@ import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.dao.User; +import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.utils.helper.SecurityHelper; public class HibernateAuthProvider extends AuthProvider { @@ -13,7 +14,15 @@ public AuthProviderResult auth(String login, String password, String ip) throws User user = srv.config.dao.userService.findUserByUsername(login); if(user == null && autoReg) { - user = srv.config.dao.userService.registerNewUser(login, password); + AuthHookManager.RegContext context = new AuthHookManager.RegContext(login, password, ip, false); + if(AuthHookManager.registraion.hook(context)) + { + user = srv.config.dao.userService.registerNewUser(login, password); + } + else + { + throw new AuthException("Registration canceled. Try again later"); + } } if(user == null || !user.verifyPassword(password)) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java index f19ebe1e..b4789057 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java @@ -10,6 +10,7 @@ public abstract class Component { public static void registerComponents() { if (!registredComp) { providers.register("authLimiter", AuthLimiterComponent.class); + providers.register("regLimiter", RegLimiterComponent.class); providers.register("commandRemover", CommandRemoverComponent.class); registredComp = true; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java new file mode 100644 index 00000000..2cef6770 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java @@ -0,0 +1,76 @@ +package pro.gravit.launchserver.components; + +import pro.gravit.launcher.NeedGarbageCollection; +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.manangers.hook.AuthHookManager; +import pro.gravit.utils.HookException; +import pro.gravit.utils.HookSet; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class RegLimiterComponent extends Component implements NeedGarbageCollection, AutoCloseable { + + public static final long TIMEOUT = 12 * 60 * 60 * 1000; //12 часов + public transient LaunchServer launchServer; + public int rateLimit; + public int rateLimitMilis; + public String message; + public transient HookSet.Hook hook; + + public transient HashMap map = new HashMap<>(); + public List excludeIps = new ArrayList<>(); + + @Override + public void preInit(LaunchServer launchServer) { + this.launchServer = launchServer; + } + + @Override + public void init(LaunchServer launchServer) { + + } + + @Override + public void postInit(LaunchServer launchServer) { + launchServer.authHookManager.registraion.registerHook(context -> { + if (isLimit(context.ip)) { + throw new HookException(message); + } + return false; + }); + } + + @Override + public void garbageCollection() { + long time = System.currentTimeMillis(); + long max_timeout = Math.max(rateLimitMilis, TIMEOUT); + map.entrySet().removeIf(e -> e.getValue().ts + max_timeout < time); + } + + public boolean isLimit(String ip) { + if (excludeIps.contains(ip)) return false; + if (map.containsKey(ip)) { + AuthLimiterComponent.AuthEntry rate = map.get(ip); + long currenttime = System.currentTimeMillis(); + if (rate.ts + rateLimitMilis < currenttime) rate.value = 0; + if (rate.value >= rateLimit && rateLimit > 0) { + rate.value++; + rate.ts = currenttime; + return true; + } + rate.value++; + rate.ts = currenttime; + return false; + } + map.put(ip, new AuthLimiterComponent.AuthEntry(1, System.currentTimeMillis())); + return false; + } + + @Override + public void close() throws Exception { + if(hook != null) + launchServer.authHookManager.registraion.unregisterHook(hook); + } +} 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 ef181c2f..31a7d451 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 @@ -6,6 +6,7 @@ import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; import pro.gravit.utils.BiHookSet; +import pro.gravit.utils.HookSet; public class AuthHookManager { public BiHookSet preHook = new BiHookSet<>(); @@ -13,4 +14,18 @@ public class AuthHookManager { public BiHookSet checkServerHook = new BiHookSet<>(); public BiHookSet joinServerHook = new BiHookSet<>(); public BiHookSet setProfileHook = new BiHookSet<>(); + public static class RegContext + { + public String login; + public String password; + public String ip; + public boolean trustContext; + public RegContext(String login, String password, String ip, boolean trustContext) { + this.login = login; + this.password = password; + this.ip = ip; + this.trustContext = trustContext; + } + } + public HookSet registraion; } From c11f1660ca8354de2bc8db48ad73c47db8a457f6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 16:11:24 +0700 Subject: [PATCH 41/70] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8?= =?UTF-8?q?=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/auth/provider/HibernateAuthProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index f29ffc63..64c817b4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -15,7 +15,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws if(user == null && autoReg) { AuthHookManager.RegContext context = new AuthHookManager.RegContext(login, password, ip, false); - if(AuthHookManager.registraion.hook(context)) + if(srv.authHookManager.registraion.hook(context)) { user = srv.config.dao.userService.registerNewUser(login, password); } From d737b8f41dc0f988b2e92394d5cb7e19f797ec87 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 16:59:47 +0700 Subject: [PATCH 42/70] =?UTF-8?q?[FEATURE][EXPERIMENTAL]=20WebSocketServic?= =?UTF-8?q?e=20=D1=81=D1=82=D0=B0=D0=BB=20=D0=B4=D0=BE=D1=81=D1=82=D1=83?= =?UTF-8?q?=D0=BF=D0=BD=D1=8B=D0=BC=20=D0=B8=D0=B7=D0=B2=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=B8=D0=B2=D1=8F=D0=B7=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=BA=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?=D0=BC=D1=83=20GsonBuilder,=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D0=B0=20clients?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 2 + .../command/handler/CommandHandler.java | 13 +--- .../command/service/ClientsCommand.java | 44 +++++++++++++ .../manangers/LaunchServerGsonManager.java | 9 +++ .../socket/LauncherNettyServer.java | 9 ++- .../launchserver/socket/WebSocketService.java | 63 +++++++++---------- .../handlers/WebSocketFrameHandler.java | 8 +-- .../socket/response/JsonResponseAdapter.java | 44 ------------- 8 files changed, 95 insertions(+), 97 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index ca37d17e..1fe39c8f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -74,6 +74,7 @@ import pro.gravit.launchserver.manangers.SessionManager; import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.launchserver.manangers.hook.BuildHookManager; +import pro.gravit.launchserver.socket.WebSocketService; import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; import pro.gravit.utils.Version; import pro.gravit.utils.command.CommandHandler; @@ -495,6 +496,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException PermissionsHandler.registerHandlers(); Component.registerComponents(); ProtectHandler.registerHandlers(); + WebSocketService.registerResponses(); //LaunchServer.server = this; // Set command handler diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 88171bca..69c16655 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -32,17 +32,7 @@ import pro.gravit.launchserver.command.install.MultiCommand; import pro.gravit.launchserver.command.modules.LoadModuleCommand; import pro.gravit.launchserver.command.modules.ModulesCommand; -import pro.gravit.launchserver.command.service.ComponentCommand; -import pro.gravit.launchserver.command.service.ConfigCommand; -import pro.gravit.launchserver.command.service.ConfigHelpCommand; -import pro.gravit.launchserver.command.service.ConfigListCommand; -import pro.gravit.launchserver.command.service.GetModulusCommand; -import pro.gravit.launchserver.command.service.GetPermissionsCommand; -import pro.gravit.launchserver.command.service.GivePermissionsCommand; -import pro.gravit.launchserver.command.service.ReloadAllCommand; -import pro.gravit.launchserver.command.service.ReloadCommand; -import pro.gravit.launchserver.command.service.ReloadListCommand; -import pro.gravit.launchserver.command.service.ServerStatusCommand; +import pro.gravit.launchserver.command.service.*; import pro.gravit.utils.command.BaseCommandCategory; import pro.gravit.utils.command.basic.ClearCommand; import pro.gravit.utils.command.basic.DebugCommand; @@ -124,6 +114,7 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand service.registerCommand("component", new ComponentCommand(server)); service.registerCommand("givePermission", new GivePermissionsCommand(server)); service.registerCommand("getPermissions", new GetPermissionsCommand(server)); + service.registerCommand("clients", new ClientsCommand(server)); Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components"); handler.registerCategory(serviceCategory); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java new file mode 100644 index 00000000..afb52e6d --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java @@ -0,0 +1,44 @@ +package pro.gravit.launchserver.command.service; + +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.command.Command; +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.WebSocketService; +import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; +import pro.gravit.utils.helper.IOHelper; +import pro.gravit.utils.helper.LogHelper; + +public class ClientsCommand extends Command { + public ClientsCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return "Show all connected clients"; + } + + @Override + public void invoke(String... args) throws Exception { + WebSocketService service = server.nettyServerSocketHandler.nettyServer.service; + service.channels.forEach((channel -> { + WebSocketFrameHandler frameHandler = channel.pipeline().get(WebSocketFrameHandler.class); + Client client = frameHandler.getClient(); + String ip = IOHelper.getIP(channel.remoteAddress()); + if(!client.isAuth) + LogHelper.info("Channel %s | checkSign %s", ip, client.checkSign ? "true" : "false"); + else + { + LogHelper.info("Client name %s | ip %s", client.username == null ? "null" : client.username, ip); + LogHelper.info("Data: checkSign %s | isSecure %s | auth_id %s", client.checkSign ? "true" : "false", client.isSecure ? "true" : "false", + client.auth_id); + LogHelper.info("Permissions: %s (long %d)", client.permissions == null ? "null" : client.permissions.toString(), client.permissions == null ? 0 : client.permissions.toString()); + } + })); + } +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index cc07d782..3769e19b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -2,7 +2,11 @@ import com.google.gson.GsonBuilder; +import pro.gravit.launcher.hasher.HashedEntry; +import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.managers.GsonManager; +import pro.gravit.launcher.request.JsonResultSerializeAdapter; +import pro.gravit.launcher.request.ResultInterface; import pro.gravit.launchserver.auth.handler.AuthHandler; import pro.gravit.launchserver.auth.hwid.HWIDHandler; import pro.gravit.launchserver.auth.permissions.PermissionsHandler; @@ -11,6 +15,8 @@ import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.dao.provider.DaoProvider; +import pro.gravit.launchserver.socket.WebSocketService; +import pro.gravit.launchserver.socket.response.JsonResponseInterface; import pro.gravit.utils.UniversalJsonAdapter; public class LaunchServerGsonManager extends GsonManager { @@ -25,5 +31,8 @@ public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers)); builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers)); builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers)); + builder.registerTypeAdapter(JsonResponseInterface.class, new UniversalJsonAdapter<>(WebSocketService.providers)); + builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); + builder.registerTypeAdapter(ResultInterface.class, new JsonResultSerializeAdapter()); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java index 0c24db50..87c456dc 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -7,6 +7,7 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoopGroup; +import io.netty.channel.group.DefaultChannelGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; @@ -15,6 +16,7 @@ import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketServerCompressionHandler; import io.netty.handler.logging.LoggingHandler; +import io.netty.util.concurrent.GlobalEventExecutor; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.auth.AuthRequest; import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; @@ -22,13 +24,14 @@ import pro.gravit.launchserver.socket.handlers.NettyIpForwardHandler; import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; import pro.gravit.launchserver.socket.handlers.fileserver.FileServerHandler; +import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.LogHelper; public class LauncherNettyServer implements AutoCloseable { public final ServerBootstrap serverBootstrap; public final EventLoopGroup bossGroup; public final EventLoopGroup workerGroup; - public WebSocketFrameHandler frameHandler = null; + public final WebSocketService service; private static final String WEBSOCKET_PATH = "/api"; public LauncherNettyServer(LaunchServer server) { @@ -36,6 +39,7 @@ public LauncherNettyServer(LaunchServer server) { bossGroup = new NioEventLoopGroup(config.performance.bossThread); workerGroup = new NioEventLoopGroup(config.performance.workerThread); serverBootstrap = new ServerBootstrap(); + service = new WebSocketService(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), server); serverBootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(config.logLevel)) @@ -53,8 +57,7 @@ public void initChannel(NioSocketChannel ch) { pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); if (server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(server.updatesDir, true)); - frameHandler = new WebSocketFrameHandler(context, server); - pipeline.addLast(frameHandler); + pipeline.addLast(new WebSocketFrameHandler(context, server, service)); } }); if (config.proxy != null && config.proxy.enabled) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 8d149f62..a94b870f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -13,19 +13,16 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.group.ChannelGroup; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import pro.gravit.launcher.Launcher; import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent; -import pro.gravit.launcher.hasher.HashedEntry; -import pro.gravit.launcher.hasher.HashedEntryAdapter; -import pro.gravit.launcher.request.JsonResultSerializeAdapter; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.RequestException; import pro.gravit.launcher.request.ResultInterface; import pro.gravit.launcher.request.admin.ProxyRequest; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.socket.response.JsonResponseAdapter; import pro.gravit.launchserver.socket.response.JsonResponseInterface; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse; @@ -40,27 +37,27 @@ import pro.gravit.launchserver.socket.response.update.LauncherResponse; import pro.gravit.launchserver.socket.response.update.UpdateListResponse; import pro.gravit.launchserver.socket.response.update.UpdateResponse; +import pro.gravit.utils.ProviderMap; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; @SuppressWarnings("rawtypes") public class WebSocketService { public final ChannelGroup channels; + public static ProviderMap providers; - public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder gson) { + public WebSocketService(ChannelGroup channels, LaunchServer server) { this.channels = channels; this.server = server; - this.gsonBuiler = gson; - this.gsonBuiler.registerTypeAdapter(JsonResponseInterface.class, new JsonResponseAdapter(this)); - this.gsonBuiler.registerTypeAdapter(ResultInterface.class, new JsonResultSerializeAdapter()); - this.gsonBuiler.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); - this.gson = gsonBuiler.create(); + //this.gsonBuiler.registerTypeAdapter(JsonResponseInterface.class, new JsonResponseAdapter(this)); + //this.gsonBuiler.registerTypeAdapter(ResultInterface.class, new JsonResultSerializeAdapter()); + //this.gsonBuiler.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); + this.gson = Launcher.gsonManager.gson; } private final LaunchServer server; private static final HashMap responses = new HashMap<>(); private final Gson gson; - private final GsonBuilder gsonBuiler; public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) { String request = frame.text(); @@ -150,34 +147,30 @@ public Class getResponseClass(String type) { return responses.get(type); } - public void registerResponse(String key, Class responseInterfaceClass) { - responses.put(key, responseInterfaceClass); - } - public void registerClient(Channel channel) { channels.add(channel); } - public void registerResponses() { - registerResponse("auth", AuthResponse.class); - registerResponse("checkServer", CheckServerResponse.class); - registerResponse("joinServer", JoinServerResponse.class); - registerResponse("profiles", ProfilesResponse.class); - registerResponse("launcher", LauncherResponse.class); - registerResponse("updateList", UpdateListResponse.class); - registerResponse("cmdExec", ExecCommandResponse.class); - registerResponse("setProfile", SetProfileResponse.class); - registerResponse("addLogListener", AddLogListenerResponse.class); - registerResponse("update", UpdateResponse.class); - registerResponse("restoreSession", RestoreSessionResponse.class); - registerResponse("batchProfileByUsername", BatchProfileByUsername.class); - registerResponse("profileByUsername", ProfileByUsername.class); - registerResponse("profileByUUID", ProfileByUUIDResponse.class); - registerResponse("getSecureToken", GetSecureTokenResponse.class); - registerResponse("verifySecureToken", VerifySecureTokenResponse.class); - registerResponse("getAvailabilityAuth", GetAvailabilityAuthResponse.class); - registerResponse("proxy", ProxyCommandResponse.class); - registerResponse("register", RegisterResponse.class); + public static void registerResponses() { + providers.register("auth", AuthResponse.class); + providers.register("checkServer", CheckServerResponse.class); + providers.register("joinServer", JoinServerResponse.class); + providers.register("profiles", ProfilesResponse.class); + providers.register("launcher", LauncherResponse.class); + providers.register("updateList", UpdateListResponse.class); + providers.register("cmdExec", ExecCommandResponse.class); + providers.register("setProfile", SetProfileResponse.class); + providers.register("addLogListener", AddLogListenerResponse.class); + providers.register("update", UpdateResponse.class); + providers.register("restoreSession", RestoreSessionResponse.class); + providers.register("batchProfileByUsername", BatchProfileByUsername.class); + providers.register("profileByUsername", ProfileByUsername.class); + providers.register("profileByUUID", ProfileByUUIDResponse.class); + providers.register("getSecureToken", GetSecureTokenResponse.class); + providers.register("verifySecureToken", VerifySecureTokenResponse.class); + providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class); + providers.register("proxy", ProxyCommandResponse.class); + providers.register("register", RegisterResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { 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 b27c9280..2e5e1ed6 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 @@ -23,15 +23,13 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler { public final LaunchServer srv; - public static GsonBuilder builder = CommonHelper.newBuilder(); public final WebSocketService service; public NettyConnectContext context; - public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv) { + public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) { this.context = context; this.srv = srv; - service = new WebSocketService(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), srv, builder); - service.registerResponses(); + this.service = service; } private Client client; @@ -43,6 +41,8 @@ public void setClient(Client client) { this.client = client; } + public Client getClient() { return client; } + @Override public void channelActive(ChannelHandlerContext ctx) { LogHelper.dev("New client %s", IOHelper.getIP(ctx.channel().remoteAddress())); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java deleted file mode 100644 index 0ebc0327..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -package pro.gravit.launchserver.socket.response; - -import java.lang.reflect.Type; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import pro.gravit.launchserver.socket.WebSocketService; - -public class JsonResponseAdapter implements JsonSerializer, JsonDeserializer { - private final WebSocketService service; - private static final String PROP_NAME = "type"; - - public JsonResponseAdapter(WebSocketService service) { - this.service = service; - } - - @SuppressWarnings("unchecked") - @Override - public JsonResponseInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = service.getResponseClass(typename); - - - return (JsonResponseInterface) context.deserialize(json, cls); - } - - @Override - public JsonElement serialize(JsonResponseInterface src, Type typeOfSrc, JsonSerializationContext context) { - // note : won't work, you must delegate this - JsonObject jo = context.serialize(src).getAsJsonObject(); - - String classPath = src.getType(); - jo.add(PROP_NAME, new JsonPrimitive(classPath)); - - return jo; - } -} From 6db16ac0f32fea5e80447b594b00df663d923da7 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:01:05 +0700 Subject: [PATCH 43/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB=D1=8F=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/command/basic/TestCommand.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java index 917b9f9b..a9d37cc7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java @@ -34,8 +34,5 @@ public void invoke(String... args) throws Exception { if (args[0].equals("stop")) { handler.close(); } - if (args[0].equals("eventAll")) { - handler.nettyServer.frameHandler.service.sendObjectAll(new PingEvent()); - } } } From 37b679bbd6b1d42b79be3f6b4d413c1cdc494fe1 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:08:20 +0700 Subject: [PATCH 44/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20NPE=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 3 ++- .../gravit/launchserver/manangers/hook/AuthHookManager.java | 2 +- .../java/pro/gravit/launchserver/socket/WebSocketService.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 1fe39c8f..6db964b0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -575,7 +575,8 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException } config.permissionsHandler.init(this); config.hwidHandler.init(); - config.dao.init(this); + if(config.dao != null) + config.dao.init(this); if (config.protectHandler != null) { config.protectHandler.checkLaunchServerLicense(); } 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 31a7d451..739d4eda 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 @@ -27,5 +27,5 @@ public RegContext(String login, String password, String ip, boolean trustContext this.trustContext = trustContext; } } - public HookSet registraion; + public HookSet registraion = new HookSet<>(); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index a94b870f..41d1dc7b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -44,7 +44,7 @@ @SuppressWarnings("rawtypes") public class WebSocketService { public final ChannelGroup channels; - public static ProviderMap providers; + public static ProviderMap providers = new ProviderMap<>(); public WebSocketService(ChannelGroup channels, LaunchServer server) { this.channels = channels; From c6782d86a762bdf59fe88f0e7d7b286fd59f4526 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:13:59 +0700 Subject: [PATCH 45/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20=D0=B2=20ClientsCommand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/command/service/ClientsCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java index afb52e6d..b373e7fd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java @@ -35,9 +35,9 @@ public void invoke(String... args) throws Exception { else { LogHelper.info("Client name %s | ip %s", client.username == null ? "null" : client.username, ip); - LogHelper.info("Data: checkSign %s | isSecure %s | auth_id %s", client.checkSign ? "true" : "false", client.isSecure ? "true" : "false", + LogHelper.subInfo("Data: checkSign %s | isSecure %s | auth_id %s", client.checkSign ? "true" : "false", client.isSecure ? "true" : "false", client.auth_id); - LogHelper.info("Permissions: %s (long %d)", client.permissions == null ? "null" : client.permissions.toString(), client.permissions == null ? 0 : client.permissions.toString()); + LogHelper.subInfo("Permissions: %s (long %d)", client.permissions == null ? "null" : client.permissions.toString(), client.permissions == null ? 0 : client.permissions.toLong()); } })); } From 25ccda7ae23b794044fb5070f683cfec9db814bc Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:21:19 +0700 Subject: [PATCH 46/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B5=D0=BB=D1=8B?= =?UTF-8?q?=D1=85=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/socket/response/auth/AuthResponse.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index c5f0d8e2..d732f2f3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -104,6 +104,10 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti clientData.permissions = aresult.permissions; clientData.auth_id = auth_id; clientData.updateAuth(server); + if(result.playerProfile != null) + clientData.username = result.playerProfile.username; + else + clientData.username = login; result.accessToken = aresult.accessToken; result.permissions = clientData.permissions; if (authType == ConnectTypes.BOT && !clientData.permissions.canBot) { From 955020005a95ce458d7040f26419f448da2bb3e0 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:41:56 +0700 Subject: [PATCH 47/70] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D1=91?= =?UTF-8?q?=D0=BD=20EventManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launcher/events/ControlEvent.java | 9 +- .../pro/gravit/launcher/events/PingEvent.java | 13 +-- .../gravit/launcher/events/SignalEvent.java | 12 +-- .../events/request/AuthRequestEvent.java | 9 +- .../BatchProfileByUsernameRequestEvent.java | 9 +- .../request/CheckServerRequestEvent.java | 9 +- .../events/request/ErrorRequestEvent.java | 9 +- .../request/JoinServerRequestEvent.java | 9 +- .../events/request/LauncherRequestEvent.java | 9 +- .../request/ProfileByUUIDRequestEvent.java | 9 +- .../ProfileByUsernameRequestEvent.java | 9 +- .../events/request/ProfilesRequestEvent.java | 9 +- .../request/SetProfileRequestEvent.java | 9 +- .../request/UpdateListRequestEvent.java | 9 +- .../pro/gravit/utils/event/EventHandler.java | 8 -- .../gravit/utils/event/EventInterface.java | 7 -- .../pro/gravit/utils/event/EventManager.java | 102 ------------------ 17 files changed, 23 insertions(+), 227 deletions(-) delete mode 100644 LauncherCore/src/main/java/pro/gravit/utils/event/EventHandler.java delete mode 100644 LauncherCore/src/main/java/pro/gravit/utils/event/EventInterface.java delete mode 100644 LauncherCore/src/main/java/pro/gravit/utils/event/EventManager.java diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java index 2fae8ce7..419619c0 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java @@ -2,10 +2,8 @@ import java.util.UUID; -import pro.gravit.utils.event.EventInterface; - //Набор стандартных событий -public class ControlEvent implements EventInterface { +public class ControlEvent { private static final UUID uuid = UUID.fromString("f1051a64-0cd0-4ed8-8430-d856a196e91f"); public enum ControlCommand { @@ -17,9 +15,4 @@ public ControlEvent(ControlCommand signal) { } public ControlCommand signal; - - @Override - public UUID getUUID() { - return uuid; - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java index da0b3b99..6a26ea14 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java @@ -1,17 +1,6 @@ package pro.gravit.launcher.events; -import java.util.UUID; - -import pro.gravit.utils.event.EventInterface; - //Пустое событие //Все обработчики обязаны его игнорировать -public final class PingEvent implements EventInterface { - private static final UUID uuid = UUID.fromString("7c8be7e7-82ce-4c99-84cd-ee8fcce1b509"); - - @Override - public UUID getUUID() { - - return uuid; - } +public final class PingEvent { } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java index b0c3c0d3..9f3d026e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java @@ -1,20 +1,10 @@ package pro.gravit.launcher.events; -import java.util.UUID; - -import pro.gravit.utils.event.EventInterface; - //Используется, что бы послать короткое сообщение, которое вмещается в int -public class SignalEvent implements EventInterface { - private static final UUID uuid = UUID.fromString("edc3afa1-2726-4da3-95c6-7e6994b981e1"); +public class SignalEvent { public int signal; public SignalEvent(int signal) { this.signal = signal; } - - @Override - public UUID getUUID() { - return uuid; - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java index 7665c4f2..4b0a09d4 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/AuthRequestEvent.java @@ -6,10 +6,8 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; -import pro.gravit.utils.event.EventInterface; -public class AuthRequestEvent extends RequestEvent implements EventInterface { - private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74"); +public class AuthRequestEvent extends RequestEvent { public AuthRequestEvent() { } @@ -46,11 +44,6 @@ public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfi this.session = session; } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "auth"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java index 21b90e60..2be4e9c7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java @@ -5,10 +5,8 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; -import pro.gravit.utils.event.EventInterface; -public class BatchProfileByUsernameRequestEvent extends RequestEvent implements EventInterface { - private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3"); +public class BatchProfileByUsernameRequestEvent extends RequestEvent { @LauncherNetworkAPI public String error; @LauncherNetworkAPI @@ -21,11 +19,6 @@ public BatchProfileByUsernameRequestEvent(PlayerProfile[] profiles) { public BatchProfileByUsernameRequestEvent() { } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "batchProfileByUsername"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CheckServerRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CheckServerRequestEvent.java index f3c62f77..58492013 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CheckServerRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CheckServerRequestEvent.java @@ -5,9 +5,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; -import pro.gravit.utils.event.EventInterface; -public class CheckServerRequestEvent extends RequestEvent implements EventInterface { + +public class CheckServerRequestEvent extends RequestEvent { private static final UUID _uuid = UUID.fromString("8801d07c-51ba-4059-b61d-fe1f1510b28a"); @LauncherNetworkAPI public UUID uuid; @@ -21,11 +21,6 @@ public CheckServerRequestEvent(PlayerProfile playerProfile) { public CheckServerRequestEvent() { } - @Override - public UUID getUUID() { - return _uuid; - } - @Override public String getType() { return "checkServer"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ErrorRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ErrorRequestEvent.java index bc022eb0..b97e3c28 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ErrorRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ErrorRequestEvent.java @@ -4,9 +4,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.utils.event.EventInterface; -public class ErrorRequestEvent extends RequestEvent implements EventInterface { + +public class ErrorRequestEvent extends RequestEvent { public static UUID uuid = UUID.fromString("0af22bc7-aa01-4881-bdbb-dc62b3cdac96"); public ErrorRequestEvent(String error) { @@ -20,9 +20,4 @@ public ErrorRequestEvent(String error) { public String getType() { return "error"; } - - @Override - public UUID getUUID() { - return null; - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java index 788db95f..15060252 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java @@ -4,9 +4,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.utils.event.EventInterface; -public class JoinServerRequestEvent extends RequestEvent implements EventInterface { + +public class JoinServerRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("2a12e7b5-3f4a-4891-a2f9-ea141c8e1995"); public JoinServerRequestEvent(boolean allow) { @@ -16,11 +16,6 @@ public JoinServerRequestEvent(boolean allow) { @LauncherNetworkAPI public boolean allow; - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "joinServer"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LauncherRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LauncherRequestEvent.java index 2118e74f..3548aa0e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LauncherRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LauncherRequestEvent.java @@ -4,9 +4,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.utils.event.EventInterface; -public class LauncherRequestEvent extends RequestEvent implements EventInterface { + +public class LauncherRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("d54cc12a-4f59-4f23-9b10-f527fdd2e38f"); @LauncherNetworkAPI public String url; @@ -33,11 +33,6 @@ public LauncherRequestEvent(byte[] binary, byte[] digest) { //Legacy support con this.digest = digest; } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "launcher"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java index 303392f3..f945129c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java @@ -5,9 +5,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; -import pro.gravit.utils.event.EventInterface; -public class ProfileByUUIDRequestEvent extends RequestEvent implements EventInterface { + +public class ProfileByUUIDRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0"); @LauncherNetworkAPI public String error; @@ -21,11 +21,6 @@ public ProfileByUUIDRequestEvent(PlayerProfile playerProfile) { public ProfileByUUIDRequestEvent() { } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "profileByUUID"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java index 2e8981bc..18c80347 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java @@ -5,9 +5,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.PlayerProfile; -import pro.gravit.utils.event.EventInterface; -public class ProfileByUsernameRequestEvent extends RequestEvent implements EventInterface { + +public class ProfileByUsernameRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1"); @LauncherNetworkAPI public String error; @@ -18,11 +18,6 @@ public ProfileByUsernameRequestEvent(PlayerProfile playerProfile) { this.playerProfile = playerProfile; } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "profileByUsername"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfilesRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfilesRequestEvent.java index 3234103e..dedd1581 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfilesRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfilesRequestEvent.java @@ -6,9 +6,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.ClientProfile; -import pro.gravit.utils.event.EventInterface; -public class ProfilesRequestEvent extends RequestEvent implements EventInterface { + +public class ProfilesRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1"); @LauncherNetworkAPI public List profiles; @@ -20,11 +20,6 @@ public ProfilesRequestEvent(List profiles) { public ProfilesRequestEvent() { } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "profiles"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java index 27426406..9cfe2104 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java @@ -5,9 +5,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.profiles.ClientProfile; -import pro.gravit.utils.event.EventInterface; -public class SetProfileRequestEvent extends RequestEvent implements EventInterface { + +public class SetProfileRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("08c0de9e-4364-4152-9066-8354a3a48541"); @LauncherNetworkAPI public ClientProfile newProfile; @@ -20,9 +20,4 @@ public SetProfileRequestEvent(ClientProfile newProfile) { public String getType() { return "setProfile"; } - - @Override - public UUID getUUID() { - return uuid; - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateListRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateListRequestEvent.java index 20f159bb..5f99c6af 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateListRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateListRequestEvent.java @@ -5,9 +5,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.utils.event.EventInterface; -public class UpdateListRequestEvent extends RequestEvent implements EventInterface { + +public class UpdateListRequestEvent extends RequestEvent { private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b"); @LauncherNetworkAPI public final HashSet dirs; @@ -16,11 +16,6 @@ public UpdateListRequestEvent(HashSet dirs) { this.dirs = dirs; } - @Override - public UUID getUUID() { - return uuid; - } - @Override public String getType() { return "updateList"; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/event/EventHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/event/EventHandler.java deleted file mode 100644 index eaef7e9e..00000000 --- a/LauncherCore/src/main/java/pro/gravit/utils/event/EventHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package pro.gravit.utils.event; - -import java.util.UUID; - -@FunctionalInterface -public interface EventHandler { - void run(UUID uuid, T event); -} diff --git a/LauncherCore/src/main/java/pro/gravit/utils/event/EventInterface.java b/LauncherCore/src/main/java/pro/gravit/utils/event/EventInterface.java deleted file mode 100644 index 35522ed9..00000000 --- a/LauncherCore/src/main/java/pro/gravit/utils/event/EventInterface.java +++ /dev/null @@ -1,7 +0,0 @@ -package pro.gravit.utils.event; - -import java.util.UUID; - -public interface EventInterface { - UUID getUUID(); -} diff --git a/LauncherCore/src/main/java/pro/gravit/utils/event/EventManager.java b/LauncherCore/src/main/java/pro/gravit/utils/event/EventManager.java deleted file mode 100644 index 4de60a27..00000000 --- a/LauncherCore/src/main/java/pro/gravit/utils/event/EventManager.java +++ /dev/null @@ -1,102 +0,0 @@ -package pro.gravit.utils.event; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import pro.gravit.utils.helper.CommonHelper; -import pro.gravit.utils.helper.LogHelper; - -public class EventManager { - public static final int QUEUE_MAX_SIZE = 2048; - public static final int INITIAL_HANDLERS_SIZE = 16; - - public class Entry { - public Entry(EventHandler func, UUID[] events) { - this.func = func; - this.events = events; - } - - EventHandler func; - UUID[] events; - } - - public class QueueEntry { - public QueueEntry(EventInterface event, UUID key) { - this.event = event; - this.key = key; - } - - EventInterface event; - UUID key; - } - - private EventExecutor executor; - private Thread executorThread; - private AtomicBoolean isStarted = new AtomicBoolean(false); - - public synchronized void start() { - if (isStarted.get()) return; - executor = new EventExecutor(); - isStarted.set(true); - executorThread = CommonHelper.newThread("EventExecutor", true, executor); - executorThread.start(); - } - - public synchronized void stop() { - if (!isStarted.get()) return; - executorThread.interrupt(); - try { - executorThread.join(); - } catch (InterruptedException ignored) { - } - } - - public ArrayList handlers = new ArrayList<>(INITIAL_HANDLERS_SIZE); - public BlockingQueue queue = new LinkedBlockingQueue<>(QUEUE_MAX_SIZE); //Максимальный размер очереди - - public int registerHandler(EventHandler func, UUID[] events) { - if (isStarted.get()) - throw new IllegalThreadStateException("It is forbidden to add a handler during thread operation."); - Arrays.sort(events); - handlers.add(new Entry(func, events)); - return handlers.size(); - } - - public void unregisterHandler(EventHandler func) { - if (isStarted.get()) - throw new IllegalThreadStateException("It is forbidden to remove a handler during thread operation."); - handlers.removeIf(e -> e.func.equals(func)); - } - - public void sendEvent(UUID key, EventInterface event, boolean blocking) { - if (blocking) process(key, event); - else queue.add(new QueueEntry(event, key)); - } - - public void process(UUID key, EventInterface event) { - for (Entry e : handlers) { - if (Arrays.binarySearch(e.events, key) >= 0) e.func.run(key, event); - } - } - - public class EventExecutor implements Runnable { - public boolean enable = true; - - @Override - public void run() { - while (enable && !Thread.interrupted()) { - try { - QueueEntry e = queue.take(); - process(e.key, e.event); - } catch (InterruptedException e) { - LogHelper.error(e); - } - Thread.yield(); - } - } - } -} From b39c640cd6d9be31ca43b7f76f8f4bbef0691b33 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 17:46:49 +0700 Subject: [PATCH 48/70] =?UTF-8?q?[REFRACTOR]=20=D0=9F=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20WebSocket=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B2/=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BF=D0=BE=D0=BD?= =?UTF-8?q?=D1=8F=D1=82=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manangers/LaunchServerGsonManager.java | 8 +++--- .../launchserver/socket/WebSocketService.java | 25 +++++++++---------- .../socket/response/SimpleResponse.java | 3 +-- ...face.java => WebSocketServerResponse.java} | 4 +-- .../response/admin/ProxyCommandResponse.java | 4 +-- .../console/LogListenerCommand.java | 4 +-- .../console/admin/LogListenerCommand.java | 4 +-- .../gravit/launcher/events/RequestEvent.java | 4 +-- .../launcher/events/request/LogEvent.java | 4 +-- .../request/JsonResultSerializeAdapter.java | 4 +-- .../gravit/launcher/request/PingRequest.java | 4 +-- .../pro/gravit/launcher/request/Request.java | 4 +-- ...sultInterface.java => WebSocketEvent.java} | 2 +- .../request/admin/ExecCommandRequest.java | 4 +-- .../launcher/request/admin/ProxyRequest.java | 10 ++++---- .../launcher/request/auth/AuthRequest.java | 4 +-- .../request/auth/CheckServerRequest.java | 4 +-- .../auth/GetAvailabilityAuthRequest.java | 4 +-- .../request/auth/JoinServerRequest.java | 4 +-- .../request/auth/RestoreSessionRequest.java | 4 +-- .../request/auth/SetProfileRequest.java | 4 +-- .../request/update/LauncherRequest.java | 4 +-- .../request/update/ProfilesRequest.java | 4 +-- .../request/update/UpdateListRequest.java | 4 +-- .../request/update/UpdateRequest.java | 4 +-- .../uuid/BatchProfileByUsernameRequest.java | 4 +-- .../request/uuid/ProfileByUUIDRequest.java | 4 +-- .../uuid/ProfileByUsernameRequest.java | 4 +-- .../websockets/ClientWebSocketService.java | 24 +++++++++--------- .../websockets/JsonRequestAdapter.java | 10 ++++---- .../request/websockets/JsonResultAdapter.java | 12 ++++----- .../StandartClientWebSocketService.java | 20 +++++++-------- .../request/websockets/WaitEventHandler.java | 6 ++--- ...stInterface.java => WebSocketRequest.java} | 2 +- 34 files changed, 106 insertions(+), 108 deletions(-) rename LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/{JsonResponseInterface.java => WebSocketServerResponse.java} (65%) rename LauncherAPI/src/main/java/pro/gravit/launcher/request/{ResultInterface.java => WebSocketEvent.java} (63%) rename LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/{RequestInterface.java => WebSocketRequest.java} (66%) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index 3769e19b..e6caf5ae 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -6,7 +6,7 @@ import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.managers.GsonManager; import pro.gravit.launcher.request.JsonResultSerializeAdapter; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.launchserver.auth.handler.AuthHandler; import pro.gravit.launchserver.auth.hwid.HWIDHandler; import pro.gravit.launchserver.auth.permissions.PermissionsHandler; @@ -16,7 +16,7 @@ import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.dao.provider.DaoProvider; import pro.gravit.launchserver.socket.WebSocketService; -import pro.gravit.launchserver.socket.response.JsonResponseInterface; +import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.utils.UniversalJsonAdapter; public class LaunchServerGsonManager extends GsonManager { @@ -31,8 +31,8 @@ public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers)); builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers)); builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers)); - builder.registerTypeAdapter(JsonResponseInterface.class, new UniversalJsonAdapter<>(WebSocketService.providers)); + builder.registerTypeAdapter(WebSocketServerResponse.class, new UniversalJsonAdapter<>(WebSocketService.providers)); builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); - builder.registerTypeAdapter(ResultInterface.class, new JsonResultSerializeAdapter()); + builder.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter()); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 41d1dc7b..beac50fd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -6,7 +6,6 @@ import java.util.UUID; import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; @@ -20,10 +19,10 @@ import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.RequestException; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.launcher.request.admin.ProxyRequest; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.socket.response.JsonResponseInterface; +import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse; import pro.gravit.launchserver.socket.response.admin.ExecCommandResponse; @@ -44,13 +43,13 @@ @SuppressWarnings("rawtypes") public class WebSocketService { public final ChannelGroup channels; - public static ProviderMap providers = new ProviderMap<>(); + public static ProviderMap providers = new ProviderMap<>(); public WebSocketService(ChannelGroup channels, LaunchServer server) { this.channels = channels; this.server = server; - //this.gsonBuiler.registerTypeAdapter(JsonResponseInterface.class, new JsonResponseAdapter(this)); - //this.gsonBuiler.registerTypeAdapter(ResultInterface.class, new JsonResultSerializeAdapter()); + //this.gsonBuiler.registerTypeAdapter(WebSocketServerResponse.class, new JsonResponseAdapter(this)); + //this.gsonBuiler.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter()); //this.gsonBuiler.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); this.gson = Launcher.gsonManager.gson; } @@ -61,7 +60,7 @@ public WebSocketService(ChannelGroup channels, LaunchServer server) { public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) { String request = frame.text(); - JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class); + WebSocketServerResponse response = gson.fromJson(request, WebSocketServerResponse.class); if (server.config.netty.proxy.enabled) { if (server.config.netty.proxy.requests.contains(response.getType())) { @@ -83,7 +82,7 @@ public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client } proxyRequest.isCheckSign = client.checkSign; try { - ResultInterface result = proxyRequest.request(); + WebSocketEvent result = proxyRequest.request(); if (result instanceof AuthRequestEvent) { LogHelper.debug("Client auth params get successful"); AuthRequestEvent authRequestEvent = (AuthRequestEvent) result; @@ -117,7 +116,7 @@ public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client process(ctx, response, client, ip); } - void process(ChannelHandlerContext ctx, JsonResponseInterface response, Client client, String ip) { + void process(ChannelHandlerContext ctx, WebSocketServerResponse response, Client client, String ip) { if (response instanceof SimpleResponse) { SimpleResponse simpleResponse = (SimpleResponse) response; simpleResponse.server = server; @@ -174,7 +173,7 @@ public static void registerResponses() { } public void sendObject(ChannelHandlerContext ctx, Object obj) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, ResultInterface.class))); + ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))); } public void sendObject(ChannelHandlerContext ctx, Object obj, Type type) { @@ -183,7 +182,7 @@ public void sendObject(ChannelHandlerContext ctx, Object obj, Type type) { public void sendObjectAll(Object obj) { for (Channel ch : channels) { - ch.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, ResultInterface.class))); + ch.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))); } } @@ -194,7 +193,7 @@ public void sendObjectAll(Object obj, Type type) { } public void sendObjectAndClose(ChannelHandlerContext ctx, Object obj) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, ResultInterface.class))).addListener(ChannelFutureListener.CLOSE); + ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))).addListener(ChannelFutureListener.CLOSE); } public void sendObjectAndClose(ChannelHandlerContext ctx, Object obj, Type type) { @@ -205,7 +204,7 @@ public void sendEvent(EventResult obj) { channels.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj))); } - public static class EventResult implements ResultInterface { + public static class EventResult implements WebSocketEvent { public EventResult() { } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java index 783daaaf..34998f7a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/SimpleResponse.java @@ -6,10 +6,9 @@ import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.WebSocketService; -public abstract class SimpleResponse implements JsonResponseInterface { +public abstract class SimpleResponse implements WebSocketServerResponse { public UUID requestUUID; public transient LaunchServer server; public transient WebSocketService service; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/WebSocketServerResponse.java similarity index 65% rename from LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java rename to LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/WebSocketServerResponse.java index 1e44ba4e..d4a769d8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/JsonResponseInterface.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/WebSocketServerResponse.java @@ -1,10 +1,10 @@ package pro.gravit.launchserver.socket.response; import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launchserver.socket.Client; -public interface JsonResponseInterface extends RequestInterface { +public interface WebSocketServerResponse extends WebSocketRequest { String getType(); void execute(ChannelHandlerContext ctx, Client client) throws Exception; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java index 356fd471..16e53c88 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/ProxyCommandResponse.java @@ -2,11 +2,11 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.JsonResponseInterface; +import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.launchserver.socket.response.SimpleResponse; public class ProxyCommandResponse extends SimpleResponse { - public JsonResponseInterface response; + public WebSocketServerResponse response; public long session; public boolean isCheckSign; diff --git a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java index dab6a1d7..4de6d4ee 100644 --- a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java +++ b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java @@ -3,12 +3,12 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.LogEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.command.Command; import pro.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements RequestInterface { + public class LogListenerRequest implements WebSocketRequest { @LauncherNetworkAPI public LogHelper.OutputTypes outputType; diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java index 04bf5f4e..8610fa07 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java @@ -3,12 +3,12 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.LogEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.command.Command; import pro.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements RequestInterface { + public class LogListenerRequest implements WebSocketRequest { @LauncherNetworkAPI public LogHelper.OutputTypes outputType; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/RequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/RequestEvent.java index 6ac8df92..a8ea23e5 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/RequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/RequestEvent.java @@ -2,8 +2,8 @@ import java.util.UUID; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; -public abstract class RequestEvent implements ResultInterface { +public abstract class RequestEvent implements WebSocketEvent { public UUID requestUUID; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java index 065e31f2..db2f6f35 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java @@ -1,9 +1,9 @@ package pro.gravit.launcher.events.request; import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; -public class LogEvent implements ResultInterface { +public class LogEvent implements WebSocketEvent { @Override public String getType() { return "log"; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/JsonResultSerializeAdapter.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/JsonResultSerializeAdapter.java index 073d5361..5ca49743 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/JsonResultSerializeAdapter.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/JsonResultSerializeAdapter.java @@ -8,11 +8,11 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -public class JsonResultSerializeAdapter implements JsonSerializer { +public class JsonResultSerializeAdapter implements JsonSerializer { private static final String PROP_NAME = "type"; @Override - public JsonElement serialize(ResultInterface src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WebSocketEvent src, Type typeOfSrc, JsonSerializationContext context) { // note : won't work, you must delegate this JsonObject jo = context.serialize(src).getAsJsonObject(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java index a84a0bfc..cabe6414 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java @@ -2,10 +2,10 @@ import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; -public final class PingRequest extends Request { +public final class PingRequest extends Request { @Override - protected ResultInterface requestDo(StandartClientWebSocketService service) throws Exception { + protected WebSocketEvent requestDo(StandartClientWebSocketService service) throws Exception { return null; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java index b649ffeb..856ed513 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java @@ -6,11 +6,11 @@ import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherAPI; import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; import pro.gravit.utils.helper.SecurityHelper; -public abstract class Request implements RequestInterface { +public abstract class Request implements WebSocketRequest { private static long session = SecurityHelper.secureRandom.nextLong(); @LauncherNetworkAPI public UUID requestUUID = UUID.randomUUID(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/ResultInterface.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java similarity index 63% rename from LauncherAPI/src/main/java/pro/gravit/launcher/request/ResultInterface.java rename to LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java index 6a2f8c3d..a4b9cfef 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/ResultInterface.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java @@ -1,5 +1,5 @@ package pro.gravit.launcher.request; -public interface ResultInterface { +public interface WebSocketEvent { String getType(); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java index 21f6bc90..c3345f0b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java @@ -3,9 +3,9 @@ import pro.gravit.launcher.LauncherAPI; import pro.gravit.launcher.events.request.ExecCommandRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public class ExecCommandRequest extends Request implements RequestInterface { +public class ExecCommandRequest extends Request implements WebSocketRequest { @LauncherAPI public String cmd; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ProxyRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ProxyRequest.java index 34b8e004..ecbc8784 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ProxyRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ProxyRequest.java @@ -1,15 +1,15 @@ package pro.gravit.launcher.request.admin; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.ResultInterface; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.WebSocketEvent; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public class ProxyRequest extends Request implements RequestInterface { - public RequestInterface response; +public class ProxyRequest extends Request implements WebSocketRequest { + public WebSocketRequest response; public long session; public boolean isCheckSign; - public ProxyRequest(RequestInterface response, long session) { + public ProxyRequest(WebSocketRequest response, long session) { this.response = response; this.session = session; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index 2307c682..9c26720e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -5,10 +5,10 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.VerifyHelper; -public final class AuthRequest extends Request implements RequestInterface { +public final class AuthRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI private final String login; @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java index 3cb20590..6c918f4b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java @@ -4,10 +4,10 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.CheckServerRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.VerifyHelper; -public final class CheckServerRequest extends Request implements RequestInterface { +public final class CheckServerRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI private final String username; @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java index 2be24ef0..aad6870b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java @@ -2,9 +2,9 @@ import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public class GetAvailabilityAuthRequest extends Request implements RequestInterface { +public class GetAvailabilityAuthRequest extends Request implements WebSocketRequest { @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java index f963b9bf..6e2ca2f4 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java @@ -4,11 +4,11 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.JoinServerRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.VerifyHelper; -public final class JoinServerRequest extends Request implements RequestInterface { +public final class JoinServerRequest extends Request implements WebSocketRequest { // Instance @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java index 36c6b615..5e15bfbc 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java @@ -3,9 +3,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public class RestoreSessionRequest extends Request implements RequestInterface { +public class RestoreSessionRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI public long session; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java index 461a0eb3..0cc7d943 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java @@ -4,9 +4,9 @@ import pro.gravit.launcher.events.request.SetProfileRequestEvent; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public class SetProfileRequest extends Request implements RequestInterface { +public class SetProfileRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI public String client; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java index b33f1db4..4b7ac5ea 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java @@ -11,14 +11,14 @@ import pro.gravit.launcher.downloader.ListDownloader; import pro.gravit.launcher.events.request.LauncherRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; -public final class LauncherRequest extends Request implements RequestInterface { +public final class LauncherRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI public byte[] digest; @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/ProfilesRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/ProfilesRequest.java index c02d667c..06f28ebc 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/ProfilesRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/ProfilesRequest.java @@ -2,9 +2,9 @@ import pro.gravit.launcher.events.request.ProfilesRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public final class ProfilesRequest extends Request implements RequestInterface { +public final class ProfilesRequest extends Request implements WebSocketRequest { @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateListRequest.java index 3641439d..463b58ed 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateListRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateListRequest.java @@ -2,9 +2,9 @@ import pro.gravit.launcher.events.request.UpdateListRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public final class UpdateListRequest extends Request implements RequestInterface { +public final class UpdateListRequest extends Request implements WebSocketRequest { @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java index bc372234..e6b9234e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java @@ -21,12 +21,12 @@ import pro.gravit.launcher.hasher.HashedFile; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.update.UpdateRequest.State.Callback; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.request.websockets.StandartClientWebSocketService; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; -public final class UpdateRequest extends Request implements RequestInterface { +public final class UpdateRequest extends Request implements WebSocketRequest { public interface UpdateController { void preUpdate(UpdateRequest request, UpdateRequestEvent e) throws IOException; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index b0f5a7d9..e304e7a9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -6,12 +6,12 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.serialize.SerializeLimits; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.VerifyHelper; -public final class BatchProfileByUsernameRequest extends Request implements RequestInterface { +public final class BatchProfileByUsernameRequest extends Request implements WebSocketRequest { class Entry { @LauncherNetworkAPI String username; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java index 7166a6ad..171b1116 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java @@ -7,9 +7,9 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.ProfileByUUIDRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; -public final class ProfileByUUIDRequest extends Request implements RequestInterface { +public final class ProfileByUUIDRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI private final UUID uuid; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java index fef8eb91..190c6f8a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java @@ -4,10 +4,10 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.RequestInterface; +import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.VerifyHelper; -public final class ProfileByUsernameRequest extends Request implements RequestInterface { +public final class ProfileByUsernameRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI private final String username; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index 7e2217cc..afba8c8c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -15,7 +15,7 @@ import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.utils.helper.LogHelper; public class ClientWebSocketService extends ClientJSONPoint { @@ -24,8 +24,8 @@ public class ClientWebSocketService extends ClientJSONPoint { public OnCloseCallback onCloseCallback; public final Boolean onConnect; public ReconnectCallback reconnectCallback; - private HashMap> requests; - private HashMap> results; + private HashMap> requests; + private HashMap> results; private HashSet handlers; public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { @@ -34,8 +34,8 @@ public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) th results = new HashMap<>(); handlers = new HashSet<>(); this.gsonBuilder = gsonBuilder; - this.gsonBuilder.registerTypeAdapter(RequestInterface.class, new JsonRequestAdapter(this)); - this.gsonBuilder.registerTypeAdapter(ResultInterface.class, new JsonResultAdapter(this)); + this.gsonBuilder.registerTypeAdapter(WebSocketRequest.class, new JsonRequestAdapter(this)); + this.gsonBuilder.registerTypeAdapter(WebSocketEvent.class, new JsonResultAdapter(this)); this.gsonBuilder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); this.gson = gsonBuilder.create(); this.onConnect = true; @@ -53,7 +53,7 @@ private static URI createURL(String address) { @Override void onMessage(String message) { - ResultInterface result = gson.fromJson(message, ResultInterface.class); + WebSocketEvent result = gson.fromJson(message, WebSocketEvent.class); for (EventHandler handler : handlers) { handler.process(result); } @@ -81,15 +81,15 @@ public interface ReconnectCallback { void onReconnect() throws IOException; } - public Class getRequestClass(String key) { + public Class getRequestClass(String key) { return requests.get(key); } - public Class getResultClass(String key) { + public Class getResultClass(String key) { return results.get(key); } - public void registerRequest(String key, Class clazz) { + public void registerRequest(String key, Class clazz) { requests.put(key, clazz); } @@ -97,7 +97,7 @@ public void registerRequests() { } - public void registerResult(String key, Class clazz) { + public void registerResult(String key, Class clazz) { results.put(key, clazz); } @@ -148,7 +148,7 @@ public void sendObject(Object obj) throws IOException { if (ch == null || !ch.isActive()) reconnectCallback.onReconnect(); //if(isClosed() && reconnectCallback != null) // reconnectCallback.onReconnect(); - send(gson.toJson(obj, RequestInterface.class)); + send(gson.toJson(obj, WebSocketRequest.class)); } public void sendObject(Object obj, Type type) throws IOException { @@ -161,6 +161,6 @@ public void sendObject(Object obj, Type type) throws IOException { @FunctionalInterface public interface EventHandler { - void process(ResultInterface resultInterface); + void process(WebSocketEvent webSocketEvent); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java index 38906c6b..18946738 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java @@ -13,7 +13,7 @@ import pro.gravit.utils.helper.LogHelper; -public class JsonRequestAdapter implements JsonSerializer, JsonDeserializer { +public class JsonRequestAdapter implements JsonSerializer, JsonDeserializer { private final ClientWebSocketService service; private static final String PROP_NAME = "type"; @@ -22,19 +22,19 @@ public JsonRequestAdapter(ClientWebSocketService service) { } @Override - public RequestInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + public WebSocketRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = service.getRequestClass(typename); + Class cls = service.getRequestClass(typename); if (cls == null) { LogHelper.error("Request type %s not found", typename); } - return (RequestInterface) context.deserialize(json, cls); + return (WebSocketRequest) context.deserialize(json, cls); } @Override - public JsonElement serialize(RequestInterface src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WebSocketRequest src, Type typeOfSrc, JsonSerializationContext context) { // note : won't work, you must delegate this JsonObject jo = context.serialize(src).getAsJsonObject(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java index a95ff2e6..2c057dd7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java @@ -11,10 +11,10 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.utils.helper.LogHelper; -public class JsonResultAdapter implements JsonSerializer, JsonDeserializer { +public class JsonResultAdapter implements JsonSerializer, JsonDeserializer { private final ClientWebSocketService service; private static final String PROP_NAME = "type"; @@ -23,19 +23,19 @@ public JsonResultAdapter(ClientWebSocketService service) { } @Override - public ResultInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + public WebSocketEvent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = service.getResultClass(typename); + Class cls = service.getResultClass(typename); if (cls == null) { LogHelper.error("Result type %s not found", typename); } - return (ResultInterface) context.deserialize(json, cls); + return (WebSocketEvent) context.deserialize(json, cls); } @Override - public JsonElement serialize(ResultInterface src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WebSocketEvent src, Type typeOfSrc, JsonSerializationContext context) { // note : won't work, you must delegate this JsonObject jo = context.serialize(src).getAsJsonObject(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java index e2866a07..71161e8e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -12,7 +12,7 @@ import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.RequestException; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; @@ -24,12 +24,12 @@ public StandartClientWebSocketService(GsonBuilder gsonBuilder, String address, i super(gsonBuilder, address, i); } - public class RequestFuture implements Future { + public class RequestFuture implements Future { public final WaitEventHandler.ResultEvent event; public boolean isCanceled = false; @SuppressWarnings("rawtypes") - public RequestFuture(RequestInterface request) throws IOException { + public RequestFuture(WebSocketRequest request) throws IOException { event = new WaitEventHandler.ResultEvent(); event.type = request.getType(); if (request instanceof Request) { @@ -57,14 +57,14 @@ public boolean isDone() { } @Override - public ResultInterface get() throws InterruptedException, ExecutionException { + public WebSocketEvent get() throws InterruptedException, ExecutionException { if (isCanceled) return null; while (!event.ready) { synchronized (event) { event.wait(); } } - ResultInterface result = event.result; + WebSocketEvent result = event.result; waitEventHandler.requests.remove(event); if (event.result.getType().equals("error") || event.result.getType().equals("exception")) { ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result; @@ -74,14 +74,14 @@ public ResultInterface get() throws InterruptedException, ExecutionException { } @Override - public ResultInterface get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException { + public WebSocketEvent get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException { if (isCanceled) return null; while (!event.ready) { synchronized (event) { event.wait(timeout); } } - ResultInterface result = event.result; + WebSocketEvent result = event.result; waitEventHandler.requests.remove(event); if (event.result.getType().equals("error") || event.result.getType().equals("exception")) { ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result; @@ -91,9 +91,9 @@ public ResultInterface get(long timeout, TimeUnit unit) throws InterruptedExcept } } - public ResultInterface sendRequest(RequestInterface request) throws IOException, InterruptedException { + public WebSocketEvent sendRequest(WebSocketRequest request) throws IOException, InterruptedException { RequestFuture future = new RequestFuture(request); - ResultInterface result; + WebSocketEvent result; try { result = future.get(); } catch (ExecutionException e) { @@ -102,7 +102,7 @@ public ResultInterface sendRequest(RequestInterface request) throws IOException, return result; } - public RequestFuture asyncSendRequest(RequestInterface request) throws IOException { + public RequestFuture asyncSendRequest(WebSocketRequest request) throws IOException { return new RequestFuture(request); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java index 50a4849b..860454cd 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java @@ -5,14 +5,14 @@ import java.util.concurrent.ConcurrentHashMap; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.launcher.request.ResultInterface; +import pro.gravit.launcher.request.WebSocketEvent; import pro.gravit.utils.helper.LogHelper; public class WaitEventHandler implements ClientWebSocketService.EventHandler { public Set requests = ConcurrentHashMap.newKeySet(); @Override - public void process(ResultInterface result) { + public void process(WebSocketEvent result) { LogHelper.debug("Processing event %s type", result.getType()); UUID checkUUID = null; if (result instanceof RequestEvent) { @@ -36,7 +36,7 @@ public void process(ResultInterface result) { } public static class ResultEvent { - public ResultInterface result; + public WebSocketEvent result; public UUID uuid; public String type; public boolean ready; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/RequestInterface.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java similarity index 66% rename from LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/RequestInterface.java rename to LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java index 86c5638e..a98a592c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/RequestInterface.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java @@ -1,5 +1,5 @@ package pro.gravit.launcher.request.websockets; -public interface RequestInterface { +public interface WebSocketRequest { String getType(); } From 09afc9943d296882d7a016227a40b0b6d811059d Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 18:34:03 +0700 Subject: [PATCH 49/70] =?UTF-8?q?[FEATURE]=20=D0=9E=D0=BF=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20Netty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 6 ++++ .../socket/LauncherNettyServer.java | 25 +++++++++------ .../socket/NettyObjectFactory.java | 31 +++++++++++++++++++ .../launchserver/socket/WebSocketService.java | 8 ++--- 4 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 6db964b0..3a84d3c4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -301,7 +301,12 @@ public class NettyConfig { public NettyProxyConfig proxy = new NettyProxyConfig(); } + public class NettySSLConfig { + public String protocol; + } + public class NettyPerformanceConfig { + public boolean usingEpoll; public int bossThread; public int workerThread; } @@ -743,6 +748,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.netty.fileServerEnabled = true; newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)}; newConfig.netty.performance = new NettyPerformanceConfig(); + newConfig.netty.performance.usingEpoll = JVMHelper.OS_TYPE == JVMHelper.OS.LINUX; //Only linux newConfig.netty.performance.bossThread = 2; newConfig.netty.performance.workerThread = 8; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java index 87c456dc..c0b5b205 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -8,9 +8,7 @@ import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoopGroup; import io.netty.channel.group.DefaultChannelGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.channel.socket.SocketChannel; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; @@ -24,7 +22,7 @@ import pro.gravit.launchserver.socket.handlers.NettyIpForwardHandler; import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; import pro.gravit.launchserver.socket.handlers.fileserver.FileServerHandler; -import pro.gravit.utils.helper.CommonHelper; +import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; public class LauncherNettyServer implements AutoCloseable { @@ -36,16 +34,25 @@ public class LauncherNettyServer implements AutoCloseable { public LauncherNettyServer(LaunchServer server) { LaunchServer.NettyConfig config = server.config.netty; - bossGroup = new NioEventLoopGroup(config.performance.bossThread); - workerGroup = new NioEventLoopGroup(config.performance.workerThread); + NettyObjectFactory.setUsingEpoll(config.performance.usingEpoll); + if(config.performance.usingEpoll) + { + LogHelper.debug("Netty: Epoll enabled"); + } + if(config.performance.usingEpoll && JVMHelper.OS_TYPE != JVMHelper.OS.LINUX) + { + LogHelper.error("netty,perfomance.usingEpoll work only Linux systems"); + } + bossGroup = NettyObjectFactory.newEventLoopGroup(config.performance.bossThread); + workerGroup = NettyObjectFactory.newEventLoopGroup(config.performance.workerThread); serverBootstrap = new ServerBootstrap(); service = new WebSocketService(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), server); serverBootstrap.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) + .channel(NettyObjectFactory.getServerSocketChannelClass()) .handler(new LoggingHandler(config.logLevel)) - .childHandler(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override - public void initChannel(NioSocketChannel ch) { + public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); NettyConnectContext context = new NettyConnectContext(); //p.addLast(new LoggingHandler(LogLevel.INFO)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java new file mode 100644 index 00000000..2157e95c --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java @@ -0,0 +1,31 @@ +package pro.gravit.launchserver.socket; + +import io.netty.channel.EventLoopGroup; +import io.netty.channel.ServerChannel; +import io.netty.channel.epoll.EpollEventLoopGroup; +import io.netty.channel.epoll.EpollServerSocketChannel; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; + +public class NettyObjectFactory { + private static boolean epoll = false; + public static void setUsingEpoll(boolean value) + { + epoll = value; + } + public static EventLoopGroup newEventLoopGroup(int threads) + { + if(epoll) + return new EpollEventLoopGroup(threads); + else + return new NioEventLoopGroup(threads); + } + public static Class getServerSocketChannelClass() + { + if(epoll) + return EpollServerSocketChannel.class; + else + return NioServerSocketChannel.class; + } + +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index beac50fd..98539d6d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -173,11 +173,11 @@ public static void registerResponses() { } public void sendObject(ChannelHandlerContext ctx, Object obj) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))); + ctx.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))); } public void sendObject(ChannelHandlerContext ctx, Object obj, Type type) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type))); + ctx.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type))); } public void sendObjectAll(Object obj) { @@ -193,11 +193,11 @@ public void sendObjectAll(Object obj, Type type) { } public void sendObjectAndClose(ChannelHandlerContext ctx, Object obj) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))).addListener(ChannelFutureListener.CLOSE); + ctx.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, WebSocketEvent.class))).addListener(ChannelFutureListener.CLOSE); } public void sendObjectAndClose(ChannelHandlerContext ctx, Object obj, Type type) { - ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type))).addListener(ChannelFutureListener.CLOSE); + ctx.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type))).addListener(ChannelFutureListener.CLOSE); } public void sendEvent(EventResult obj) { From c9f27a4f3cf19faf9ebaad5d149d29673d0366d9 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 20:24:54 +0700 Subject: [PATCH 50/70] =?UTF-8?q?[FEATURE]=20=D0=9A=D1=80=D0=B8=D0=BF?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D0=B0=20bouncycastle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 1 + .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index c4975b31..df2639df 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -54,6 +54,7 @@ bundle project(':Radon') bundle 'org.javassist:javassist:3.25.0-GA' bundle 'io.netty:netty-all:4.1.36.Final' bundle 'org.hibernate:hibernate-core:5.4.3.Final' + bundle 'org.bouncycastle:bcpkix-jdk15on:1.61' bundle 'org.slf4j:slf4j-simple:1.7.25' bundle 'org.slf4j:slf4j-api:1.7.25' diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 3a84d3c4..bb7c6a7a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -301,10 +301,6 @@ public class NettyConfig { public NettyProxyConfig proxy = new NettyProxyConfig(); } - public class NettySSLConfig { - public String protocol; - } - public class NettyPerformanceConfig { public boolean usingEpoll; public int bossThread; From 2e5295dbaf23e1735b476ecb79af9bdc7ac61a20 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 21:45:11 +0700 Subject: [PATCH 51/70] =?UTF-8?q?[FEATURE]=20=D0=AD=D0=BB=D0=BB=D0=B8?= =?UTF-8?q?=D0=BF=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D1=84=D0=B8?= =?UTF-8?q?=D1=8F.=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D1=81=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D1=81=D0=B5=D1=80=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 10 ++-- .../manangers/CertificateManager.java | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index bb7c6a7a..548971fd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -66,12 +66,7 @@ import pro.gravit.launchserver.config.LaunchServerRuntimeConfig; import pro.gravit.launchserver.dao.UserService; import pro.gravit.launchserver.dao.provider.DaoProvider; -import pro.gravit.launchserver.manangers.LaunchServerGsonManager; -import pro.gravit.launchserver.manangers.MirrorManager; -import pro.gravit.launchserver.manangers.ModulesManager; -import pro.gravit.launchserver.manangers.ReconfigurableManager; -import pro.gravit.launchserver.manangers.ReloadManager; -import pro.gravit.launchserver.manangers.SessionManager; +import pro.gravit.launchserver.manangers.*; import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.launchserver.manangers.hook.BuildHookManager; import pro.gravit.launchserver.socket.WebSocketService; @@ -441,6 +436,8 @@ public static void main(String... args) throws Throwable { public final ConfigManager configManager; + public final CertificateManager certificateManager; + public final BuildHookManager buildHookManager; @@ -599,6 +596,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException reconfigurableManager = new ReconfigurableManager(); authHookManager = new AuthHookManager(); configManager = new ConfigManager(); + certificateManager = new CertificateManager(); GarbageManager.registerNeedGC(sessionManager); reloadManager.registerReloadable("launchServer", this); registerObject("permissionsHandler", config.permissionsHandler); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java new file mode 100644 index 00000000..2f518ecb --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java @@ -0,0 +1,50 @@ +package pro.gravit.launchserver.manangers; + + +import org.bouncycastle.asn1.x500.X500NameBuilder; +import org.bouncycastle.asn1.x500.style.BCStyle; +import org.bouncycastle.asn1.x509.AlgorithmIdentifier; +import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; +import org.bouncycastle.cert.X509CertificateHolder; +import org.bouncycastle.cert.X509v3CertificateBuilder; +import org.bouncycastle.crypto.params.AsymmetricKeyParameter; +import org.bouncycastle.operator.ContentSigner; +import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; +import org.bouncycastle.operator.OperatorCreationException; +import org.bouncycastle.operator.bc.BcECContentSignerBuilder; +import pro.gravit.utils.helper.SecurityHelper; + +import java.math.BigInteger; +import java.security.PublicKey; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; + +public class CertificateManager { + public X509CertificateHolder ca; + public AsymmetricKeyParameter caKey; + + //public X509CertificateHolder server; + //public AsymmetricKeyParameter serverKey; + + public int validDays = 0; + public int minusHours = 6; + + public X509CertificateHolder generateCertificate(String subjectName, PublicKey subjectPublicKey) throws OperatorCreationException { + SubjectPublicKeyInfo subjectPubKeyInfo = SubjectPublicKeyInfo.getInstance(subjectPublicKey); + BigInteger serial = BigInteger.valueOf(SecurityHelper.newRandom().nextLong()); + Date startDate = Date.from(Instant.now().minus(minusHours, ChronoUnit.HOURS)); + Date endDate = Date.from(startDate.toInstant().plus(validDays, ChronoUnit.DAYS)); + + X500NameBuilder subject = new X500NameBuilder(); + subject.addRDN(BCStyle.CN, subjectName); + X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(ca.getSubject(), serial, + startDate, endDate, subject.build(), subjectPubKeyInfo); + + AlgorithmIdentifier sigAlgId = ca.getSignatureAlgorithm(); + AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId); + ContentSigner sigGen = new BcECContentSignerBuilder(sigAlgId, digAlgId).build(caKey); + + return v3CertGen.build(sigGen); + } +} From aebb96b32e6c2bef86ada43a4f87a8c24e3d987b Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 22:20:05 +0700 Subject: [PATCH 52/70] =?UTF-8?q?[FEATURE]=20=D0=AD=D0=BB=D0=BB=D0=B8?= =?UTF-8?q?=D0=BF=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D1=84=D0=B8?= =?UTF-8?q?=D1=8F.=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20CA?= =?UTF-8?q?,=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D0=B2=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=B8=D1=81=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manangers/CertificateManager.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java index 2f518ecb..f7e10deb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java @@ -1,22 +1,41 @@ package pro.gravit.launchserver.manangers; +import org.bouncycastle.asn1.x500.X500Name; import org.bouncycastle.asn1.x500.X500NameBuilder; import org.bouncycastle.asn1.x500.style.BCStyle; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; +import org.bouncycastle.cert.CertIOException; import org.bouncycastle.cert.X509CertificateHolder; import org.bouncycastle.cert.X509v3CertificateBuilder; import org.bouncycastle.crypto.params.AsymmetricKeyParameter; +import org.bouncycastle.crypto.params.ECKeyParameters; +import org.bouncycastle.crypto.util.PrivateKeyFactory; +import org.bouncycastle.jce.ECNamedCurveTable; +import org.bouncycastle.jce.spec.ECParameterSpec; +import org.bouncycastle.openssl.PEMWriter; import org.bouncycastle.operator.ContentSigner; import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.bc.BcECContentSignerBuilder; +import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; +import org.bouncycastle.util.io.pem.PemObject; +import org.bouncycastle.util.io.pem.PemWriter; +import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.SecurityHelper; +import java.io.FileWriter; +import java.io.IOException; import java.math.BigInteger; -import java.security.PublicKey; +import java.nio.file.Path; +import java.security.*; +import java.security.cert.CertificateException; +import java.security.spec.ECGenParameterSpec; import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.util.Date; @@ -47,4 +66,35 @@ public X509CertificateHolder generateCertificate(String subjectName, PublicKey s return v3CertGen.build(sigGen); } + + public void generateCA() throws NoSuchAlgorithmException, IOException, OperatorCreationException, InvalidAlgorithmParameterException { + ECGenParameterSpec ecGenSpec = new ECGenParameterSpec("secp384r1"); + KeyPairGenerator generator = KeyPairGenerator.getInstance("EC"); + generator.initialize(ecGenSpec, SecurityHelper.newRandom()); + KeyPair pair = generator.generateKeyPair(); + LocalDateTime startDate = LocalDate.now().atStartOfDay(); + + X509v3CertificateBuilder builder= new X509v3CertificateBuilder( + new X500Name("CN=ca"), + new BigInteger("0"), + Date.from(startDate.atZone(ZoneId.systemDefault()).toInstant()), + Date.from(startDate.plusDays(3650).atZone(ZoneId.systemDefault()).toInstant()), + new X500Name("CN=ca"), + SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded())); + JcaContentSignerBuilder csBuilder= new JcaContentSignerBuilder("SHA256WITHECDSA"); + ContentSigner signer = csBuilder.build(pair.getPrivate()); + ca = builder.build(signer); + caKey = PrivateKeyFactory.createKey(pair.getPrivate().getEncoded()); + } + + public void writePrivateKey(Path file, PrivateKey privateKey) throws IOException { + try (PemWriter writer = new PemWriter(IOHelper.newWriter(file))) { + writer.writeObject(new PemObject("PRIVATE KEY", privateKey.getEncoded())); + } + } + public void writeCertificate(Path file, X509CertificateHolder holder) throws IOException { + try (PemWriter writer = new PemWriter(IOHelper.newWriter(file))) { + writer.writeObject(new PemObject("CERTIFICATE", holder.toASN1Structure().getEncoded())); + } + } } From c85350821ee338cabd0e32d7691ed6d6aa93646d Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Jul 2019 22:47:07 +0700 Subject: [PATCH 53/70] =?UTF-8?q?[FEATURE]=20=D0=AD=D0=BB=D0=BB=D0=B8?= =?UTF-8?q?=D0=BF=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D1=84=D0=B8?= =?UTF-8?q?=D1=8F.=20=D0=A2=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B,=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/basic/TestCommand.java | 18 ++++++++++++++++ .../manangers/CertificateManager.java | 21 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java index a9d37cc7..c5deec73 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/TestCommand.java @@ -1,11 +1,16 @@ package pro.gravit.launchserver.command.basic; +import org.bouncycastle.cert.X509CertificateHolder; import pro.gravit.launcher.events.PingEvent; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; import pro.gravit.utils.helper.CommonHelper; +import java.nio.file.Paths; +import java.security.KeyPair; +import java.security.KeyPairGenerator; + public class TestCommand extends Command { public TestCommand(LaunchServer server) { super(server); @@ -34,5 +39,18 @@ public void invoke(String... args) throws Exception { if (args[0].equals("stop")) { handler.close(); } + if(args[0].equals("genCA")) { + server.certificateManager.generateCA(); + server.certificateManager.writePrivateKey(Paths.get("ca.key"), server.certificateManager.caKey); + server.certificateManager.writeCertificate(Paths.get("ca.crt"), server.certificateManager.ca); + } + if(args[0].equals("genCert")) { + verifyArgs(args, 2); + String name = args[1]; + KeyPair pair = server.certificateManager.generateKeyPair(); + X509CertificateHolder cert = server.certificateManager.generateCertificate(name, pair.getPublic()); + server.certificateManager.writePrivateKey(Paths.get(name.concat(".key")), pair.getPrivate()); + server.certificateManager.writeCertificate(Paths.get(name.concat(".crt")), cert); + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java index f7e10deb..cae36ff7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver.manangers; +import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; import org.bouncycastle.asn1.x500.X500Name; import org.bouncycastle.asn1.x500.X500NameBuilder; import org.bouncycastle.asn1.x500.style.BCStyle; @@ -12,6 +13,7 @@ import org.bouncycastle.crypto.params.AsymmetricKeyParameter; import org.bouncycastle.crypto.params.ECKeyParameters; import org.bouncycastle.crypto.util.PrivateKeyFactory; +import org.bouncycastle.crypto.util.PrivateKeyInfoFactory; import org.bouncycastle.jce.ECNamedCurveTable; import org.bouncycastle.jce.spec.ECParameterSpec; import org.bouncycastle.openssl.PEMWriter; @@ -46,11 +48,11 @@ public class CertificateManager { //public X509CertificateHolder server; //public AsymmetricKeyParameter serverKey; - public int validDays = 0; + public int validDays = 60; public int minusHours = 6; public X509CertificateHolder generateCertificate(String subjectName, PublicKey subjectPublicKey) throws OperatorCreationException { - SubjectPublicKeyInfo subjectPubKeyInfo = SubjectPublicKeyInfo.getInstance(subjectPublicKey); + SubjectPublicKeyInfo subjectPubKeyInfo = SubjectPublicKeyInfo.getInstance(subjectPublicKey.getEncoded()); BigInteger serial = BigInteger.valueOf(SecurityHelper.newRandom().nextLong()); Date startDate = Date.from(Instant.now().minus(minusHours, ChronoUnit.HOURS)); Date endDate = Date.from(startDate.toInstant().plus(validDays, ChronoUnit.DAYS)); @@ -87,11 +89,26 @@ public void generateCA() throws NoSuchAlgorithmException, IOException, OperatorC caKey = PrivateKeyFactory.createKey(pair.getPrivate().getEncoded()); } + public KeyPair generateKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { + ECGenParameterSpec ecGenSpec = new ECGenParameterSpec("secp384r1"); + KeyPairGenerator generator = KeyPairGenerator.getInstance("EC"); + generator.initialize(ecGenSpec, SecurityHelper.newRandom()); + return generator.generateKeyPair(); + } + public void writePrivateKey(Path file, PrivateKey privateKey) throws IOException { try (PemWriter writer = new PemWriter(IOHelper.newWriter(file))) { writer.writeObject(new PemObject("PRIVATE KEY", privateKey.getEncoded())); } } + + public void writePrivateKey(Path file, AsymmetricKeyParameter key) throws IOException { + PrivateKeyInfo info = PrivateKeyInfoFactory.createPrivateKeyInfo(key); + try (PemWriter writer = new PemWriter(IOHelper.newWriter(file))) { + writer.writeObject(new PemObject("PRIVATE KEY", info.getEncoded())); + } + } + public void writeCertificate(Path file, X509CertificateHolder holder) throws IOException { try (PemWriter writer = new PemWriter(IOHelper.newWriter(file))) { writer.writeObject(new PemObject("CERTIFICATE", holder.toASN1Structure().getEncoded())); From 486fae8ccfc9531224716e6f3a5b45e642db19ce Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 2 Jul 2019 15:36:50 +0700 Subject: [PATCH 54/70] =?UTF-8?q?[FEATURE]=20=D0=92=D0=BE=D0=B7=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=B4?= =?UTF-8?q?=D0=B0=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD=D1=83=D0=BB=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B9=20HWID,=20=D0=B0=20=D1=81=D0=BB=D0=B5=D0=B4=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=83=20OSHI=20=D0=B5=D1=81=D0=BB=D0=B8=20HWID=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=82=D1=80=D0=B5=D0=B1=D1=83=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 2 ++ .../auth/hwid/AcceptHWIDHandler.java | 2 +- .../launchserver/auth/hwid/HWIDHandler.java | 2 +- .../auth/hwid/JsonFileHWIDHandler.java | 2 +- .../auth/hwid/JsonHWIDHandler.java | 4 ++-- .../auth/hwid/MemoryHWIDHandler.java | 2 +- .../auth/hwid/MysqlHWIDHandler.java | 4 ++-- .../launchserver/command/auth/BanCommand.java | 2 +- .../command/auth/GetHWIDCommand.java | 2 +- .../command/auth/UnbanCommand.java | 2 +- .../pro/gravit/launchserver/dao/UserDAO.java | 2 +- .../pro/gravit/launchserver/dao/UserHWID.java | 4 ++-- .../dao/impl/DefaultUserDAOImpl.java | 2 +- .../dao/impl/HibernateUserDAOImpl.java | 2 +- .../manangers/LaunchServerGsonManager.java | 3 +++ .../socket/response/auth/AuthResponse.java | 7 +++--- Launcher/runtime/engine/api.js | 3 +++ .../pro/gravit/launcher/LauncherEngine.java | 2 ++ .../launcher/client/ClientLauncher.java | 2 ++ .../launcher/client/FunctionalBridge.java | 2 +- .../launcher/gui/JSRuntimeProvider.java | 5 ++++ .../launcher/hwid/OshiHWIDProvider.java | 3 --- .../launcher/managers/ClientGsonManager.java | 3 +++ .../pro/gravit/launcher/{ => hwid}/HWID.java | 2 +- .../gravit/launcher/hwid/HWIDProvider.java | 11 +++++++++ .../{ => hwid}/LauncherHWIDInterface.java | 4 +++- .../java/pro/gravit/launcher/hwid/NoHWID.java | 23 +++++++++++++++++++ .../gravit/launcher/{ => hwid}/OshiHWID.java | 3 ++- .../launcher/request/auth/AuthRequest.java | 2 +- 29 files changed, 82 insertions(+), 27 deletions(-) rename LauncherAPI/src/main/java/pro/gravit/launcher/{ => hwid}/HWID.java (86%) create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java rename LauncherAPI/src/main/java/pro/gravit/launcher/{ => hwid}/LauncherHWIDInterface.java (53%) create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/hwid/NoHWID.java rename LauncherAPI/src/main/java/pro/gravit/launcher/{ => hwid}/OshiHWID.java (97%) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 548971fd..3b746f13 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -37,6 +37,7 @@ import pro.gravit.launcher.LauncherConfig; import pro.gravit.launcher.NeedGarbageCollection; import pro.gravit.launcher.hasher.HashedDir; +import pro.gravit.launcher.hwid.HWIDProvider; import pro.gravit.launcher.managers.ConfigManager; import pro.gravit.launcher.managers.GarbageManager; import pro.gravit.launcher.profiles.ClientProfile; @@ -495,6 +496,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException Component.registerComponents(); ProtectHandler.registerHandlers(); WebSocketService.registerResponses(); + HWIDProvider.registerHWIDs(); //LaunchServer.server = this; // Set command handler diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java index b09ba0e7..16a36b0d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; public class AcceptHWIDHandler extends HWIDHandler { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java index 51978a11..eadb4228 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java @@ -2,7 +2,7 @@ import java.util.List; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.utils.ProviderMap; public abstract class HWIDHandler implements AutoCloseable { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java index 778c75f8..b181da50 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java @@ -12,7 +12,7 @@ import com.google.gson.reflect.TypeToken; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launcher.Launcher; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index bc605cca..8bbcb277 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -9,8 +9,8 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; -import pro.gravit.launcher.HWID; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.utils.HTTPRequest; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java index 1d221f37..21a719b7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Objects; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; public class MemoryHWIDHandler extends HWIDHandler { public class Entry { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index 7bbe5b0e..2447034e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -7,8 +7,8 @@ import java.util.ArrayList; import java.util.List; -import pro.gravit.launcher.HWID; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launchserver.auth.MySQLSourceConfig; import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/BanCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/BanCommand.java index e3b8b57b..89a5ce9b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/BanCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/BanCommand.java @@ -2,7 +2,7 @@ import java.util.List; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/GetHWIDCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/GetHWIDCommand.java index 1e82ec3a..3e7805a1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/GetHWIDCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/GetHWIDCommand.java @@ -2,7 +2,7 @@ import java.util.List; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/UnbanCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/UnbanCommand.java index 0effa030..f6897e8e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/UnbanCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/auth/UnbanCommand.java @@ -2,7 +2,7 @@ import java.util.List; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserDAO.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserDAO.java index 667ca4b0..b4769a3d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserDAO.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserDAO.java @@ -1,6 +1,6 @@ package pro.gravit.launchserver.dao; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.OshiHWID; import java.util.List; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java index 9d2b3f9a..106aab2a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java @@ -1,7 +1,7 @@ package pro.gravit.launchserver.dao; -import pro.gravit.launcher.HWID; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.OshiHWID; import javax.persistence.*; import java.util.function.Supplier; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/DefaultUserDAOImpl.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/DefaultUserDAOImpl.java index 107e5686..49a24676 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/DefaultUserDAOImpl.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/DefaultUserDAOImpl.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.UUID; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.UserDAO; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java index 1c29dfc3..fc086c57 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/impl/HibernateUserDAOImpl.java @@ -12,7 +12,7 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.UserDAO; import pro.gravit.launchserver.dao.UserHWID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index e6caf5ae..d636f6e0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -4,6 +4,8 @@ import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.HWIDProvider; import pro.gravit.launcher.managers.GsonManager; import pro.gravit.launcher.request.JsonResultSerializeAdapter; import pro.gravit.launcher.request.WebSocketEvent; @@ -31,6 +33,7 @@ public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers)); builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers)); builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers)); + builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids)); builder.registerTypeAdapter(WebSocketServerResponse.class, new UniversalJsonAdapter<>(WebSocketService.providers)); builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); builder.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter()); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index d732f2f3..0124074e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -9,7 +9,8 @@ import javax.crypto.IllegalBlockSizeException; import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.OshiHWID; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launchserver.auth.AuthException; @@ -46,7 +47,7 @@ public AuthResponse(String login, String password, String auth_id, OshiHWID hwid public String auth_id; public boolean initProxy; public ConnectTypes authType; - public OshiHWID hwid; + public HWID hwid; public enum ConnectTypes { SERVER, CLIENT, BOT @@ -76,7 +77,7 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti AuthProviderPair pair; if (auth_id.isEmpty()) pair = server.config.getAuthProviderPair(); else pair = server.config.getAuthProviderPair(auth_id); - AuthContext context = new AuthContext(0, login, password.length(), customText, client, ip, null, authType); + AuthContext context = new AuthContext(0, login, password.length(), customText, client, null, ip, authType); AuthProvider provider = pair.provider; server.authHookManager.preHook.hook(context, clientData); provider.preAuth(login, password, customText, ip); diff --git a/Launcher/runtime/engine/api.js b/Launcher/runtime/engine/api.js index 0b07d4fb..4bae67fa 100644 --- a/Launcher/runtime/engine/api.js +++ b/Launcher/runtime/engine/api.js @@ -59,6 +59,9 @@ var VerifyHelper = VerifyHelperClass.static; var NewLauncherSettings = NewLauncherSettingsClass.static; var SettingsManager = SettingsManagerClass.static; +var NoHWID = NoHWIDClass.static; +var OshiHWID = OshiHWID.static; + // Helper JS class API imports var JSApplication = null; if (typeof JSApplicationClass !== 'undefined') { diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index c839dfd0..f2d84e0e 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -10,6 +10,7 @@ import pro.gravit.launcher.guard.LauncherGuardManager; import pro.gravit.launcher.gui.JSRuntimeProvider; import pro.gravit.launcher.gui.RuntimeProvider; +import pro.gravit.launcher.hwid.HWIDProvider; import pro.gravit.launcher.managers.ClientGsonManager; import pro.gravit.launcher.managers.ConsoleManager; import pro.gravit.launcher.request.Request; @@ -34,6 +35,7 @@ public static void main(String... args) throws Throwable { // Start Launcher initGson(); ConsoleManager.initConsole(); + HWIDProvider.registerHWIDs(); LauncherConfig config = Launcher.getConfig(); if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { if (!LauncherAgent.isStarted()) throw new SecurityException("LauncherAgent must started"); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index 5674255a..a4fe3cd0 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -32,6 +32,7 @@ import pro.gravit.launcher.gui.JSRuntimeProvider; import pro.gravit.launcher.hasher.FileNameMatcher; import pro.gravit.launcher.hasher.HashedDir; +import pro.gravit.launcher.hwid.HWIDProvider; import pro.gravit.launcher.managers.ClientGsonManager; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.PlayerProfile; @@ -427,6 +428,7 @@ public static void main(String... args) throws Throwable { if (engine.runtimeProvider == null) engine.runtimeProvider = new JSRuntimeProvider(); engine.runtimeProvider.init(true); engine.runtimeProvider.preLoad(); + HWIDProvider.registerHWIDs(); LauncherGuardManager.initGuard(true); LogHelper.debug("Reading ClientLauncher params"); Params params; diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java index 28e77f81..ec1e5474 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java @@ -6,7 +6,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launcher.LauncherAPI; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.guard.LauncherGuardManager; diff --git a/Launcher/src/main/java/pro/gravit/launcher/gui/JSRuntimeProvider.java b/Launcher/src/main/java/pro/gravit/launcher/gui/JSRuntimeProvider.java index a502b137..97c09d85 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/gui/JSRuntimeProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/gui/JSRuntimeProvider.java @@ -25,6 +25,8 @@ import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedFile; +import pro.gravit.launcher.hwid.NoHWID; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launcher.managers.SettingsManager; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.PlayerProfile; @@ -130,6 +132,9 @@ public static void addLauncherClassBindings(Map bindings) { bindings.put("DirBridgeClass", DirBridge.class); bindings.put("FunctionalBridgeClass", FunctionalBridge.class); + bindings.put("NoHWIDClass", NoHWID.class); + bindings.put("OshiHWIDClass", OshiHWID.class); + // Load JS API if available try { Class.forName("javafx.application.Application"); diff --git a/Launcher/src/main/java/pro/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/hwid/OshiHWIDProvider.java index 67ad55c4..ccbdd898 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/hwid/OshiHWIDProvider.java @@ -10,9 +10,6 @@ import oshi.hardware.NetworkIF; import oshi.hardware.SoundCard; import oshi.hardware.UsbDevice; -import pro.gravit.launcher.HWID; -import pro.gravit.launcher.LauncherHWIDInterface; -import pro.gravit.launcher.OshiHWID; import pro.gravit.utils.helper.LogHelper; public class OshiHWIDProvider implements LauncherHWIDInterface { diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java index 1f4d1539..bf2f2632 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java @@ -3,6 +3,8 @@ import com.google.gson.GsonBuilder; import pro.gravit.launcher.client.UserSettings; +import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.HWIDProvider; import pro.gravit.utils.UniversalJsonAdapter; public class ClientGsonManager extends GsonManager { @@ -10,5 +12,6 @@ public class ClientGsonManager extends GsonManager { public void registerAdapters(GsonBuilder builder) { super.registerAdapters(builder); builder.registerTypeAdapter(UserSettings.class, new UniversalJsonAdapter<>(UserSettings.providers)); + builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids)); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/HWID.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWID.java similarity index 86% rename from LauncherAPI/src/main/java/pro/gravit/launcher/HWID.java rename to LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWID.java index 3cc02197..32616752 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/HWID.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWID.java @@ -1,4 +1,4 @@ -package pro.gravit.launcher; +package pro.gravit.launcher.hwid; public interface HWID { String getSerializeString(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java new file mode 100644 index 00000000..24deea4b --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java @@ -0,0 +1,11 @@ +package pro.gravit.launcher.hwid; + +import pro.gravit.utils.ProviderMap; + +public class HWIDProvider { + public static ProviderMap hwids = new ProviderMap<>(); + public static void registerHWIDs() + { + hwids.register("oshi", OshiHWID.class); + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherHWIDInterface.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/LauncherHWIDInterface.java similarity index 53% rename from LauncherAPI/src/main/java/pro/gravit/launcher/LauncherHWIDInterface.java rename to LauncherAPI/src/main/java/pro/gravit/launcher/hwid/LauncherHWIDInterface.java index 99edce7f..9c4c192b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherHWIDInterface.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/LauncherHWIDInterface.java @@ -1,4 +1,6 @@ -package pro.gravit.launcher; +package pro.gravit.launcher.hwid; + +import pro.gravit.launcher.hwid.HWID; @FunctionalInterface public interface LauncherHWIDInterface { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/NoHWID.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/NoHWID.java new file mode 100644 index 00000000..d03c1d82 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/NoHWID.java @@ -0,0 +1,23 @@ +package pro.gravit.launcher.hwid; + +public class NoHWID implements HWID { + @Override + public String getSerializeString() { + return ""; + } + + @Override + public int getLevel() { + return 0; + } + + @Override + public int compare(HWID hwid) { + return 0; + } + + @Override + public boolean isNull() { + return true; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/OshiHWID.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/OshiHWID.java similarity index 97% rename from LauncherAPI/src/main/java/pro/gravit/launcher/OshiHWID.java rename to LauncherAPI/src/main/java/pro/gravit/launcher/hwid/OshiHWID.java index 2c669470..68e8eff4 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/OshiHWID.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/OshiHWID.java @@ -1,9 +1,10 @@ -package pro.gravit.launcher; +package pro.gravit.launcher.hwid; import java.util.Objects; import java.util.StringJoiner; import com.google.gson.Gson; +import pro.gravit.launcher.LauncherAPI; public class OshiHWID implements HWID { public static Gson gson = new Gson(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index 9c26720e..e3695bfb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -1,6 +1,6 @@ package pro.gravit.launcher.request.auth; -import pro.gravit.launcher.HWID; +import pro.gravit.launcher.hwid.HWID; import pro.gravit.launcher.LauncherAPI; import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.AuthRequestEvent; From ea9084037c092bfa33dc639e49cbe1470de40db0 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 2 Jul 2019 15:44:37 +0700 Subject: [PATCH 55/70] =?UTF-8?q?[HOTFIX]=20=D0=9E=D0=BF=D0=B5=D1=87=D0=B0?= =?UTF-8?q?=D1=82=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/engine/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Launcher/runtime/engine/api.js b/Launcher/runtime/engine/api.js index 4bae67fa..1c751f1d 100644 --- a/Launcher/runtime/engine/api.js +++ b/Launcher/runtime/engine/api.js @@ -60,7 +60,7 @@ var NewLauncherSettings = NewLauncherSettingsClass.static; var SettingsManager = SettingsManagerClass.static; var NoHWID = NoHWIDClass.static; -var OshiHWID = OshiHWID.static; +var OshiHWID = OshiHWIDClass.static; // Helper JS class API imports var JSApplication = null; From 73d1d6485b6af062150c58c48fe5e69c5a5bf69d Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Wed, 3 Jul 2019 09:24:13 +0300 Subject: [PATCH 56/70] =?UTF-8?q?[ANY]=20=D0=A1=D1=81=D1=8B=D0=BB=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20discord=20=D0=B2=D0=B5=D0=B4=D1=91?= =?UTF-8?q?=D1=82=20=D0=B2=20=D0=BA=D0=B0=D0=BD=D0=B0=D0=BB=20#important.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c03966a5..73547ed4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Modification of the launcher sashok724's v3 from Gravit [![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher) -* Discord channel: https://discord.gg/aJK6nMN +* [Discord channel](https://discord.gg/XTAZevy) * [See license](LICENSE) * [See code of conduct](CODE_OF_CONDUCT.md) * [WIKI](https://yii2.gravit.pro) From 6a5d110f9a25db557dab733abb252db44420bf18 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 3 Jul 2019 14:23:26 +0700 Subject: [PATCH 57/70] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20=D1=81=D0=B5=D1=80=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manangers/LaunchServerGsonManager.java | 3 +- .../launcher/managers/ClientGsonManager.java | 2 + .../gravit/launcher/hwid/HWIDProvider.java | 1 + .../launcher/request/WebSocketEvent.java | 4 +- .../launcher/request/auth/AuthRequest.java | 1 + .../websockets/ClientWebSocketService.java | 81 ++++++++----------- .../websockets/JsonRequestAdapter.java | 46 ----------- .../request/websockets/JsonResultAdapter.java | 47 ----------- .../StandartClientWebSocketService.java | 6 +- .../request/websockets/WebSocketRequest.java | 4 +- .../gravit/utils/TypeSerializeInterface.java | 5 ++ .../gravit/utils/UniversalJsonAdapter.java | 6 +- .../server/ServerWrapperGsonManager.java | 2 + 13 files changed, 60 insertions(+), 148 deletions(-) delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java create mode 100644 LauncherCore/src/main/java/pro/gravit/utils/TypeSerializeInterface.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index d636f6e0..6b804245 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -9,6 +9,7 @@ import pro.gravit.launcher.managers.GsonManager; import pro.gravit.launcher.request.JsonResultSerializeAdapter; import pro.gravit.launcher.request.WebSocketEvent; +import pro.gravit.launcher.request.websockets.ClientWebSocketService; import pro.gravit.launchserver.auth.handler.AuthHandler; import pro.gravit.launchserver.auth.hwid.HWIDHandler; import pro.gravit.launchserver.auth.permissions.PermissionsHandler; @@ -35,7 +36,7 @@ public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers)); builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids)); builder.registerTypeAdapter(WebSocketServerResponse.class, new UniversalJsonAdapter<>(WebSocketService.providers)); - builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); builder.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter()); + //ClientWebSocketService.appendTypeAdapters(builder); } } diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java index bf2f2632..7e788093 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientGsonManager.java @@ -5,6 +5,7 @@ import pro.gravit.launcher.client.UserSettings; import pro.gravit.launcher.hwid.HWID; import pro.gravit.launcher.hwid.HWIDProvider; +import pro.gravit.launcher.request.websockets.ClientWebSocketService; import pro.gravit.utils.UniversalJsonAdapter; public class ClientGsonManager extends GsonManager { @@ -13,5 +14,6 @@ public void registerAdapters(GsonBuilder builder) { super.registerAdapters(builder); builder.registerTypeAdapter(UserSettings.class, new UniversalJsonAdapter<>(UserSettings.providers)); builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids)); + ClientWebSocketService.appendTypeAdapters(builder); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java index 24deea4b..0b924e73 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java @@ -7,5 +7,6 @@ public class HWIDProvider { public static void registerHWIDs() { hwids.register("oshi", OshiHWID.class); + hwids.register("no", NoHWID.class); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java index a4b9cfef..03895907 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/WebSocketEvent.java @@ -1,5 +1,7 @@ package pro.gravit.launcher.request; -public interface WebSocketEvent { +import pro.gravit.utils.TypeSerializeInterface; + +public interface WebSocketEvent extends TypeSerializeInterface { String getType(); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index e3695bfb..9f26491c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -4,6 +4,7 @@ import pro.gravit.launcher.LauncherAPI; import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.AuthRequestEvent; +import pro.gravit.launcher.hwid.OshiHWID; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.VerifyHelper; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index afba8c8c..de2de7d2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -11,36 +11,39 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import pro.gravit.launcher.Launcher; import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.request.WebSocketEvent; +import pro.gravit.utils.ProviderMap; +import pro.gravit.utils.UniversalJsonAdapter; import pro.gravit.utils.helper.LogHelper; public class ClientWebSocketService extends ClientJSONPoint { - public final GsonBuilder gsonBuilder; public final Gson gson; public OnCloseCallback onCloseCallback; public final Boolean onConnect; public ReconnectCallback reconnectCallback; - private HashMap> requests; - private HashMap> results; + public static ProviderMap results = new ProviderMap<>(); + public static ProviderMap requests = new ProviderMap<>(); private HashSet handlers; - public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { + public ClientWebSocketService(String address, int i) throws SSLException { super(createURL(address)); - requests = new HashMap<>(); - results = new HashMap<>(); handlers = new HashSet<>(); - this.gsonBuilder = gsonBuilder; - this.gsonBuilder.registerTypeAdapter(WebSocketRequest.class, new JsonRequestAdapter(this)); - this.gsonBuilder.registerTypeAdapter(WebSocketEvent.class, new JsonResultAdapter(this)); - this.gsonBuilder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); - this.gson = gsonBuilder.create(); + this.gson = Launcher.gsonManager.gson; this.onConnect = true; } + public static void appendTypeAdapters(GsonBuilder builder) + { + builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); + builder.registerTypeAdapter(WebSocketEvent.class, new UniversalJsonAdapter<>(ClientWebSocketService.results)); + builder.registerTypeAdapter(WebSocketRequest.class, new UniversalJsonAdapter<>(ClientWebSocketService.requests)); + } + private static URI createURL(String address) { try { URI u = new URI(address); @@ -81,47 +84,31 @@ public interface ReconnectCallback { void onReconnect() throws IOException; } - public Class getRequestClass(String key) { - return requests.get(key); - } - - public Class getResultClass(String key) { - return results.get(key); - } - - public void registerRequest(String key, Class clazz) { - requests.put(key, clazz); - } - public void registerRequests() { } - public void registerResult(String key, Class clazz) { - results.put(key, clazz); - } - public void registerResults() { - registerResult("auth", AuthRequestEvent.class); - registerResult("checkServer", CheckServerRequestEvent.class); - registerResult("joinServer", JoinServerRequestEvent.class); - registerResult("launcher", LauncherRequestEvent.class); - registerResult("profileByUsername", ProfileByUsernameRequestEvent.class); - registerResult("profileByUUID", ProfileByUUIDRequestEvent.class); - registerResult("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class); - registerResult("profiles", ProfilesRequestEvent.class); - registerResult("setProfile", SetProfileRequestEvent.class); - registerResult("updateList", UpdateListRequestEvent.class); - registerResult("error", ErrorRequestEvent.class); - registerResult("update", UpdateRequestEvent.class); - registerResult("restoreSession", RestoreSessionRequestEvent.class); - registerResult("getSecureToken", GetSecureTokenRequestEvent.class); - registerResult("verifySecureToken", VerifySecureTokenRequestEvent.class); - registerResult("log", LogEvent.class); - registerResult("cmdExec", ExecCommandRequestEvent.class); - registerResult("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); - registerResult("exception", ExceptionEvent.class); - registerResult("register", RegisterRequestEvent.class); + results.register("auth", AuthRequestEvent.class); + results.register("checkServer", CheckServerRequestEvent.class); + results.register("joinServer", JoinServerRequestEvent.class); + results.register("launcher", LauncherRequestEvent.class); + results.register("profileByUsername", ProfileByUsernameRequestEvent.class); + results.register("profileByUUID", ProfileByUUIDRequestEvent.class); + results.register("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class); + results.register("profiles", ProfilesRequestEvent.class); + results.register("setProfile", SetProfileRequestEvent.class); + results.register("updateList", UpdateListRequestEvent.class); + results.register("error", ErrorRequestEvent.class); + results.register("update", UpdateRequestEvent.class); + results.register("restoreSession", RestoreSessionRequestEvent.class); + results.register("getSecureToken", GetSecureTokenRequestEvent.class); + results.register("verifySecureToken", VerifySecureTokenRequestEvent.class); + results.register("log", LogEvent.class); + results.register("cmdExec", ExecCommandRequestEvent.class); + results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); + results.register("exception", ExceptionEvent.class); + results.register("register", RegisterRequestEvent.class); } public void registerHandler(EventHandler eventHandler) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java deleted file mode 100644 index 18946738..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonRequestAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -package pro.gravit.launcher.request.websockets; - -import java.lang.reflect.Type; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import pro.gravit.utils.helper.LogHelper; - -public class JsonRequestAdapter implements JsonSerializer, JsonDeserializer { - private final ClientWebSocketService service; - private static final String PROP_NAME = "type"; - - public JsonRequestAdapter(ClientWebSocketService service) { - this.service = service; - } - - @Override - public WebSocketRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = service.getRequestClass(typename); - if (cls == null) { - LogHelper.error("Request type %s not found", typename); - } - - - return (WebSocketRequest) context.deserialize(json, cls); - } - - @Override - public JsonElement serialize(WebSocketRequest src, Type typeOfSrc, JsonSerializationContext context) { - // note : won't work, you must delegate this - JsonObject jo = context.serialize(src).getAsJsonObject(); - - String classPath = src.getType(); - jo.add(PROP_NAME, new JsonPrimitive(classPath)); - - return jo; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java deleted file mode 100644 index 2c057dd7..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/JsonResultAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -package pro.gravit.launcher.request.websockets; - -import java.lang.reflect.Type; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import pro.gravit.launcher.request.WebSocketEvent; -import pro.gravit.utils.helper.LogHelper; - -public class JsonResultAdapter implements JsonSerializer, JsonDeserializer { - private final ClientWebSocketService service; - private static final String PROP_NAME = "type"; - - public JsonResultAdapter(ClientWebSocketService service) { - this.service = service; - } - - @Override - public WebSocketEvent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = service.getResultClass(typename); - if (cls == null) { - LogHelper.error("Result type %s not found", typename); - } - - - return (WebSocketEvent) context.deserialize(json, cls); - } - - @Override - public JsonElement serialize(WebSocketEvent src, Type typeOfSrc, JsonSerializationContext context) { - // note : won't work, you must delegate this - JsonObject jo = context.serialize(src).getAsJsonObject(); - - String classPath = src.getType(); - jo.add(PROP_NAME, new JsonPrimitive(classPath)); - - return jo; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 71161e8e..79453c73 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -20,8 +20,8 @@ public class StandartClientWebSocketService extends ClientWebSocketService { public WaitEventHandler waitEventHandler = new WaitEventHandler(); - public StandartClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { - super(gsonBuilder, address, i); + public StandartClientWebSocketService(String address, int i) throws SSLException { + super(address, i); } public class RequestFuture implements Future { @@ -109,7 +109,7 @@ public RequestFuture asyncSendRequest(WebSocketRequest request) throws IOExcepti public static StandartClientWebSocketService initWebSockets(String address, boolean async) { StandartClientWebSocketService service; try { - service = new StandartClientWebSocketService(CommonHelper.newBuilder(), address, 5000); + service = new StandartClientWebSocketService(address, 5000); } catch (SSLException e) { throw new SecurityException(e); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java index a98a592c..05d3e899 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketRequest.java @@ -1,5 +1,7 @@ package pro.gravit.launcher.request.websockets; -public interface WebSocketRequest { +import pro.gravit.utils.TypeSerializeInterface; + +public interface WebSocketRequest extends TypeSerializeInterface { String getType(); } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/TypeSerializeInterface.java b/LauncherCore/src/main/java/pro/gravit/utils/TypeSerializeInterface.java new file mode 100644 index 00000000..41bd9bfe --- /dev/null +++ b/LauncherCore/src/main/java/pro/gravit/utils/TypeSerializeInterface.java @@ -0,0 +1,5 @@ +package pro.gravit.utils; + +public interface TypeSerializeInterface { + String getType(); +} diff --git a/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java b/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java index 0fcd1283..e5b0204a 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java @@ -41,11 +41,13 @@ public R deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext } @Override + @SuppressWarnings("unchecked") public JsonElement serialize(R src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jo = context.serialize(src).getAsJsonObject(); - - @SuppressWarnings("unchecked") String classPath = providerMap.getName((Class) src.getClass()); + if (classPath == null && src instanceof TypeSerializeInterface) { + classPath = ((TypeSerializeInterface) src).getType(); + } jo.add(PROP_NAME, new JsonPrimitive(classPath)); return jo; diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapperGsonManager.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapperGsonManager.java index b67da826..b3ee9806 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapperGsonManager.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapperGsonManager.java @@ -3,10 +3,12 @@ import com.google.gson.GsonBuilder; import pro.gravit.launcher.managers.GsonManager; +import pro.gravit.launcher.request.websockets.ClientWebSocketService; public class ServerWrapperGsonManager extends GsonManager { @Override public void registerAdapters(GsonBuilder builder) { super.registerAdapters(builder); + ClientWebSocketService.appendTypeAdapters(builder); } } From 2c9a9631f58f64a83fd6e18801a41bfa0521e47a Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Wed, 3 Jul 2019 14:56:30 +0300 Subject: [PATCH 58/70] =?UTF-8?q?[FIX]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=201.14.1=20=D0=B8=201.14.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launcher/profiles/ClientProfile.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 7622aa21..a6a53227 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -35,7 +35,9 @@ public enum Version { MC113("1.13", 393), MC1131("1.13.1", 401), MC1132("1.13.2", 402), - MC114("1.14", 477); + MC114("1.14", 477), + MC1141("1.14.1", 480), + MC1142("1.14.2", 485); private static final Map VERSIONS; static { From 493fbf8f2b3c65002ab66f3cd58a6807951d1d09 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Wed, 3 Jul 2019 15:12:20 +0300 Subject: [PATCH 59/70] =?UTF-8?q?[FIX]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=201.14.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launcher/profiles/ClientProfile.java | 3 ++- .../src/main/java/pro/gravit/utils/helper/IOHelper.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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 a6a53227..4762efb5 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -37,7 +37,8 @@ public enum Version { MC1132("1.13.2", 402), MC114("1.14", 477), MC1141("1.14.1", 480), - MC1142("1.14.2", 485); + MC1142("1.14.2", 485), + MC1143("1.14.3", 490); private static final Map VERSIONS; static { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java index 4864c6ed..77b34f1b 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java @@ -62,6 +62,7 @@ import pro.gravit.launcher.LauncherAPI; public final class IOHelper { + public static final long MB32 = 1 << 25; private static final class DeleteDirVisitor extends SimpleFileVisitor { private final Path dir; private final boolean self; From 67662dfdac80b85c523fb15c2d3619c302e5e8d9 Mon Sep 17 00:00:00 2001 From: LoomeL <44950511+LoomeL@users.noreply.github.com> Date: Wed, 3 Jul 2019 19:31:35 +0600 Subject: [PATCH 60/70] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B2=D0=BE=D0=B5=D0=B9=20jvm?= =?UTF-8?q?=20=D0=B2=20runtime=20(#302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Signed-off-by: LoomeL * Загрузка своей JVM * Поправка настройки по умолчанию --- Launcher/runtime/config.js | 6 +++ Launcher/runtime/dialog/dialog.js | 61 ++++++++++++++++++++++--------- Launcher/runtime/init.js | 12 ++++++ 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/Launcher/runtime/config.js b/Launcher/runtime/config.js index 992277a5..7966e1ee 100644 --- a/Launcher/runtime/config.js +++ b/Launcher/runtime/config.js @@ -16,6 +16,12 @@ var config = { autoEnterDefault: false, // Should autoEnter be enabled by default? fullScreenDefault: false, // Should fullScreen be enabled by default? ramDefault: 1024, // Default RAM amount (0 for auto) + + jvm: { + enable: false, + jvmMustdie32Dir: "jre-8u202-win32", + jvmMustdie64Dir: "jre-8u202-win64", + } }; DirBridge.dir = DirBridge.getLauncherDir(config.dir); diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 631d3744..1c23beb4 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -305,26 +305,51 @@ function doAuth(login, rsaPassword, auth_type) { function doUpdate(profile, pp, accessToken) { var digest = profile.isUpdateFastCheck(); overlay.swap(0, update.overlay, function(event) { - - update.resetOverlay("Обновление файлов ресурсов"); - var assetDirName = profile.getAssetDir(); - var assetDir = settings.updatesDir.resolve(assetDirName); - var assetMatcher = profile.getAssetUpdateMatcher(); - makeSetProfileRequest(profile, function() { - ClientLauncher.setProfile(profile); - makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { - settings.putHDir(assetDirName, assetDir, assetHDir.hdir); - - update.resetOverlay("Обновление файлов клиента"); - var clientDirName = profile.getDir(); - var clientDir = settings.updatesDir.resolve(clientDirName); - var clientMatcher = profile.getClientUpdateMatcher(); - makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { - settings.putHDir(clientDirName, clientDir, clientHDir.hdir); - doLaunchClient(assetDir, assetHDir.hdir, clientDir, clientHDir.hdir, profile, pp, accessToken); + if (config.jvm.enable) { + makeSetProfileRequest(profile, function() { + ClientLauncher.setProfile(profile); + var jvmDir = settings.updatesDir.resolve(jvmDirName); + update.resetOverlay("Обновление файлов JVM"); + makeUpdateRequest(jvmDirName, jvmDir, null, digest, function(jvmHDir) { + ClientLauncher.setJavaBinPath(jvmDir); + update.resetOverlay("Обновление файлов ресурсов"); + var assetDirName = profile.getAssetDir(); + var assetDir = settings.updatesDir.resolve(assetDirName); + var assetMatcher = profile.getAssetUpdateMatcher(); + makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { + settings.putHDir(assetDirName, assetDir, assetHDir.hdir); + update.resetOverlay("Обновление файлов клиента"); + var clientDirName = profile.getDir(); + var clientDir = settings.updatesDir.resolve(clientDirName); + var clientMatcher = profile.getClientUpdateMatcher(); + makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { + settings.putHDir(clientDirName, clientDir, clientHDir.hdir); + doLaunchClient(assetDir, assetHDir.hdir, clientDir, clientHDir.hdir, profile, pp, accessToken); + }); + }); }); }); - }); + } else { + update.resetOverlay("Обновление файлов ресурсов"); + var assetDirName = profile.getAssetDir(); + var assetDir = settings.updatesDir.resolve(assetDirName); + var assetMatcher = profile.getAssetUpdateMatcher(); + makeSetProfileRequest(profile, function() { + ClientLauncher.setProfile(profile); + makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { + settings.putHDir(assetDirName, assetDir, assetHDir.hdir); + + update.resetOverlay("Обновление файлов клиента"); + var clientDirName = profile.getDir(); + var clientDir = settings.updatesDir.resolve(clientDirName); + var clientMatcher = profile.getClientUpdateMatcher(); + makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { + settings.putHDir(clientDirName, clientDir, clientHDir.hdir); + doLaunchClient(assetDir, assetHDir.hdir, clientDir, clientHDir.hdir, profile, pp, accessToken); + }); + }); + }); + } }); } diff --git a/Launcher/runtime/init.js b/Launcher/runtime/init.js index 1db04f3b..9b1ccb43 100644 --- a/Launcher/runtime/init.js +++ b/Launcher/runtime/init.js @@ -79,6 +79,18 @@ function setRootParent(parent) { function start(args) { + if (config.jvm.enable) { + switch (JVMHelper.OS_TYPE) { + case JVMHelperOS.MUSTDIE: + jvmDirName = JVMHelper.OS_BITS === 32 ? config.jvm.jvmMustdie32Dir : + jvmDirName = JVMHelper.OS_BITS === 64 ? config.jvm.jvmMustdie64Dir : config.jvm.enable = false; + break; + default: + config.jvm.enable = false; + break; + } + } + LogHelper.debug("Setting FX properties"); java.lang.System.setProperty("prism.lcdtext", "false"); From 623a8f189cfc8cfedb6cf85138380fe50fb8e15a Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 4 Jul 2019 14:41:30 +0700 Subject: [PATCH 61/70] =?UTF-8?q?[FIX]=20DaoProvider=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 3b746f13..42513fe5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -497,6 +497,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException ProtectHandler.registerHandlers(); WebSocketService.registerResponses(); HWIDProvider.registerHWIDs(); + DaoProvider.registerProviders(); //LaunchServer.server = this; // Set command handler From 95d8cc461c481175262d8eadc084423f750777af Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 4 Jul 2019 16:19:07 +0700 Subject: [PATCH 62/70] =?UTF-8?q?[FIX]=20=D0=97=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=20=D0=BD=D0=B0=20https://mirror.gravit.pro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launchserver/LaunchServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 42513fe5..72c2f2ef 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -714,7 +714,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { // Create new config LogHelper.info("Creating LaunchServer config"); Config newConfig = new Config(); - newConfig.mirrors = new String[]{"http://mirror.gravitlauncher.ml/", "https://mirror.gravit.pro/"}; + newConfig.mirrors = new String[]{"https://mirror.gravit.pro/"}; newConfig.launch4j = new ExeConf(); newConfig.launch4j.enabled = true; newConfig.launch4j.copyright = "© GravitLauncher Team"; From fd9e2f9bd88d8672ac6f24ead8cd68b0b7225f03 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 17:39:17 +0700 Subject: [PATCH 63/70] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20Legacy=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launchserver/LaunchServer.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 72c2f2ef..4e898384 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -142,11 +142,6 @@ public AuthProviderPair getAuthProviderPair() { public Map components; - // Misc options - public int threadCount; - - public int threadCoreCount; - public ExeConf launch4j; public NettyConfig netty; public GuardLicenseConf guardLicense; @@ -752,9 +747,6 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.launcher = new LauncherConf(); newConfig.launcher.guardType = "no"; - newConfig.threadCoreCount = 0; // on your own - newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); - newConfig.enabledRadon = true; newConfig.genMappings = true; newConfig.enabledProGuard = true; From 752fb9e87932f3b4949dcbd5c16c8902a3b874e3 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 17:58:25 +0700 Subject: [PATCH 64/70] =?UTF-8?q?[FEATURE]=20=D0=90=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/utils/command/Command.java | 26 +++++++++++++++++++ .../utils/command/JLineCommandHandler.java | 20 +++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java index 6deff0d9..ebeb96dc 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java @@ -1,7 +1,10 @@ package pro.gravit.utils.command; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; +import org.jline.reader.Candidate; import pro.gravit.utils.helper.VerifyHelper; public abstract class Command { @@ -29,6 +32,29 @@ protected static UUID parseUUID(String s) throws CommandException { public abstract String getUsageDescription(); + public Candidate buildCandidate(CommandHandler.Category category, String commandName) + { + return new Candidate(commandName); + } + + public List complete(List words, int wordIndex, String word) + { + return new ArrayList<>(); + } + + public List subCommandComplete(String word, List commands) + { + List candidates = new ArrayList<>(); + for(String s : commands) + { + if(word.startsWith(s)) + { + candidates.add(new Candidate(s)); + } + } + return candidates; + } + public abstract void invoke(String... args) throws Exception; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java index 97566b37..a795c571 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java @@ -36,12 +36,20 @@ public class JLineConsoleCompleter implements Completer { @Override public void complete(LineReader reader, ParsedLine line, List candidates) { String completeWord = line.word(); - if (line.wordIndex() != 0) return; - walk((category, name, command) -> { - if (name.startsWith(completeWord)) { - candidates.add(new Candidate(name)); - } - }); + if (line.wordIndex() == 0) + { + walk((category, name, command) -> { + if (name.startsWith(completeWord)) { + candidates.add(command.buildCandidate(category, name)); + } + }); + } + else + { + Command target = findCommand(line.words().get(0)); + List candidates1 = target.complete(line.words(), line.wordIndex(), completeWord); + candidates.addAll(candidates1); + } } } From 5b7ae04fbdd247b865b4819cd960bffbb5931d12 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 18:42:29 +0700 Subject: [PATCH 65/70] =?UTF-8?q?[FEATURE]=20=D0=A1=D1=83=D0=B1=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B=20=D0=B8=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=B8=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/utils/command/Command.java | 39 ++++++++++++------- .../utils/command/JLineCommandHandler.java | 4 +- .../pro/gravit/utils/command/SubCommand.java | 13 +++++++ 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 LauncherCore/src/main/java/pro/gravit/utils/command/SubCommand.java diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java index ebeb96dc..10d03a4f 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java @@ -1,14 +1,12 @@ package pro.gravit.utils.command; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; import org.jline.reader.Candidate; import pro.gravit.utils.helper.VerifyHelper; public abstract class Command { - + public Map childCommands = new HashMap<>(); protected static String parseUsername(String username) throws CommandException { try { @@ -39,20 +37,31 @@ public Candidate buildCandidate(CommandHandler.Category category, String command public List complete(List words, int wordIndex, String word) { - return new ArrayList<>(); + if(wordIndex == 0) + { + List candidates = new ArrayList<>(); + childCommands.forEach((k,v) -> { + if(k.startsWith(word)) + { + candidates.add(new Candidate(k)); + } + }); + return candidates; + } + else + { + Command cmd = childCommands.get(words.get(0)); + if(cmd == null) return new ArrayList<>(); + return cmd.complete(words.subList(1, words.size()), wordIndex - 1, word); + } } - public List subCommandComplete(String word, List commands) + public void invokeSubcommands(String... args) throws Exception { - List candidates = new ArrayList<>(); - for(String s : commands) - { - if(word.startsWith(s)) - { - candidates.add(new Candidate(s)); - } - } - return candidates; + verifyArgs(args, 1); + Command command = childCommands.get(args[0]); + if(command == null) throw new CommandException(String.format("Unknown sub command: '%s'", args[0])); + command.invoke(Arrays.copyOfRange(args, 1, args.length)); } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java index a795c571..25767e33 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java @@ -1,6 +1,7 @@ package pro.gravit.utils.command; import java.io.IOException; +import java.util.Arrays; import java.util.List; import org.jline.reader.Candidate; @@ -47,7 +48,8 @@ public void complete(LineReader reader, ParsedLine line, List candida else { Command target = findCommand(line.words().get(0)); - List candidates1 = target.complete(line.words(), line.wordIndex(), completeWord); + List words = line.words(); + List candidates1 = target.complete(words.subList(1, words.size()), line.wordIndex() - 1, completeWord); candidates.addAll(candidates1); } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/SubCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/SubCommand.java new file mode 100644 index 00000000..54bd51fe --- /dev/null +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/SubCommand.java @@ -0,0 +1,13 @@ +package pro.gravit.utils.command; + +public abstract class SubCommand extends Command { + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return null; + } +} From 97bf5816c0c1311d6f28cc9c5a0819184d00e2c3 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 18:48:13 +0700 Subject: [PATCH 66/70] =?UTF-8?q?[FEATURE]=20=D0=A2=D0=B5=D1=81=D1=82=20?= =?UTF-8?q?=D1=81=D1=83=D0=B1=D0=BA=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4=20?= =?UTF-8?q?=D0=B2=20dumpSessions=20=D0=B8=20dumpEntryCache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/dump/DumpEntryCacheCommand.java | 79 +++++++++++-------- .../command/dump/DumpSessionsCommand.java | 50 +++++++----- 2 files changed, 78 insertions(+), 51 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java index 4fe70d76..fba4e1ff 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpEntryCacheCommand.java @@ -11,12 +11,59 @@ import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.handler.CachedAuthHandler; import pro.gravit.launchserver.command.Command; +import pro.gravit.utils.command.SubCommand; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; public class DumpEntryCacheCommand extends Command { public DumpEntryCacheCommand(LaunchServer server) { super(server); + childCommands.put("load", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args, 2); + AuthProviderPair pair = server.config.getAuthProviderPair(args[0]); + if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[0])); + if (!(pair.handler instanceof CachedAuthHandler)) + throw new UnsupportedOperationException("This command used only CachedAuthHandler"); + CachedAuthHandler authHandler = (CachedAuthHandler) pair.handler; + + LogHelper.info("CachedAuthHandler read from %s", args[0]); + int size_entry; + int size_username; + try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) { + EntryAndUsername entryAndUsername = Launcher.gsonManager.configGson.fromJson(reader, EntryAndUsername.class); + size_entry = entryAndUsername.entryCache.size(); + size_username = entryAndUsername.usernameCache.size(); + authHandler.loadEntryCache(entryAndUsername.entryCache); + authHandler.loadUsernameCache(entryAndUsername.usernameCache); + + } + LogHelper.subInfo("Readed %d entryCache %d usernameCache", size_entry, size_username); + } + }); + childCommands.put("unload", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args, 2); + AuthProviderPair pair = server.config.getAuthProviderPair(args[0]); + if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[0])); + if (!(pair.handler instanceof CachedAuthHandler)) + throw new UnsupportedOperationException("This command used only CachedAuthHandler"); + CachedAuthHandler authHandler = (CachedAuthHandler) pair.handler; + + LogHelper.info("CachedAuthHandler write to %s", args[1]); + Map entryCache = authHandler.getEntryCache(); + Map usernamesCache = authHandler.getUsernamesCache(); + EntryAndUsername serializable = new EntryAndUsername(); + serializable.entryCache = entryCache; + serializable.usernameCache = usernamesCache; + try (Writer writer = IOHelper.newWriter(Paths.get(args[1]))) { + Launcher.gsonManager.configGson.toJson(serializable, writer); + } + LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size()); + } + }); } @Override @@ -31,37 +78,7 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { - verifyArgs(args, 3); - AuthProviderPair pair = server.config.getAuthProviderPair(args[1]); - if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1])); - if (!(pair.handler instanceof CachedAuthHandler)) - throw new UnsupportedOperationException("This command used only CachedAuthHandler"); - CachedAuthHandler authHandler = (CachedAuthHandler) pair.handler; - if (args[0].equals("unload")) { - LogHelper.info("CachedAuthHandler write to %s", args[2]); - Map entryCache = authHandler.getEntryCache(); - Map usernamesCache = authHandler.getUsernamesCache(); - EntryAndUsername serializable = new EntryAndUsername(); - serializable.entryCache = entryCache; - serializable.usernameCache = usernamesCache; - try (Writer writer = IOHelper.newWriter(Paths.get(args[1]))) { - Launcher.gsonManager.configGson.toJson(serializable, writer); - } - LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size()); - } else if (args[0].equals("load")) { - LogHelper.info("CachedAuthHandler read from %s", args[1]); - int size_entry; - int size_username; - try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) { - EntryAndUsername entryAndUsername = Launcher.gsonManager.configGson.fromJson(reader, EntryAndUsername.class); - size_entry = entryAndUsername.entryCache.size(); - size_username = entryAndUsername.usernameCache.size(); - authHandler.loadEntryCache(entryAndUsername.entryCache); - authHandler.loadUsernameCache(entryAndUsername.usernameCache); - - } - LogHelper.subInfo("Readed %d entryCache %d usernameCache", size_entry, size_username); - } + invokeSubcommands(args); } public class EntryAndUsername { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java index 234b72d2..350e7515 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dump/DumpSessionsCommand.java @@ -13,12 +13,41 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.launchserver.socket.Client; +import pro.gravit.utils.command.SubCommand; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; public class DumpSessionsCommand extends Command { public DumpSessionsCommand(LaunchServer server) { super(server); + childCommands.put("load", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args, 1); + LogHelper.info("Sessions read from %s", args[0]); + int size; + try (Reader reader = IOHelper.newReader(Paths.get(args[0]))) { + Type setType = new TypeToken>() { + }.getType(); + Set clientSet = Launcher.gsonManager.configGson.fromJson(reader, setType); + size = clientSet.size(); + server.sessionManager.loadSessions(clientSet); + } + LogHelper.subInfo("Readed %d sessions", size); + } + }); + childCommands.put("unload", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args, 1); + LogHelper.info("Sessions write to %s", args[0]); + Set clientSet = server.sessionManager.getSessions(); + try (Writer writer = IOHelper.newWriter(Paths.get(args[0]))) { + Launcher.gsonManager.configGson.toJson(clientSet, writer); + } + LogHelper.subInfo("Write %d sessions", clientSet.size()); + } + }); } @Override @@ -33,25 +62,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { - verifyArgs(args, 2); - if (args[0].equals("unload")) { - LogHelper.info("Sessions write to %s", args[1]); - Set clientSet = server.sessionManager.getSessions(); - try (Writer writer = IOHelper.newWriter(Paths.get(args[1]))) { - Launcher.gsonManager.configGson.toJson(clientSet, writer); - } - LogHelper.subInfo("Write %d sessions", clientSet.size()); - } else if (args[0].equals("load")) { - LogHelper.info("Sessions read from %s", args[1]); - int size; - try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) { - Type setType = new TypeToken>() { - }.getType(); - Set clientSet = Launcher.gsonManager.configGson.fromJson(reader, setType); - size = clientSet.size(); - server.sessionManager.loadSessions(clientSet); - } - LogHelper.subInfo("Readed %d sessions", size); - } + invokeSubcommands(args); } } From aac9aef821d375f5561f5fd0b296d6d59b729e7f Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 19:17:23 +0700 Subject: [PATCH 67/70] =?UTF-8?q?[FEATURE]=20Help=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=81=D1=83=D0=B1=D0=BA=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/command/basic/HelpCommand.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java index 77c819d1..95f00723 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java @@ -1,5 +1,6 @@ package pro.gravit.utils.command.basic; +import java.util.Arrays; import java.util.Map.Entry; import org.fusesource.jansi.Ansi; @@ -13,7 +14,7 @@ public final class HelpCommand extends Command { private CommandHandler handler; - private static void printCommand(String name, Command command) { + public static void printCommand(String name, Command command) { String args = command.getArgsDescription(); //LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()); LogHelper.rawLog(() -> FormatHelper.rawFormat(LogHelper.Level.INFO, LogHelper.getDataTime(), true) + String.format("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()), () -> { @@ -31,6 +32,27 @@ private static void printCommand(String name, Command command) { }, () -> LogHelper.htmlFormatLog(LogHelper.Level.INFO, LogHelper.getDataTime(), String.format("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()), true)); } + public static void printSubCommandsHelp(String base, Command command) + { + command.childCommands.forEach((k, v) -> { + printCommand(base.concat(" ").concat(k), v); + }); + } + + public static void printSubCommandsHelp(String name, String[] args, Command command) throws CommandException + { + if(args.length == 0) + { + printSubCommandsHelp(name, command); + } + else + { + Command child = command.childCommands.get(args[0]); + if(child == null) throw new CommandException(String.format("Unknown sub command: '%s'", args[0])); + printSubCommandsHelp(name.concat(" ").concat(args[0]), Arrays.copyOfRange(args,1 , args.length), child); + } + } + private static void printCategory(String name, String description) { if (description != null) LogHelper.info("Category: %s - %s", name, description); else LogHelper.info("Category: %s", name); @@ -58,7 +80,9 @@ public void invoke(String... args) throws CommandException { } // Print command help - printCommand(args[0]); + if(args.length == 1) + printCommand(args[0]); + printSubCommandsHelp(args[0], Arrays.copyOfRange(args, 1 , args.length), handler.lookup(args[0])); } private void printCommand(String name) throws CommandException { From 198b7037d5f64e8372ac2b1c5e648141e769eb68 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 19:54:10 +0700 Subject: [PATCH 68/70] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20Reconfigurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 3 +- .../gravit/launchserver/Reconfigurable.java | 8 ++- .../auth/provider/RejectAuthProvider.java | 36 ++++-------- .../gravit/launchserver/command/Command.java | 8 +++ .../command/handler/CommandHandler.java | 2 - .../command/service/ConfigCommand.java | 9 +-- .../command/service/ConfigHelpCommand.java | 28 ---------- .../command/service/ConfigListCommand.java | 25 --------- .../manangers/ReconfigurableManager.java | 56 ++++++++++++++----- .../pro/gravit/utils/command/Command.java | 10 +++- 10 files changed, 82 insertions(+), 103 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigHelpCommand.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigListCommand.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 4e898384..fbbe1527 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -510,7 +510,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException localCommandHandler = new StdCommandHandler(true); LogHelper.warning("JLine2 isn't in classpath, using std"); } - pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler, this); commandHandler = localCommandHandler; // Set key pair @@ -607,6 +606,8 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException Arrays.stream(config.mirrors).forEach(mirrorManager::addMirror); + pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler, this); + // init modules modulesManager.initModules(); if (config.components != null) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/Reconfigurable.java b/LaunchServer/src/main/java/pro/gravit/launchserver/Reconfigurable.java index 45ee0193..acb00ba4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/Reconfigurable.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/Reconfigurable.java @@ -1,7 +1,9 @@ package pro.gravit.launchserver; -public interface Reconfigurable { - void reconfig(String action, String[] args); +import pro.gravit.utils.command.Command; - void printConfigHelp(); +import java.util.Map; + +public interface Reconfigurable { + Map getCommands(); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java index 4a707288..f6025060 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -1,9 +1,13 @@ package pro.gravit.launchserver.auth.provider; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import pro.gravit.launchserver.Reconfigurable; import pro.gravit.launchserver.auth.AuthException; +import pro.gravit.utils.command.Command; +import pro.gravit.utils.command.SubCommand; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -36,31 +40,15 @@ public void close() { } @Override - public void reconfig(String action, String[] args) { - switch (action) { - case "message": + public Map getCommands() { + Map commands = new HashMap<>(); + commands.put("message", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { message = args[0]; LogHelper.info("New reject message: %s", message); - break; - case "whitelist.add": - if (whitelist == null) whitelist = new ArrayList<>(); - whitelist.add(args[0]); - break; - case "whitelist.remove": - if (whitelist == null) whitelist = new ArrayList<>(); - whitelist.remove(args[0]); - break; - case "whitelist.clear": - whitelist.clear(); - break; - } - } - - @Override - public void printConfigHelp() { - LogHelper.info("message [new message] - set message"); - LogHelper.info("whitelist.add [username] - add username to whitelist"); - LogHelper.info("whitelist.remove [username] - remove username into whitelist"); - LogHelper.info("whitelist.clear - clear whitelist"); + } + }); + return commands; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/Command.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/Command.java index 83c28838..32ed911e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/Command.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/Command.java @@ -2,6 +2,8 @@ import pro.gravit.launchserver.LaunchServer; +import java.util.Map; + public abstract class Command extends pro.gravit.utils.command.Command { @@ -9,6 +11,12 @@ public abstract class Command extends pro.gravit.utils.command.Command { protected Command(LaunchServer server) { + super(); + this.server = server; + } + + public Command(Map childCommands, LaunchServer server) { + super(childCommands); this.server = server; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 69c16655..7af943e6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -105,8 +105,6 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand service.registerCommand("reloadAll", new ReloadAllCommand(server)); service.registerCommand("reloadList", new ReloadListCommand(server)); service.registerCommand("config", new ConfigCommand(server)); - service.registerCommand("configHelp", new ConfigHelpCommand(server)); - service.registerCommand("configList", new ConfigListCommand(server)); service.registerCommand("serverStatus", new ServerStatusCommand(server)); service.registerCommand("checkInstall", new CheckInstallCommand(server)); service.registerCommand("multi", new MultiCommand(server)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigCommand.java index 3c546609..ce6a295e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigCommand.java @@ -2,11 +2,12 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; +import pro.gravit.launchserver.manangers.ReconfigurableManager; import pro.gravit.utils.helper.LogHelper; public class ConfigCommand extends Command { public ConfigCommand(LaunchServer server) { - super(server); + super(server.reconfigurableManager.getCommands(), server); } @Override @@ -21,10 +22,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { - verifyArgs(args, 2); - LogHelper.info("Call %s module %s action", args[0], args[1]); - String[] new_args = new String[args.length - 2]; - System.arraycopy(args, 2, new_args, 0, args.length - 2); - server.reconfigurableManager.call(args[0], args[1], new_args); + invokeSubcommands(args); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigHelpCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigHelpCommand.java deleted file mode 100644 index b1a0b749..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigHelpCommand.java +++ /dev/null @@ -1,28 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.LogHelper; - -public class ConfigHelpCommand extends Command { - public ConfigHelpCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return "[name]"; - } - - @Override - public String getUsageDescription() { - return "print help for config command"; - } - - @Override - public void invoke(String... args) throws Exception { - verifyArgs(args, 1); - LogHelper.info("Help %s module", args[0]); - server.reconfigurableManager.printHelp(args[0]); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigListCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigListCommand.java deleted file mode 100644 index 9af0aee9..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ConfigListCommand.java +++ /dev/null @@ -1,25 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; - -public class ConfigListCommand extends Command { - public ConfigListCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return "[name]"; - } - - @Override - public String getUsageDescription() { - return "print help for config command"; - } - - @Override - public void invoke(String... args) { - server.reconfigurableManager.printReconfigurables(); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java index 59e4d054..227ec8d0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java @@ -1,35 +1,65 @@ package pro.gravit.launchserver.manangers; import java.util.HashMap; +import java.util.Map; import java.util.Objects; import pro.gravit.launchserver.Reconfigurable; +import pro.gravit.utils.command.Command; +import pro.gravit.utils.command.CommandException; +import pro.gravit.utils.command.basic.HelpCommand; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.VerifyHelper; public class ReconfigurableManager { - private final HashMap RECONFIGURABLE = new HashMap<>(); + private class ReconfigurableVirtualCommand extends Command { + public ReconfigurableVirtualCommand(Map childs) { + super(childs); + } + + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return null; + } + + @Override + public void invoke(String... args) throws Exception { + invokeSubcommands(args); + } + } + private final HashMap RECONFIGURABLE = new HashMap<>(); public void registerReconfigurable(String name, Reconfigurable reconfigurable) { - VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), Objects.requireNonNull(reconfigurable, "adapter"), + VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), new ReconfigurableVirtualCommand(reconfigurable.getCommands()), String.format("Reloadable has been already registered: '%s'", name)); } - public Reconfigurable unregisterReconfigurable(String name) { - return RECONFIGURABLE.remove(name); + public void unregisterReconfigurable(String name) { + RECONFIGURABLE.remove(name); } - public void printHelp(String name) { - RECONFIGURABLE.get(name.toLowerCase()).printConfigHelp(); + public void call(String name, String action, String[] args) throws Exception + { + Command commands = RECONFIGURABLE.get(name); + if(commands == null) throw new CommandException(String.format("Reconfigurable %s not found", name)); + Command command = commands.childCommands.get(action); + if(command == null) throw new CommandException(String.format("Action %s.%s not found", name, action)); + command.invoke(args); } - public void call(String name, String action, String[] args) { - RECONFIGURABLE.get(name.toLowerCase()).reconfig(action.toLowerCase(), args); + public void printHelp(String name) throws CommandException + { + Command commands = RECONFIGURABLE.get(name); + if(commands == null) throw new CommandException(String.format("Reconfigurable %s not found", name)); + HelpCommand.printSubCommandsHelp(name, commands); } - - public void printReconfigurables() { - LogHelper.info("Print reconfigurables"); - RECONFIGURABLE.forEach((k, v) -> LogHelper.subInfo(k)); - LogHelper.info("Found %d reconfigurables", RECONFIGURABLE.size()); + public Map getCommands() + { + return RECONFIGURABLE; } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java index 10d03a4f..aa1470ac 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java @@ -6,7 +6,15 @@ import pro.gravit.utils.helper.VerifyHelper; public abstract class Command { - public Map childCommands = new HashMap<>(); + public Map childCommands; + + public Command() { + childCommands = new HashMap<>(); + } + + public Command(Map childCommands) { + this.childCommands = childCommands; + } protected static String parseUsername(String username) throws CommandException { try { From e1f07cdfc8576ec407e6a0c80baec7c665222eba Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 19:56:26 +0700 Subject: [PATCH 69/70] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB?= =?UTF-8?q?=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 dba4f013..f7cf0576 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit dba4f0132cdb49cbc6cb7356fb6a54a063aba8b5 +Subproject commit f7cf0576033cd413b99e8180610d586e370c9351 From b67d1d502943b674e0772e2c5bc0e9c864db9248 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 6 Jul 2019 20:26:16 +0700 Subject: [PATCH 70/70] [ANY] 5.0.5b1 Stable --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index be65d7db..08176b4b 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -22,7 +22,7 @@ public final class Version { public final Type release; public static final int MAJOR = 5; public static final int MINOR = 0; - public static final int PATCH = 4; + public static final int PATCH = 5; public static final int BUILD = 1; public static final Version.Type RELEASE = Version.Type.STABLE;