From 65dbab45818bf0abebacb0194cd0cf807a2abab1 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 8 Mar 2019 13:13:16 +0300 Subject: [PATCH 01/18] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= =?UTF-8?q?.?= 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 d4320ce2..27cf43d1 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit d4320ce29b8a142a75b86237139e92a72e00b481 +Subproject commit 27cf43d1a95465d313eddc8e8386352a1339ce8d From 6033703b9b8764fdfa570ab7f50de94bcfa34ebc Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 8 Mar 2019 13:17:05 +0300 Subject: [PATCH 02/18] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= =?UTF-8?q?.?= 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 27cf43d1..b7fbe50c 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 27cf43d1a95465d313eddc8e8386352a1339ce8d +Subproject commit b7fbe50c08a3e274aadb93292fed6d05918647b3 From 920a15a6b2d4839bd82f7a9462cfba16febb8a21 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 8 Mar 2019 18:02:54 +0700 Subject: [PATCH 03/18] =?UTF-8?q?[FEATURE]=20=D0=A1=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20HWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/HWID.java | 2 ++ .../main/java/ru/gravit/launcher/OshiHWID.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libLauncher/src/main/java/ru/gravit/launcher/HWID.java b/libLauncher/src/main/java/ru/gravit/launcher/HWID.java index 4daa1c31..c72e8e74 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/HWID.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/HWID.java @@ -5,5 +5,7 @@ public interface HWID { int getLevel(); //Уровень доверия, насколько уникальные значения + int compare(HWID hwid); + boolean isNull(); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java index 1d13951d..a6877ae3 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java @@ -29,6 +29,21 @@ public int getLevel() //Уровень доверия, насколько уни return result; } + @Override + public int compare(HWID hwid) { + if(hwid instanceof OshiHWID) + { + int rate = 0; + OshiHWID oshi = (OshiHWID) hwid; + if(Math.abs(oshi.totalMemory - totalMemory) < 1024*1024) rate+=10; + if(oshi.HWDiskSerial.equals(HWDiskSerial)) rate+=50; + if(oshi.processorID.equals(processorID)) rate+=26; + if(oshi.serialNumber.equals(serialNumber)) rate+=15; + return rate; + } + return 0; + } + @Override public boolean isNull() { return getLevel() < 2; From 7f61f21a0b1a57b483814facf1095bd013a0e167 Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 8 Mar 2019 18:15:01 +0700 Subject: [PATCH 04/18] =?UTF-8?q?[FEATURE]=20compareMode=20=D0=B2=20HWIDHa?= =?UTF-8?q?ndler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/hwid/MysqlHWIDHandler.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index b3852c7e..ce907c4e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -36,6 +36,11 @@ public class MysqlHWIDHandler extends HWIDHandler { private String banMessage; + private boolean compareMode = false; + //Using queryHWID "queryHwids": "SELECT * FROM `users_hwids` WHERE `totalMemory` = ? or `serialNumber` = ? or `HWDiskSerial` = ? or `processorID` = ?" + private int compare = 50; //При наборе схожести в 50 очков + private boolean oneCompareMode = false; + /* //Добавить поля hwid в базу с пользователями @@ -136,12 +141,22 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI a.setString(i + 1, CommonHelper.replace(paramsHwids[i], replaceParams)); } ResultSet set = a.executeQuery(); - if (set.next()) { + boolean isOne = false; + while(set.next()) { + if(!oneCompareMode) isOne = true; + OshiHWID db_hwid = new OshiHWID(); + db_hwid.serialNumber = set.getString(hwidFieldSerialNumber); + db_hwid.processorID = set.getString(hwidFieldProcessorID); + db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial); + db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory)); + if(hwid.compare(db_hwid) < compare) continue; + if(oneCompareMode) isOne = true; boolean isBanned = set.getBoolean(hwidFieldBanned); if (isBanned) { throw new HWIDException(banMessage); } - } else { + } + if(isOne) { onUpdateInfo(hwid, username, c); } } catch (SQLException e) { From ec5ef7af4f8a54474cab19e3110af72a3c6552bf Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 8 Mar 2019 18:58:18 +0700 Subject: [PATCH 05/18] =?UTF-8?q?[REFRACTOR]=20=D0=9F=D1=80=D0=B5=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?CommandHandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 11 +- .../gravit/launchserver/command/Command.java | 35 +-- .../command/auth/UUIDToUsernameCommand.java | 2 +- .../command/auth/UsernameToUUIDCommand.java | 2 +- .../command/basic/HelpCommand.java | 6 +- .../command/handler/CommandHandler.java | 225 ++++-------------- .../command/hash/DownloadClientCommand.java | 2 +- .../command/hash/IndexAssetCommand.java | 2 +- .../command/hash/UnindexAssetCommand.java | 2 +- libLauncher/build.gradle | 1 + .../java/ru/gravit/utils/command/Command.java | 40 ++++ .../utils}/command/CommandException.java | 2 +- .../gravit/utils/command/CommandHandler.java | 104 ++++++++ .../utils/command}/JLineCommandHandler.java | 7 +- .../utils/command}/StdCommandHandler.java | 7 +- .../ru/gravit/utils/helper/CommonHelper.java | 52 ++++ 16 files changed, 267 insertions(+), 233 deletions(-) create mode 100644 libLauncher/src/main/java/ru/gravit/utils/command/Command.java rename {LaunchServer/src/main/java/ru/gravit/launchserver => libLauncher/src/main/java/ru/gravit/utils}/command/CommandException.java (90%) create mode 100644 libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java rename {LaunchServer/src/main/java/ru/gravit/launchserver/command/handler => libLauncher/src/main/java/ru/gravit/utils/command}/JLineCommandHandler.java (86%) rename {LaunchServer/src/main/java/ru/gravit/launchserver/command/handler => libLauncher/src/main/java/ru/gravit/utils/command}/StdCommandHandler.java (75%) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 8631d732..6a7d1b76 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -18,9 +18,9 @@ import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.RejectAuthProvider; import ru.gravit.launchserver.binary.*; -import ru.gravit.launchserver.command.handler.CommandHandler; -import ru.gravit.launchserver.command.handler.JLineCommandHandler; -import ru.gravit.launchserver.command.handler.StdCommandHandler; +import ru.gravit.utils.command.CommandHandler; +import ru.gravit.utils.command.JLineCommandHandler; +import ru.gravit.utils.command.StdCommandHandler; import ru.gravit.launchserver.config.*; import ru.gravit.launchserver.manangers.*; import ru.gravit.launchserver.manangers.hook.AuthHookManager; @@ -349,12 +349,13 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE Class.forName("jline.Terminal"); // JLine2 available - localCommandHandler = new JLineCommandHandler(this); + localCommandHandler = new JLineCommandHandler(); LogHelper.info("JLine2 terminal enabled"); } catch (ClassNotFoundException ignored) { - localCommandHandler = new StdCommandHandler(this, true); + localCommandHandler = new StdCommandHandler(true); LogHelper.warning("JLine2 isn't in classpath, using std"); } + ru.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler); commandHandler = localCommandHandler; // Set key pair diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java index a69b023a..22817021 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java @@ -1,28 +1,12 @@ package ru.gravit.launchserver.command; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.VerifyHelper; import java.util.UUID; -public abstract class Command { - - protected static String parseUsername(String username) throws CommandException { - try { - return VerifyHelper.verifyUsername(username); - } catch (IllegalArgumentException e) { - throw new CommandException(e.getMessage()); - } - } - - - protected static UUID parseUUID(String s) throws CommandException { - try { - return UUID.fromString(s); - } catch (IllegalArgumentException ignored) { - throw new CommandException(String.format("Invalid UUID: '%s'", s)); - } - } +public abstract class Command extends ru.gravit.utils.command.Command { protected final LaunchServer server; @@ -31,19 +15,4 @@ protected static UUID parseUUID(String s) throws CommandException { protected Command(LaunchServer server) { this.server = server; } - - - public abstract String getArgsDescription(); // " [optional]" - - - public abstract String getUsageDescription(); - - - public abstract void invoke(String... args) throws Exception; - - - protected final void verifyArgs(String[] args, int min) throws CommandException { - if (args.length < min) - throw new CommandException("Command usage: " + getArgsDescription()); - } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java index 918a5e7f..75f7e774 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java @@ -2,7 +2,7 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.LogHelper; import java.io.IOException; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java index 24d226ac..ac3afaad 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java @@ -2,7 +2,7 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.LogHelper; import java.io.IOException; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java index 34dd6282..f4fb699f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.command.basic; import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.Command; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.LogHelper; import java.util.Map.Entry; -public final class HelpCommand extends Command { +public final class HelpCommand extends ru.gravit.launchserver.command.Command { private static void printCommand(String name, Command command) { String args = command.getArgsDescription(); LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index 1da94327..d92c4b2c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -2,7 +2,7 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.launchserver.command.auth.*; import ru.gravit.launchserver.command.basic.*; import ru.gravit.launchserver.command.dump.DumpEntryCacheCommand; @@ -13,6 +13,7 @@ import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; import ru.gravit.launchserver.command.service.*; +import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -22,191 +23,59 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; -public abstract class CommandHandler implements Runnable { - private static String[] parse(CharSequence line) throws CommandException { - boolean quoted = false; - boolean wasQuoted = false; - - // Read line char by char - Collection result = new LinkedList<>(); - StringBuilder builder = new StringBuilder(100); - for (int i = 0; i <= line.length(); i++) { - boolean end = i >= line.length(); - char ch = end ? '\0' : line.charAt(i); - - // Maybe we should read next argument? - if (end || !quoted && Character.isWhitespace(ch)) { - if (end && quoted) - throw new CommandException("Quotes wasn't closed"); - - // Empty args are ignored (except if was quoted) - if (wasQuoted || builder.length() > 0) - result.add(builder.toString()); - - // Reset file builder - wasQuoted = false; - builder.setLength(0); - continue; - } - - // Append next char - switch (ch) { - case '"': // "abc"de, "abc""de" also allowed - quoted = !quoted; - wasQuoted = true; - break; - case '\\': // All escapes, including spaces etc - if (i + 1 >= line.length()) - throw new CommandException("Escape character is not specified"); - char next = line.charAt(i + 1); - builder.append(next); - i++; - break; - default: // Default char, simply append - builder.append(ch); - break; - } - } - - // Return result as array - return result.toArray(new String[0]); - } - - private final Map commands = new ConcurrentHashMap<>(32); - - protected CommandHandler(LaunchServer server) { +public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler { + public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) + { + LaunchServer server = LaunchServer.server; // Register basic commands - registerCommand("help", new HelpCommand(server)); - registerCommand("version", new VersionCommand(server)); - registerCommand("build", new BuildCommand(server)); - registerCommand("stop", new StopCommand(server)); - registerCommand("restart", new RestartCommand(server)); - registerCommand("rebind", new RebindCommand(server)); - registerCommand("debug", new DebugCommand(server)); - registerCommand("clear", new ClearCommand(server)); - registerCommand("gc", new GCCommand(server)); - registerCommand("proguardClean", new ProguardCleanCommand(server)); - registerCommand("proguardDictRegen", new RegenProguardDictCommand(server)); - registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server)); - registerCommand("logConnections", new LogConnectionsCommand(server)); - registerCommand("loadModule", new LoadModuleCommand(server)); - registerCommand("modules", new ModulesCommand(server)); - registerCommand("test", new TestCommand(server)); + handler.registerCommand("help", new HelpCommand(server)); + handler.registerCommand("version", new VersionCommand(server)); + handler.registerCommand("build", new BuildCommand(server)); + handler.registerCommand("stop", new StopCommand(server)); + handler.registerCommand("restart", new RestartCommand(server)); + handler.registerCommand("rebind", new RebindCommand(server)); + handler.registerCommand("debug", new DebugCommand(server)); + handler.registerCommand("clear", new ClearCommand(server)); + handler.registerCommand("gc", new GCCommand(server)); + handler.registerCommand("proguardClean", new ProguardCleanCommand(server)); + handler.registerCommand("proguardDictRegen", new RegenProguardDictCommand(server)); + handler.registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server)); + handler.registerCommand("logConnections", new LogConnectionsCommand(server)); + handler.registerCommand("loadModule", new LoadModuleCommand(server)); + handler.registerCommand("modules", new ModulesCommand(server)); + handler.registerCommand("test", new TestCommand(server)); // Register sync commands - registerCommand("indexAsset", new IndexAssetCommand(server)); - registerCommand("unindexAsset", new UnindexAssetCommand(server)); - registerCommand("downloadAsset", new DownloadAssetCommand(server)); - registerCommand("downloadClient", new DownloadClientCommand(server)); - registerCommand("syncBinaries", new SyncBinariesCommand(server)); - registerCommand("syncUpdates", new SyncUpdatesCommand(server)); - registerCommand("syncProfiles", new SyncProfilesCommand(server)); + handler.registerCommand("indexAsset", new IndexAssetCommand(server)); + handler.registerCommand("unindexAsset", new UnindexAssetCommand(server)); + handler.registerCommand("downloadAsset", new DownloadAssetCommand(server)); + handler.registerCommand("downloadClient", new DownloadClientCommand(server)); + handler.registerCommand("syncBinaries", new SyncBinariesCommand(server)); + handler.registerCommand("syncUpdates", new SyncUpdatesCommand(server)); + handler.registerCommand("syncProfiles", new SyncProfilesCommand(server)); // Register auth commands - registerCommand("auth", new AuthCommand(server)); - registerCommand("usernameToUUID", new UsernameToUUIDCommand(server)); - registerCommand("uuidToUsername", new UUIDToUsernameCommand(server)); - registerCommand("ban", new BanCommand(server)); - registerCommand("unban", new UnbanCommand(server)); + handler.registerCommand("auth", new AuthCommand(server)); + handler.registerCommand("usernameToUUID", new UsernameToUUIDCommand(server)); + handler.registerCommand("uuidToUsername", new UUIDToUsernameCommand(server)); + handler.registerCommand("ban", new BanCommand(server)); + handler.registerCommand("unban", new UnbanCommand(server)); //Register dump commands - registerCommand("dumpSessions", new DumpSessionsCommand(server)); - registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); + handler.registerCommand("dumpSessions", new DumpSessionsCommand(server)); + handler.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); //Register service commands - registerCommand("reload", new ReloadCommand(server)); - registerCommand("reloadAll", new ReloadAllCommand(server)); - registerCommand("reloadList", new ReloadListCommand(server)); - registerCommand("config", new ConfigCommand(server)); - registerCommand("configHelp", new ConfigHelpCommand(server)); - registerCommand("configList", new ConfigListCommand(server)); - registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server)); - registerCommand("serverStatus", new ServerStatusCommand(server)); - registerCommand("checkInstall", new CheckInstallCommand(server)); - registerCommand("multi", new MultiCommand(server)); - registerCommand("getModulus", new GetModulusCommand(server)); - } - - - public abstract void bell() throws IOException; - - - public abstract void clear() throws IOException; - - - public final Map commandsMap() { - return Collections.unmodifiableMap(commands); - } - - - public final void eval(String line, boolean bell) { - LogHelper.info("Command '%s'", line); - - // Parse line to tokens - String[] args; - try { - args = parse(line); - } catch (Exception e) { - LogHelper.error(e); - return; - } - - // Evaluate command - eval(args, bell); - } - - - public final void eval(String[] args, boolean bell) { - if (args.length == 0) - return; - - // Measure start time and invoke command - Instant startTime = Instant.now(); - try { - lookup(args[0]).invoke(Arrays.copyOfRange(args, 1, args.length)); - } catch (Exception e) { - LogHelper.error(e); - } - - // Bell if invocation took > 1s - Instant endTime = Instant.now(); - if (bell && Duration.between(startTime, endTime).getSeconds() >= 5) - try { - bell(); - } catch (IOException e) { - LogHelper.error(e); - } - } - - - public final Command lookup(String name) throws CommandException { - Command command = commands.get(name); - if (command == null) - throw new CommandException(String.format("Unknown command: '%s'", name)); - return command; - } - - - public abstract String readLine() throws IOException; - - private void readLoop() throws IOException { - for (String line = readLine(); line != null; line = readLine()) - eval(line, true); - } - - - public final void registerCommand(String name, Command command) { - VerifyHelper.verifyIDName(name); - VerifyHelper.putIfAbsent(commands, name, Objects.requireNonNull(command, "command"), - String.format("Command has been already registered: '%s'", name)); - } - - @Override - public final void run() { - try { - readLoop(); - } catch (IOException e) { - LogHelper.error(e); - } + handler.registerCommand("reload", new ReloadCommand(server)); + handler.registerCommand("reloadAll", new ReloadAllCommand(server)); + handler.registerCommand("reloadList", new ReloadListCommand(server)); + handler.registerCommand("config", new ConfigCommand(server)); + handler.registerCommand("configHelp", new ConfigHelpCommand(server)); + handler.registerCommand("configList", new ConfigListCommand(server)); + handler.registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server)); + handler.registerCommand("serverStatus", new ServerStatusCommand(server)); + handler.registerCommand("checkInstall", new CheckInstallCommand(server)); + handler.registerCommand("multi", new MultiCommand(server)); + handler.registerCommand("getModulus", new GetModulusCommand(server)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java index 2d0a5a88..7886f1f3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -4,7 +4,7 @@ import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.HttpDownloader; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java index 4dfd6710..0d220e84 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java @@ -4,7 +4,7 @@ import com.google.gson.JsonObject; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java index 9bb0c797..b74f7c9d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java @@ -5,7 +5,7 @@ import com.google.gson.JsonParser; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.command.CommandException; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; diff --git a/libLauncher/build.gradle b/libLauncher/build.gradle index 0e527171..e5db09f7 100644 --- a/libLauncher/build.gradle +++ b/libLauncher/build.gradle @@ -3,5 +3,6 @@ dependencies { compileOnly 'org.fusesource.jansi:jansi:1.17.1' + compileOnly 'jline:jline:2.14.6' compile 'com.google.code.gson:gson:2.8.5' } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/Command.java b/libLauncher/src/main/java/ru/gravit/utils/command/Command.java new file mode 100644 index 00000000..7e594d50 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/utils/command/Command.java @@ -0,0 +1,40 @@ +package ru.gravit.utils.command; + +import ru.gravit.utils.helper.VerifyHelper; + +import java.util.UUID; + +public abstract class Command { + + + protected static String parseUsername(String username) throws CommandException { + try { + return VerifyHelper.verifyUsername(username); + } catch (IllegalArgumentException e) { + throw new CommandException(e.getMessage()); + } + } + + + protected static UUID parseUUID(String s) throws CommandException { + try { + return UUID.fromString(s); + } catch (IllegalArgumentException ignored) { + throw new CommandException(String.format("Invalid UUID: '%s'", s)); + } + } + + public abstract String getArgsDescription(); // " [optional]" + + + public abstract String getUsageDescription(); + + + public abstract void invoke(String... args) throws Exception; + + + protected final void verifyArgs(String[] args, int min) throws CommandException { + if (args.length < min) + throw new CommandException("Command usage: " + getArgsDescription()); + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/CommandException.java b/libLauncher/src/main/java/ru/gravit/utils/command/CommandException.java similarity index 90% rename from LaunchServer/src/main/java/ru/gravit/launchserver/command/CommandException.java rename to libLauncher/src/main/java/ru/gravit/utils/command/CommandException.java index 514a4571..ce2009b1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/CommandException.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/CommandException.java @@ -1,4 +1,4 @@ -package ru.gravit.launchserver.command; +package ru.gravit.utils.command; public final class CommandException extends Exception { private static final long serialVersionUID = -6588814993972117772L; diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java new file mode 100644 index 00000000..5d59e4cc --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java @@ -0,0 +1,104 @@ +package ru.gravit.utils.command; + +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; + +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +public abstract class CommandHandler implements Runnable { + private final Map commands = new ConcurrentHashMap<>(32); + + public final void eval(String line, boolean bell) { + LogHelper.info("Command '%s'", line); + + // Parse line to tokens + String[] args; + try { + args = CommonHelper.parseCommand(line); + } catch (Exception e) { + LogHelper.error(e); + return; + } + + // Evaluate command + eval(args, bell); + } + + + public final void eval(String[] args, boolean bell) { + if (args.length == 0) + return; + + // Measure start time and invoke command + Instant startTime = Instant.now(); + try { + lookup(args[0]).invoke(Arrays.copyOfRange(args, 1, args.length)); + } catch (Exception e) { + LogHelper.error(e); + } + + // Bell if invocation took > 1s + Instant endTime = Instant.now(); + if (bell && Duration.between(startTime, endTime).getSeconds() >= 5) + try { + bell(); + } catch (IOException e) { + LogHelper.error(e); + } + } + + + public final Command lookup(String name) throws CommandException { + Command command = commands.get(name); + if (command == null) + throw new CommandException(String.format("Unknown command: '%s'", name)); + return command; + } + + + public abstract String readLine() throws IOException; + + private void readLoop() throws IOException { + for (String line = readLine(); line != null; line = readLine()) + eval(line, true); + } + + + public final void registerCommand(String name, Command command) { + VerifyHelper.verifyIDName(name); + VerifyHelper.putIfAbsent(commands, name, Objects.requireNonNull(command, "command"), + String.format("Command has been already registered: '%s'", name)); + } + + @Override + public final void run() { + try { + readLoop(); + } catch (IOException e) { + LogHelper.error(e); + } + } + + + + public abstract void bell() throws IOException; + + + public abstract void clear() throws IOException; + + + public final Map commandsMap() { + return Collections.unmodifiableMap(commands); + } + + + +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java similarity index 86% rename from LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java rename to libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java index 039afe3d..c3909646 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java @@ -1,7 +1,6 @@ -package ru.gravit.launchserver.command.handler; +package ru.gravit.utils.command; import jline.console.ConsoleReader; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper.Output; @@ -23,8 +22,8 @@ public void println(String message) { private final ConsoleReader reader; - public JLineCommandHandler(LaunchServer server) throws IOException { - super(server); + public JLineCommandHandler() throws IOException { + super(); // Set reader reader = new ConsoleReader(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java similarity index 75% rename from LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java rename to libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java index 7f77b039..a7ae1a06 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java @@ -1,6 +1,5 @@ -package ru.gravit.launchserver.command.handler; +package ru.gravit.utils.command; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import java.io.BufferedReader; @@ -9,8 +8,8 @@ public final class StdCommandHandler extends CommandHandler { private final BufferedReader reader; - public StdCommandHandler(LaunchServer server, boolean readCommands) { - super(server); + public StdCommandHandler(boolean readCommands) { + super(); reader = readCommands ? IOHelper.newReader(System.in) : null; } diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/CommonHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/CommonHelper.java index bc7d21f7..5f7548e3 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/CommonHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/CommonHelper.java @@ -1,10 +1,13 @@ package ru.gravit.utils.helper; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.utils.command.CommandException; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; +import java.util.Collection; +import java.util.LinkedList; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,4 +71,53 @@ public static String replace(String source, String... params) { private CommonHelper() { } + + public static String[] parseCommand(CharSequence line) throws CommandException { + boolean quoted = false; + boolean wasQuoted = false; + + // Read line char by char + Collection result = new LinkedList<>(); + StringBuilder builder = new StringBuilder(100); + for (int i = 0; i <= line.length(); i++) { + boolean end = i >= line.length(); + char ch = end ? '\0' : line.charAt(i); + + // Maybe we should read next argument? + if (end || !quoted && Character.isWhitespace(ch)) { + if (end && quoted) + throw new CommandException("Quotes wasn't closed"); + + // Empty args are ignored (except if was quoted) + if (wasQuoted || builder.length() > 0) + result.add(builder.toString()); + + // Reset file builder + wasQuoted = false; + builder.setLength(0); + continue; + } + + // Append next char + switch (ch) { + case '"': // "abc"de, "abc""de" also allowed + quoted = !quoted; + wasQuoted = true; + break; + case '\\': // All escapes, including spaces etc + if (i + 1 >= line.length()) + throw new CommandException("Escape character is not specified"); + char next = line.charAt(i + 1); + builder.append(next); + i++; + break; + default: // Default char, simply append + builder.append(ch); + break; + } + } + + // Return result as array + return result.toArray(new String[0]); + } } From 57231d948d8adba7fc8b7ce2f4a4a49dba95cd6a Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 8 Mar 2019 19:43:26 +0700 Subject: [PATCH 06/18] [FEATURE] LaunchServerConsole --- LaunchServerConsole/build.gradle | 20 +++++++++++ .../launchserver/console/ConsoleMain.java | 35 +++++++++++++++++++ .../console/RemoteJLineCommandHandler.java | 24 +++++++++++++ .../console/RemoteStdCommandHandler.java | 24 +++++++++++++ .../gravit/utils/command/CommandHandler.java | 12 +++---- .../utils/command/JLineCommandHandler.java | 2 +- .../utils/command/StdCommandHandler.java | 2 +- settings.gradle | 3 +- 8 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 LaunchServerConsole/build.gradle create mode 100644 LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java create mode 100644 LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteJLineCommandHandler.java create mode 100644 LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteStdCommandHandler.java diff --git a/LaunchServerConsole/build.gradle b/LaunchServerConsole/build.gradle new file mode 100644 index 00000000..78f606d2 --- /dev/null +++ b/LaunchServerConsole/build.gradle @@ -0,0 +1,20 @@ +String mainClassName = "ru.gravit.launchserver.console.ConsoleMain" + + +repositories { + maven { + url "http://repo.spring.io/plugins-release/" + } +} + +sourceCompatibility = '1.8' +targetCompatibility = '1.8' + +jar { + from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } + manifest.attributes("Main-Class": mainClassName) +} + +dependencies { + compileOnly project(':ServerWrapper') +} diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java new file mode 100644 index 00000000..652e89e3 --- /dev/null +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java @@ -0,0 +1,35 @@ +package ru.gravit.launchserver.console; + +import ru.gravit.launcher.server.ServerWrapper; +import ru.gravit.utils.command.CommandHandler; +import ru.gravit.utils.command.JLineCommandHandler; +import ru.gravit.utils.command.StdCommandHandler; +import ru.gravit.utils.helper.LogHelper; + +import java.io.IOException; + +public class ConsoleMain { + public static CommandHandler commandHandler; + public static void main(String[] args) throws IOException { + if(ServerWrapper.config == null) + { + LogHelper.warning("ServerWrapper not found"); + } + if(!ServerWrapper.permissions.canAdmin) + { + LogHelper.warning("Permission canAdmin not found"); + } + try { + Class.forName("jline.Terminal"); + + // JLine2 available + commandHandler = new RemoteJLineCommandHandler(); + LogHelper.info("JLine2 terminal enabled"); + } catch (ClassNotFoundException ignored) { + commandHandler = new RemoteStdCommandHandler(true); + LogHelper.warning("JLine2 isn't in classpath, using std"); + } + LogHelper.info("CommandHandler started. Use 'exit' to exit this console"); + commandHandler.run(); + } +} diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteJLineCommandHandler.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteJLineCommandHandler.java new file mode 100644 index 00000000..bfdb634f --- /dev/null +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteJLineCommandHandler.java @@ -0,0 +1,24 @@ +package ru.gravit.launchserver.console; + +import ru.gravit.launcher.request.admin.ExecCommandRequest; +import ru.gravit.utils.command.Command; +import ru.gravit.utils.command.JLineCommandHandler; +import ru.gravit.utils.helper.LogHelper; + +import java.io.IOException; + +public class RemoteJLineCommandHandler extends JLineCommandHandler { + public RemoteJLineCommandHandler() throws IOException { + } + @Override + public void eval(String line, boolean bell) + { + if(line.equals("exit")) System.exit(0); + ExecCommandRequest request = new ExecCommandRequest(System.out::println, line); + try { + request.request(); + } catch (Exception e) { + LogHelper.error(e); + } + } +} diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteStdCommandHandler.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteStdCommandHandler.java new file mode 100644 index 00000000..b5255d66 --- /dev/null +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/RemoteStdCommandHandler.java @@ -0,0 +1,24 @@ +package ru.gravit.launchserver.console; + +import ru.gravit.launcher.request.admin.ExecCommandRequest; +import ru.gravit.utils.command.Command; +import ru.gravit.utils.command.CommandHandler; +import ru.gravit.utils.command.StdCommandHandler; +import ru.gravit.utils.helper.LogHelper; + +public class RemoteStdCommandHandler extends StdCommandHandler { + public RemoteStdCommandHandler(boolean readCommands) { + super(readCommands); + } + @Override + public void eval(String line, boolean bell) + { + if(line.equals("exit")) System.exit(0); + ExecCommandRequest request = new ExecCommandRequest(System.out::println, line); + try { + request.request(); + } catch (Exception e) { + LogHelper.error(e); + } + } +} diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java index 5d59e4cc..b66f2913 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java @@ -16,7 +16,7 @@ public abstract class CommandHandler implements Runnable { private final Map commands = new ConcurrentHashMap<>(32); - public final void eval(String line, boolean bell) { + public void eval(String line, boolean bell) { LogHelper.info("Command '%s'", line); // Parse line to tokens @@ -33,7 +33,7 @@ public final void eval(String line, boolean bell) { } - public final void eval(String[] args, boolean bell) { + public void eval(String[] args, boolean bell) { if (args.length == 0) return; @@ -56,7 +56,7 @@ public final void eval(String[] args, boolean bell) { } - public final Command lookup(String name) throws CommandException { + public Command lookup(String name) throws CommandException { Command command = commands.get(name); if (command == null) throw new CommandException(String.format("Unknown command: '%s'", name)); @@ -72,14 +72,14 @@ private void readLoop() throws IOException { } - public final void registerCommand(String name, Command command) { + public void registerCommand(String name, Command command) { VerifyHelper.verifyIDName(name); VerifyHelper.putIfAbsent(commands, name, Objects.requireNonNull(command, "command"), String.format("Command has been already registered: '%s'", name)); } @Override - public final void run() { + public void run() { try { readLoop(); } catch (IOException e) { @@ -95,7 +95,7 @@ public final void run() { public abstract void clear() throws IOException; - public final Map commandsMap() { + public Map commandsMap() { return Collections.unmodifiableMap(commands); } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java index c3909646..504393b7 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java @@ -6,7 +6,7 @@ import java.io.IOException; -public final class JLineCommandHandler extends CommandHandler { +public class JLineCommandHandler extends CommandHandler { private final class JLineOutput implements Output { @Override public void println(String message) { diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java index a7ae1a06..27cab6cd 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/StdCommandHandler.java @@ -5,7 +5,7 @@ import java.io.BufferedReader; import java.io.IOException; -public final class StdCommandHandler extends CommandHandler { +public class StdCommandHandler extends CommandHandler { private final BufferedReader reader; public StdCommandHandler(boolean readCommands) { diff --git a/settings.gradle b/settings.gradle index 0ef17ca5..3fc709d9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,7 +5,8 @@ include 'LauncherAPI' include 'ServerWrapper' include 'LaunchServer' +include 'LaunchServerConsole' include 'modules' file('modules').eachDir { sub -> if (sub.name.endsWith('_module')) include 'modules:' + sub.name -} \ No newline at end of file +} From 1819e1c95cf15860dab6ca9c10c60a4a0173243a Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Fri, 8 Mar 2019 16:21:41 +0300 Subject: [PATCH 07/18] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20launch4j.=20(#187)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FEATURE] Получение launch4j. * [FEATURE] Генерация готового bundle, со всей структурой каталогов нужной для работы лауннчсервера. * [FIX] Название архива с LaunchServer. --- LaunchServer/build.gradle | 61 +++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index c6702389..0f2209c1 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -18,8 +18,10 @@ bundle hikari pack + launch4j + launch4jCJ bundleOnly.extendsFrom bundle - compile.extendsFrom bundle, hikari, pack + compile.extendsFrom bundle, hikari, pack, launch4jCJ, launch4j } jar { @@ -57,10 +59,18 @@ pack project(':libLauncher') exclude group: 'io.micrometer' exclude group: 'org.slf4j' } - - compileOnly('net.sf.launch4j:launch4j:3.12') { // need user + + launch4j('net.sf.launch4j:launch4j:3.12') { exclude group: '*' } + + launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-win32') { + exclude group: '*' + } + + launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-linux') { + exclude group: '*' + } } task hikari(type: Copy) { @@ -68,16 +78,49 @@ task hikari(type: Copy) { from configurations.hikari } +task launch4jM(type: Copy) { + into "$buildDir/libs/libraries/launch4j" + from(configurations.launch4jCJ.collect { it.isDirectory() ? it : zipTree(it) }) + includeEmptyDirs false + eachFile { FileCopyDetails fcp -> + if (fcp.relativePath.pathString.startsWith("launch4j-")) { + def segments = fcp.relativePath.segments + def pathSegments = segments[1..-1] as String[] + fcp.relativePath = new RelativePath(!fcp.file.isDirectory(), pathSegments) + fcp.mode = 0755 + } else { + fcp.exclude() + } + } +} + +task launch4jA(type: Copy) { + into "$buildDir/libs/libraries/launch4j" + from(configurations.launch4j) + includeEmptyDirs false + eachFile { FileCopyDetails fcp -> + if (fcp.name.startsWith("launch4j")) { + fcp.name = "launch4j.jar" + fcp.mode = 0755 + } else { + fcp.exclude() + } + } +} + task dumpLibs(type: Copy) { - dependsOn tasks.hikari + dependsOn tasks.hikari, tasks.launch4jM, tasks.launch4jA into "$buildDir/libs/libraries" from configurations.bundleOnly } -task dumpClientLibs(type: Copy) { - dependsOn parent.childProjects.Launcher.tasks.build - into "$buildDir/libs/launcher-libraries" - from parent.childProjects.Launcher.tasks.dumpLibs.destinationDir +task bundle(type: Zip) { + dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.jar + archiveName 'LaunchServer.zip' + destinationDir file("$buildDir") + from(tasks.dumpLibs.destinationDir) { into 'libraries' } + from tasks.jar.archivePath + from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' } } -build.dependsOn tasks.dumpLibs, tasks.dumpClientLibs +build.dependsOn tasks.dumpLibs, tasks.bundle From d06fcafdc70835fe59db1b6216932dfd5851fb2c Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 8 Mar 2019 16:39:27 +0300 Subject: [PATCH 08/18] =?UTF-8?q?[FEATURE]=20=D0=93=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20Downloader.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fileserver/FileServerHandler.java | 16 --------- .../gravit/utils/downloader/Downloader.java | 8 +++++ .../utils/downloader/DownloadingThread.java | 34 ------------------- 3 files changed, 8 insertions(+), 50 deletions(-) delete mode 100644 libLauncher/src/main/java/ru/gravit/utils/downloader/DownloadingThread.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java index 3b78e8ad..8d6165d1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java @@ -130,22 +130,6 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr lastContentFuture = sendFileFuture; } - sendFileFuture.addListener(new ChannelProgressiveFutureListener() { - @Override - public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) { - if (total < 0) { // total unknown - System.err.println(future.channel() + " Transfer progress: " + progress); - } else { - System.err.println(future.channel() + " Transfer progress: " + progress + " / " + total); - } - } - - @Override - public void operationComplete(ChannelProgressiveFuture future) { - System.err.println(future.channel() + " Transfer complete."); - } - }); - // Decide whether to close the connection or not. if (!HttpUtil.isKeepAlive(request)) { lastContentFuture.addListener(new ClosingChannelFutureListener(raf)); diff --git a/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java b/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java index 12dfa4c1..9187a1f8 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java +++ b/libLauncher/src/main/java/ru/gravit/utils/downloader/Downloader.java @@ -39,6 +39,8 @@ public interface Handler { private final int skip; private final Handler handler; + private HttpURLConnection connect = null; + public Downloader(URL url, File file) { this.requestProps = new HashMap<>(requestClient); this.file = file; @@ -128,6 +130,7 @@ public void downloadFile() throws IOException { interrupted.set(false); if (url.getProtocol().equalsIgnoreCase("http")) { HttpURLConnection connect = (HttpURLConnection) (url).openConnection(); + this.connect = connect; if (method != null) connect.setRequestMethod(method); for (Map.Entry ent : requestProps.entrySet()) { connect.setRequestProperty(ent.getKey(), ent.getValue()); @@ -158,6 +161,7 @@ public void downloadFile() throws IOException { } } else { HttpsURLConnection connect = (HttpsURLConnection) (url).openConnection(); + this.connect = connect; if (method != null) connect.setRequestMethod(method); for (Map.Entry ent : requestProps.entrySet()) { connect.setRequestProperty(ent.getKey(), ent.getValue()); @@ -200,5 +204,9 @@ public void run() { this.ex.set(ex); LogHelper.error(ex); } + if (connect != null) + try { + connect.disconnect(); + } catch (Throwable ignored) { } } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/downloader/DownloadingThread.java b/libLauncher/src/main/java/ru/gravit/utils/downloader/DownloadingThread.java deleted file mode 100644 index 01fb2691..00000000 --- a/libLauncher/src/main/java/ru/gravit/utils/downloader/DownloadingThread.java +++ /dev/null @@ -1,34 +0,0 @@ -package ru.gravit.utils.downloader; - -import java.io.File; -import java.net.URL; - -public class DownloadingThread extends Thread { - private final Downloader runnable; - - public DownloadingThread(File file, URL url, String name) { - super(name); - runnable = new Downloader(url, file); - } - - public Downloader getDownloader() { - return runnable; - } - - @Override - public void interrupt() { - runnable.interrupt.set(true); - while (!runnable.interrupted.get()) { - } - super.interrupt(); - } - - public void hardInterrupt() { - super.interrupt(); - } - - @Override - public void run() { - runnable.run(); - } -} From 2c0a2020802044acb22d15729b8fbf69e921d4eb Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 16:18:14 +0700 Subject: [PATCH 09/18] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D1=81?= =?UTF-8?q?=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=89=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/command/install/CheckInstallCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java index 0c9c2ae2..d7c58dba 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java @@ -22,5 +22,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { LogHelper.info("Check install success"); + System.exit(0); } } From d5c7e5ed68fce6d7670d7d78201c0adfe6f330c4 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 16:42:17 +0700 Subject: [PATCH 10/18] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D1=81?= =?UTF-8?q?=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=89=D0=B8=D0=BA=D0=B0=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/command/install/CheckInstallCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java index d7c58dba..72e78c22 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/install/CheckInstallCommand.java @@ -2,6 +2,7 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.LogHelper; public class CheckInstallCommand extends Command { @@ -22,6 +23,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { LogHelper.info("Check install success"); - System.exit(0); + JVMHelper.RUNTIME.exit(0); } } From af90fd41ca6dd9267ce86009abf4f814ac5743eb Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 21:20:08 +0700 Subject: [PATCH 11/18] =?UTF-8?q?[FIX]=20compareMode=20=D0=BE=D0=B1=D0=B5?= =?UTF-8?q?=D1=80=D0=BD=D1=83=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/auth/hwid/MysqlHWIDHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index ce907c4e..704ff525 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -144,12 +144,15 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI boolean isOne = false; while(set.next()) { if(!oneCompareMode) isOne = true; - OshiHWID db_hwid = new OshiHWID(); - db_hwid.serialNumber = set.getString(hwidFieldSerialNumber); - db_hwid.processorID = set.getString(hwidFieldProcessorID); - db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial); - db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory)); - if(hwid.compare(db_hwid) < compare) continue; + if(compareMode) + { + OshiHWID db_hwid = new OshiHWID(); + db_hwid.serialNumber = set.getString(hwidFieldSerialNumber); + db_hwid.processorID = set.getString(hwidFieldProcessorID); + db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial); + db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory)); + if(hwid.compare(db_hwid) < compare) continue; + } if(oneCompareMode) isOne = true; boolean isBanned = set.getBoolean(hwidFieldBanned); if (isBanned) { From 57866994742133501139455d55ad2504cd60f63b Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 21:40:50 +0700 Subject: [PATCH 12/18] =?UTF-8?q?[FIX]=20compareMode=20=D0=B4=D0=BE=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BE=D1=87=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/auth/hwid/MysqlHWIDHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index 704ff525..11ae3d6f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -151,7 +151,13 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI db_hwid.processorID = set.getString(hwidFieldProcessorID); db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial); db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory)); - if(hwid.compare(db_hwid) < compare) continue; + LogHelper.dev("Compare HWID: %s vs %s", hwid.getSerializeString(), db_hwid.getSerializeString()); + int compare_point = hwid.compare(db_hwid); + if(compare_point < compare) continue; + else + { + LogHelper.debug("User %s hwid check: found compare %d in %d", username, compare_point, set.getInt("id")); + } } if(oneCompareMode) isOne = true; boolean isBanned = set.getBoolean(hwidFieldBanned); From 07761dd88b81a98349b7f6ab3ae532c39f530c6c Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 22:41:12 +0700 Subject: [PATCH 13/18] =?UTF-8?q?[FEATURE]=20=D0=9D=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D1=8B?= =?UTF-8?q?=20=D0=B2=20HWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/hwid/OshiHWIDProvider.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java index 01909b20..2f147063 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -62,6 +62,29 @@ public String getHWDisk() { } } + public String getSoundCardInfo() + { + for(SoundCard soundcard : hardware.getSoundCards()) + { + return soundcard.getName(); + } + return ""; + } + + public String getMacAddr() + { + for(NetworkIF networkIF : hardware.getNetworkIFs()) + { + for(String ipv4 : networkIF.getIPv4addr()) + { + if(ipv4.startsWith("127.")) continue; + if(ipv4.startsWith("10.")) continue; + return networkIF.getMacaddr(); + } + } + return ""; + } + public long getTotalMemory() { if (noHWID) return -1; if (hardware == null) hardware = systemInfo.getHardware(); @@ -85,6 +108,20 @@ public void printHardwareInformation() { for (UsbDevice s : hardware.getUsbDevices(true)) { LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName()); } + for(NetworkIF networkIF : hardware.getNetworkIFs()) + { + LogHelper.debug("Network Interface: %s mac: %s", networkIF.getName(), networkIF.getMacaddr()); + for(String ipv4 : networkIF.getIPv4addr()) + { + if(ipv4.startsWith("127.")) continue; + if(ipv4.startsWith("10.")) continue; + LogHelper.subDebug("IPv4: %s", ipv4); + } + } + for(SoundCard soundcard : hardware.getSoundCards()) + { + LogHelper.debug("SoundCard %s", soundcard.getName()); + } CentralProcessor processor = hardware.getProcessor(); LogHelper.debug("Processor Model: %s ID: %s", processor.getModel(), processor.getProcessorID()); } catch (Throwable e) { From 08696839dcd79f64fb4e06dd69a7a79f457c3e7e Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 9 Mar 2019 22:52:24 +0700 Subject: [PATCH 14/18] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=B4=D0=BA?= =?UTF-8?q?=D1=80=D1=83=D1=87=D0=B5=D0=BD=D1=8B=20=D1=87=D0=B8=D1=81=D0=BB?= =?UTF-8?q?=D0=B0=20HWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/hwid/OshiHWIDProvider.java | 1 + .../java/ru/gravit/launcher/OshiHWID.java | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java index 2f147063..4c2ea950 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -137,6 +137,7 @@ public HWID getHWID() { hwid.totalMemory = getTotalMemory(); hwid.HWDiskSerial = getHWDisk(); hwid.processorID = getProcessorID(); + hwid.macAddr = getMacAddr(); printHardwareInformation(); return hwid; } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java index a6877ae3..4911d294 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java @@ -12,6 +12,8 @@ public class OshiHWID implements HWID { public String HWDiskSerial; @LauncherAPI public String processorID; + @LauncherAPI + public String macAddr; @Override public String getSerializeString() { @@ -22,10 +24,11 @@ public String getSerializeString() { public int getLevel() //Уровень доверия, насколько уникальные значения { int result = 0; - if (totalMemory != 0) result++; - if (serialNumber != null && !serialNumber.equals("unknown")) result += 4; - if (HWDiskSerial != null && !HWDiskSerial.equals("unknown")) result += 15; - if (processorID != null && !processorID.equals("unknown")) result += 6; + if (totalMemory != 0) result+=8; + if (serialNumber != null && !serialNumber.equals("unknown")) result += 12; + if (HWDiskSerial != null && !HWDiskSerial.equals("unknown")) result += 30; + if (processorID != null && !processorID.equals("unknown")) result += 10; + if (macAddr != null && !macAddr.equals("00:00:00:00:00:00")) result += 15; return result; } @@ -35,10 +38,12 @@ public int compare(HWID hwid) { { int rate = 0; OshiHWID oshi = (OshiHWID) hwid; - if(Math.abs(oshi.totalMemory - totalMemory) < 1024*1024) rate+=10; - if(oshi.HWDiskSerial.equals(HWDiskSerial)) rate+=50; - if(oshi.processorID.equals(processorID)) rate+=26; + if(Math.abs(oshi.totalMemory - totalMemory) < 1024*1024) rate+=5; + if(oshi.totalMemory == totalMemory) rate+=15; + if(oshi.HWDiskSerial.equals(HWDiskSerial)) rate+=45; + if(oshi.processorID.equals(processorID)) rate+=18; if(oshi.serialNumber.equals(serialNumber)) rate+=15; + if(oshi.macAddr.equals(macAddr)) rate+=19; return rate; } return 0; @@ -46,6 +51,6 @@ public int compare(HWID hwid) { @Override public boolean isNull() { - return getLevel() < 2; + return getLevel() < 15; } } From 94d677fe1e2ded7198377105d656fd21ce849c4e Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 10 Mar 2019 16:17:19 +0700 Subject: [PATCH 15/18] =?UTF-8?q?[FIX]=20=D0=9D=D0=B5=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=B0=D1=8F=20=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=81=D0=BA=D0=B8=D1=85=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launchserver/binary/JAConfigurator.java | 2 +- .../java/ru/gravit/launcher/managers/SimpleModuleManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index d6d683c0..e4280842 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -36,7 +36,7 @@ public void addModuleClass(String fullName) { moduleBody.append("();"); moduleBody.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod"); moduleBody.append(autoincrement); - moduleBody.append(" , true );"); + moduleBody.append(");"); autoincrement++; } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java b/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java index fc4202d5..4ac0336f 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java @@ -132,7 +132,7 @@ public void printModules() { @Override public void registerModule(Module module) { - load(module); + modules.add(module); LogHelper.info("Module %s version: %s registered", module.getName(), module.getVersion()); } From be4c2f4b07f4e902e272a1afe124c30e82b3140a Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 10 Mar 2019 18:48:46 +0700 Subject: [PATCH 16/18] =?UTF-8?q?[FIX]=20Assess=20denied=20=D0=B8=20witch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/response/auth/CheckServerResponse.java | 2 +- .../gravit/launchserver/response/auth/JoinServerResponse.java | 2 +- .../gravit/launchserver/response/update/ProfilesResponse.java | 2 +- .../gravit/launchserver/response/update/UpdateResponse.java | 2 +- .../socket/websocket/json/update/UpdateResponse.java | 2 +- .../main/java/ru/gravit/launcher/ClientLauncherWrapper.java | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java index dbdd2b44..b2974674 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java @@ -28,7 +28,7 @@ public void reply() throws IOException { debug("Username: %s, Server ID: %s", username, serverID); Client clientData = server.sessionManager.getClient(session); if (!clientData.isAuth || clientData.type != Client.Type.SERVER) { - requestError("Assess denied"); + requestError("Access denied"); return; } // Try check server with auth handler diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java index dd5d9463..821848a6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java @@ -26,7 +26,7 @@ public void reply() throws IOException { String serverID = VerifyHelper.verifyServerID(input.readASCII(SerializeLimits.MAX_SERVERID)); // With minus sign Client clientData = server.sessionManager.getClient(session); if (!clientData.isAuth || clientData.type != Client.Type.USER) { - requestError("Assess denied"); + requestError("Access denied"); return; } // Try join server with auth handler diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java index 039e018b..47dd872e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java @@ -25,7 +25,7 @@ public void reply() throws IOException { input.readBoolean(); if (client.type == Client.Type.USER && !client.checkSign) { LogHelper.warning("User session: %d ip %s try get profiles", session, ip); - requestError("Assess denied"); + requestError("Access denied"); return; } writeNoError(output); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java index 530b489d..8e4c547b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java @@ -39,7 +39,7 @@ public void reply() throws IOException { } Client clientData = server.sessionManager.getClient(session); if (!clientData.isAuth || clientData.type != Client.Type.USER || clientData.profile == null) { - requestError("Assess denied"); + requestError("Access denied"); return; } if (!clientData.permissions.canAdmin) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateResponse.java index 6c0502c6..26965f25 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateResponse.java @@ -19,7 +19,7 @@ public String getType() { @Override public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { if (!client.isAuth || client.type != Client.Type.USER || client.profile == null) { - service.sendObject(ctx,new ErrorRequestEvent("Assess denied")); + service.sendObject(ctx,new ErrorRequestEvent("Access denied")); return; } if (!client.permissions.canAdmin) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 39a9633c..3f86f331 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -44,9 +44,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep if (!process.isAlive()) { int errorcode = process.exitValue(); if (errorcode != 0) - LogHelper.error("Process exit witch error code: %d", errorcode); + LogHelper.error("Process exitwith error code: %d", errorcode); else - LogHelper.info("Process exit witch code 0"); + LogHelper.info("Process exitwith code 0"); } else { LogHelper.debug("Process started success"); } From 84e5f91fdf2fb22b1fb6425d0de92ce36a569854 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 10 Mar 2019 19:01:14 +0700 Subject: [PATCH 17/18] =?UTF-8?q?[FIX]=20=D0=94=D0=BE=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BF=D0=BE=D0=BD=D1=8F?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=D0=B9=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 4 ++++ .../launchserver/auth/MySQLSourceConfig.java | 4 ++-- .../gravit/launcher/ClientLauncherWrapper.java | 4 ++-- .../launcher/profiles/ClientProfile.java | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 6a7d1b76..7d300b5a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -165,6 +165,10 @@ public void verify() { if (env == null) { throw new NullPointerException("Env must not be null"); } + if(netty == null) + { + throw new NullPointerException("Netty must not be null"); + } } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java index 95c16c79..fccb3b40 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java @@ -89,9 +89,9 @@ public synchronized Connection getConnection() throws SQLException { // Set HikariCP pool // Replace source with hds source = new HikariDataSource(cfg); - LogHelper.info("HikariCP pooling enabled for '%s'", poolName); + LogHelper.warning("HikariCP pooling enabled for '%s'", poolName); } catch (ClassNotFoundException ignored) { - LogHelper.warning("HikariCP isn't in classpath for '%s'", poolName); + LogHelper.debug("HikariCP isn't in classpath for '%s'", poolName); } } return source.getConnection(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 3f86f331..3c2d9df1 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -44,9 +44,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep if (!process.isAlive()) { int errorcode = process.exitValue(); if (errorcode != 0) - LogHelper.error("Process exitwith error code: %d", errorcode); + LogHelper.error("Process exit with error code: %d", errorcode); else - LogHelper.info("Process exitwith code 0"); + LogHelper.info("Process exit with code 0"); } else { LogHelper.debug("Process started success"); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index 8de9245a..9d533337 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -391,6 +391,24 @@ public void verify() { // Client launcher VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Main class can't be empty"); + for(String s : classPath) + { + if(s == null) throw new IllegalArgumentException("Found null entry in classPath"); + } + for(String s : jvmArgs) + { + if(s == null) throw new IllegalArgumentException("Found null entry in jvmArgs"); + } + for(String s : clientArgs) + { + if(s == null) throw new IllegalArgumentException("Found null entry in clientArgs"); + } + for(OptionalFile f : updateOptional) + { + if(f == null) throw new IllegalArgumentException("Found null entry in updateOptional"); + if(f.name == null) throw new IllegalArgumentException("Optional: name must not be null"); + if(f.list == null) throw new IllegalArgumentException("Optional: list must not be null"); + } } @Override From c13f1db02d65fd0d9b71d0bfeff5af92f4d84dfe Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 10 Mar 2019 19:07:02 +0700 Subject: [PATCH 18/18] [AN] 4.4.1 --- libLauncher/src/main/java/ru/gravit/launcher/Launcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java index ccca5eaa..6bfbdec0 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java @@ -60,7 +60,7 @@ public final class Launcher { private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL); public static final int MAJOR = 4; public static final int MINOR = 4; - public static final int PATCH = 0; + public static final int PATCH = 1; public static final int BUILD = 1; public static final Version.Type RELEASE = Version.Type.STABLE; public static GsonBuilder gsonBuilder;