From 1b516ccf2f01fbc5f7eaf3b3ccb6ba896c8ddeb6 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Thu, 6 Dec 2018 05:29:34 +0300 Subject: [PATCH 1/2] Safe classWriter. (#92) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ClassWriter hierarchy... * Some improvements of jar building. * Modules updated. * Fixed modules... Again. * Выловил заразу всё таки... * Update modules to use SafeClassWriter. * To Strings... * Organize imports. --- .../ru/gravit/launchserver/LaunchServer.java | 20 +- .../ru/gravit/launchserver/ProguardConf.java | 4 +- .../launchserver/asm/ClassMetadataReader.java | 93 ++++ .../launchserver/asm/SafeClassWriter.java | 40 ++ .../launchserver/auth/MySQLSourceConfig.java | 4 +- .../auth/handler/AuthHandler.java | 2 +- .../auth/handler/BinaryFileAuthHandler.java | 2 +- .../auth/handler/CachedAuthHandler.java | 4 +- .../auth/handler/FileAuthHandler.java | 10 +- .../auth/handler/MemoryAuthHandler.java | 2 +- .../auth/handler/MySQLAuthHandler.java | 2 +- .../auth/handler/NullAuthHandler.java | 2 +- .../auth/handler/TextFileAuthHandler.java | 4 +- .../launchserver/auth/hwid/HWIDHandler.java | 2 +- .../auth/hwid/JsonHWIDHandler.java | 21 +- .../auth/hwid/MysqlHWIDHandler.java | 17 +- .../auth/provider/AcceptAuthProvider.java | 2 +- .../auth/provider/AuthProvider.java | 6 +- .../auth/provider/DigestAuthProvider.java | 6 +- .../auth/provider/FileAuthProvider.java | 12 +- .../auth/provider/JsonAuthProvider.java | 5 +- .../auth/provider/MojangAuthProvider.java | 3 +- .../auth/provider/MySQLAuthProvider.java | 10 +- .../auth/provider/NullAuthProvider.java | 2 +- .../auth/provider/RejectAuthProvider.java | 4 +- .../auth/provider/RequestAuthProvider.java | 4 +- .../launchserver/binary/BuildContext.java | 14 +- .../binary/EXEL4JLauncherBinary.java | 11 +- .../binary/EXELauncherBinary.java | 2 +- .../launchserver/binary/JAConfigurator.java | 24 +- .../binary/JARLauncherBinary.java | 504 ++++++++---------- .../launchserver/binary/LauncherBinary.java | 8 +- .../gravit/launchserver/command/Command.java | 2 +- .../command/auth/AuthCommand.java | 4 +- .../launchserver/command/auth/BanCommand.java | 2 +- .../command/auth/UUIDToUsernameCommand.java | 2 +- .../command/auth/UnbanCommand.java | 2 +- .../command/auth/UsernameToUUIDCommand.java | 2 +- .../command/basic/ClearCommand.java | 2 +- .../command/basic/DebugCommand.java | 2 +- .../launchserver/command/basic/GCCommand.java | 4 +- .../command/basic/HelpCommand.java | 2 +- .../command/basic/LogConnectionsCommand.java | 2 +- .../command/basic/StopCommand.java | 2 +- .../command/basic/VersionCommand.java | 2 +- .../command/handler/CommandHandler.java | 18 +- .../command/handler/JLineCommandHandler.java | 2 +- .../command/handler/StdCommandHandler.java | 2 +- .../command/hash/DownloadAssetCommand.java | 6 +- .../command/hash/DownloadClientCommand.java | 6 +- .../command/hash/IndexAssetCommand.java | 7 +- .../command/hash/SyncBinariesCommand.java | 2 +- .../command/hash/SyncProfilesCommand.java | 2 +- .../command/hash/SyncUpdatesCommand.java | 2 +- .../command/hash/UnindexAssetCommand.java | 9 +- .../fileserver/FileServerHandler.java | 48 +- .../manangers/BuildHookManager.java | 81 ++- .../launchserver/manangers/MirrorManager.java | 4 +- .../manangers/ModulesManager.java | 2 +- .../manangers/NodeTransformer.java | 40 ++ .../launchserver/modules/CoreModule.java | 2 +- .../modules/LaunchServerModuleContext.java | 2 +- .../launchserver/modules/SimpleModule.java | 2 +- .../launchserver/response/Response.java | 15 +- .../response/auth/AuthResponse.java | 10 +- .../response/auth/AuthServerResponse.java | 11 +- .../response/auth/CheckServerResponse.java | 4 +- .../response/auth/JoinServerResponse.java | 6 +- .../response/auth/SetProfileResponse.java | 4 +- .../BatchProfileByUsernameResponse.java | 2 +- .../profile/ProfileByUUIDResponse.java | 2 +- .../profile/ProfileByUsernameResponse.java | 2 +- .../response/update/LauncherResponse.java | 6 +- .../update/LegacyLauncherResponse.java | 4 +- .../response/update/ProfilesResponse.java | 4 +- .../response/update/UpdateResponse.java | 4 +- .../socket/NettyServerSocketHandler.java | 49 +- .../launchserver/socket/ResponseThread.java | 6 +- .../socket/ServerSocketHandler.java | 4 +- .../websocket/WebSocketFrameHandler.java | 1 + .../websocket/WebSocketIndexPageHandler.java | 23 +- .../socket/websocket/WebSocketService.java | 7 +- .../websocket/json/JsonResponseAdapter.java | 14 +- .../websocket/json/auth/AuthResponse.java | 6 +- .../json/update/LauncherResponse.java | 6 +- .../texture/NullTextureProvider.java | 2 +- .../texture/RequestTextureProvider.java | 6 +- .../launchserver/texture/TextureProvider.java | 2 +- .../gravit/launchserver/defaults/config.cfg | 6 +- .../launcher/ClientLauncherWrapper.java | 12 +- .../ru/gravit/launcher/LauncherEngine.java | 32 +- .../ru/gravit/launcher/RequestWorker.java | 4 +- .../launcher/client/ClientLauncher.java | 34 +- .../ru/gravit/launcher/client/DirBridge.java | 6 +- .../launcher/client/FunctionalBridge.java | 11 +- .../launcher/client/LauncherSettings.java | 28 +- .../gravit/launcher/client/ServerPinger.java | 7 +- .../launcher/gui/choosebox/CheckComboBox.java | 1 - .../indicator/ProgressCircleIndicator.java | 6 +- .../gui/indicator/RingProgressIndicator.java | 4 +- .../launcher/hwid/OshiHWIDProvider.java | 6 +- .../authlib/yggdrasil/CompatBridge.java | 2 +- .../authlib/yggdrasil/CompatProfile.java | 2 +- .../authlib/yggdrasil/LegacyBridge.java | 4 +- .../YggdrasilGameProfileRepository.java | 4 +- .../YggdrasilMinecraftSessionService.java | 9 +- .../launcher/request/CustomRequest.java | 2 +- .../ru/gravit/launcher/request/Request.java | 4 +- .../launcher/request/auth/AuthRequest.java | 9 +- .../request/auth/AuthServerRequest.java | 4 +- .../request/auth/ChangeServerRequest.java | 4 +- .../request/auth/CheckServerRequest.java | 4 +- .../request/auth/JoinServerRequest.java | 4 +- .../request/update/LauncherRequest.java | 12 +- .../request/update/LegacyLauncherRequest.java | 8 +- .../request/update/UpdateListRequest.java | 2 +- .../request/update/UpdateRequest.java | 6 +- .../uuid/BatchProfileByUsernameRequest.java | 4 +- .../uuid/ProfileByUsernameRequest.java | 2 +- .../websockets/ClientWebSocketService.java | 11 +- .../websockets/JsonRequestAdapter.java | 11 +- .../java/ru/gravit/launcher/Launcher.java | 4 +- .../ru/gravit/launcher/LauncherAgent.java | 2 +- .../ru/gravit/launcher/LauncherConfig.java | 6 +- .../gravit/launcher/events/ControlEvent.java | 4 +- .../ru/gravit/launcher/events/PingEvent.java | 4 +- .../gravit/launcher/events/SignalEvent.java | 4 +- .../ru/gravit/launcher/hasher/HashedDir.java | 14 +- .../launcher/hasher/HashedEntryAdapter.java | 11 +- .../ru/gravit/launcher/hasher/HashedFile.java | 4 +- .../launcher/modules/SimpleModuleManager.java | 14 +- .../launcher/profiles/ClientProfile.java | 18 +- .../launcher/profiles/PlayerProfile.java | 4 +- .../ru/gravit/launcher/profiles/Texture.java | 4 +- .../gravit/launcher/request/UpdateAction.java | 2 +- .../serialize/config/TextConfigReader.java | 2 +- .../config/entry/BlockConfigEntry.java | 2 +- .../serialize/signed/DigestBytesHolder.java | 8 +- .../serialize/signed/SignedBytesHolder.java | 2 +- .../serialize/stream/EnumSerializer.java | 2 +- .../serialize/stream/StreamObject.java | 2 +- .../launcher/ssl/LauncherSSLContext.java | 14 +- .../java/ru/gravit/utils/HTTPRequest.java | 1 + .../java/ru/gravit/utils/HttpDownloader.java | 6 +- .../ru/gravit/utils/event/EventManager.java | 6 +- .../ru/gravit/utils/helper/UnpackHelper.java | 48 +- modules | 2 +- 147 files changed, 1071 insertions(+), 697 deletions(-) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 71d630df..1247f512 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -33,19 +33,16 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.hasher.HashedDir; -import ru.gravit.launcher.serialize.config.entry.*; -import ru.gravit.launchserver.manangers.MirrorManager; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.TextConfigReader; import ru.gravit.launcher.serialize.config.TextConfigWriter; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; +import ru.gravit.launcher.serialize.config.entry.IntegerConfigEntry; +import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.auth.AuthLimiter; import ru.gravit.launchserver.auth.handler.AuthHandler; @@ -59,11 +56,18 @@ import ru.gravit.launchserver.command.handler.JLineCommandHandler; import ru.gravit.launchserver.command.handler.StdCommandHandler; import ru.gravit.launchserver.manangers.BuildHookManager; +import ru.gravit.launchserver.manangers.MirrorManager; import ru.gravit.launchserver.manangers.ModulesManager; import ru.gravit.launchserver.manangers.SessionManager; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.ServerSocketHandler; import ru.gravit.launchserver.texture.TextureProvider; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class LaunchServer implements Runnable, AutoCloseable { public static final class Config extends ConfigObject { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java index 82ec4992..29e38b60 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java @@ -40,8 +40,8 @@ public ProguardConf(LaunchServer srv) { prepare(false); if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); - confStrs.add("-injar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + ".jar\'"); - confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obf.jar\'"); + confStrs.add("-injar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-nonObf.jar\'"); + confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obfed.jar\'"); confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add(readConf()); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java new file mode 100644 index 00000000..e26c05a2 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java @@ -0,0 +1,93 @@ +package ru.gravit.launchserver.asm; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.jar.JarFile; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Opcodes; + +import ru.gravit.utils.helper.IOHelper; + +/** + * Позволяет искать методы внутри незагруженных классов и общие суперклассы для + * чего угодно. Работает через поиск class-файлов в classpath. + */ +public class ClassMetadataReader { + private class CheckSuperClassVisitor extends ClassVisitor { + + String superClassName; + + public CheckSuperClassVisitor() { + super(Opcodes.ASM5); + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, + String[] interfaces) { + superClassName = superName; + } + } + + private final List cp; + + public ClassMetadataReader(List cp) { + this.cp = cp; + } + + public List getCp() { + return cp; + } + + public ClassMetadataReader() { + this.cp = new ArrayList<>(); + } + + public void acceptVisitor(byte[] classData, ClassVisitor visitor) { + new ClassReader(classData).accept(visitor, 0); + } + + public void acceptVisitor(String className, ClassVisitor visitor) throws IOException { + acceptVisitor(getClassData(className), visitor); + } + + public byte[] getClassData(String className) throws IOException { + for (JarFile f : cp) { + if (f.getEntry(className + ".class") != null) try (InputStream in = f.getInputStream(f.getEntry(className + ".class"))) { return IOHelper.read(in); } + } + return IOHelper.read(IOHelper.getResourceURL(className + ".class")); + } + + public String getSuperClass(String type) { + if (type.equals("java/lang/Object")) return null; + try { + return getSuperClassASM(type); + } catch (Exception e) { + return "java/lang/Object"; + } + } + + protected String getSuperClassASM(String type) throws IOException { + CheckSuperClassVisitor cv = new CheckSuperClassVisitor(); + acceptVisitor(type, cv); + return cv.superClassName; + } + + /** + * Возвращает суперклассы в порядке возрастающей конкретности (начиная с + * java/lang/Object и заканчивая данным типом) + */ + public ArrayList getSuperClasses(String type) { + ArrayList superclasses = new ArrayList<>(1); + superclasses.add(type); + while ((type = getSuperClass(type)) != null) + superclasses.add(type); + Collections.reverse(superclasses); + return superclasses; + } + +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java new file mode 100644 index 00000000..5aa2a11c --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java @@ -0,0 +1,40 @@ +package ru.gravit.launchserver.asm; + +import java.util.ArrayList; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; + +/** + * ClassWriter с другой реализацией метода getCommonSuperClass: при его + * использовании не происходит загрузки классов. + */ +public class SafeClassWriter extends ClassWriter { + + private final ClassMetadataReader classMetadataReader; + + public SafeClassWriter(ClassMetadataReader classMetadataReader, int flags) { + super(flags); + this.classMetadataReader = classMetadataReader; + } + + public SafeClassWriter(ClassReader classReader, ClassMetadataReader classMetadataReader, int flags) { + super(classReader, flags); + this.classMetadataReader = classMetadataReader; + } + + @Override + protected String getCommonSuperClass(String type1, String type2) { + ArrayList superClasses1 = classMetadataReader.getSuperClasses(type1); + ArrayList superClasses2 = classMetadataReader.getSuperClasses(type2); + int size = Math.min(superClasses1.size(), superClasses2.size()); + int i; + for (i = 0; i < size && superClasses1.get(i).equals(superClasses2.get(i)); i++) + ; + if (i == 0) + return "java/lang/Object"; + else + return superClasses1.get(i - 1); + } + +} \ No newline at end of file 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 43df5421..6a0c1321 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java @@ -9,13 +9,13 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; import ru.gravit.launcher.serialize.config.entry.IntegerConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class MySQLSourceConfig extends ConfigObject implements AutoCloseable { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java index 248a802c..823b777a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java @@ -6,11 +6,11 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.VerifyHelper; public abstract class AuthHandler extends ConfigObject implements AutoCloseable { private static final Map> AUTH_HANDLERS = new ConcurrentHashMap<>(4); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java index 4155a13b..869a37b0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java @@ -5,10 +5,10 @@ import java.util.Set; import java.util.UUID; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.utils.helper.IOHelper; public final class BinaryFileAuthHandler extends FileAuthHandler { public BinaryFileAuthHandler(BlockConfigEntry block) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java index e7a65f4a..03bbb464 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java @@ -8,12 +8,12 @@ import ru.gravit.launcher.NeedGarbageCollection; import ru.gravit.launcher.managers.GarbageManager; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; +import ru.gravit.launchserver.auth.provider.AuthProviderResult; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launchserver.auth.provider.AuthProviderResult; public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection { public static final class Entry { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java index 44e7a89b..881b5471 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java @@ -10,11 +10,6 @@ import java.util.UUID; import java.util.concurrent.locks.ReentrantReadWriteLock; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -23,6 +18,11 @@ import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launcher.serialize.stream.StreamObject; import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public abstract class FileAuthHandler extends AuthHandler { public static final class Entry extends StreamObject { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java index 0959efc5..8afe2704 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java @@ -4,10 +4,10 @@ import java.util.Arrays; import java.util.UUID; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; public final class MemoryAuthHandler extends CachedAuthHandler { private static String toUsername(UUID uuid) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java index e56c6696..234c71d2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java @@ -7,10 +7,10 @@ import java.sql.SQLException; import java.util.UUID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launchserver.auth.MySQLSourceConfig; +import ru.gravit.utils.helper.VerifyHelper; public final class MySQLAuthHandler extends CachedAuthHandler { private final MySQLSourceConfig mySQLHolder; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java index eceb93f8..0c5ab784 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java @@ -4,9 +4,9 @@ import java.util.Objects; import java.util.UUID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.VerifyHelper; public final class NullAuthHandler extends AuthHandler { private volatile AuthHandler handler; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/TextFileAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/TextFileAuthHandler.java index f0d539de..cbbbec84 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/TextFileAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/TextFileAuthHandler.java @@ -8,14 +8,14 @@ import java.util.Set; import java.util.UUID; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.TextConfigReader; import ru.gravit.launcher.serialize.config.TextConfigWriter; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.ConfigEntry; import ru.gravit.launcher.serialize.config.entry.ConfigEntry.Type; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class TextFileAuthHandler extends FileAuthHandler { private static StringConfigEntry cc(String value) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java index 10338fc4..197c5501 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java @@ -6,9 +6,9 @@ import java.util.concurrent.ConcurrentHashMap; import ru.gravit.launcher.HWID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.utils.helper.VerifyHelper; public abstract class HWIDHandler extends ConfigObject implements AutoCloseable { private static final Map> HW_HANDLERS = new ConcurrentHashMap<>(4); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index 95e80d98..ca72ea45 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -1,20 +1,21 @@ package ru.gravit.launchserver.auth.hwid; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import ru.gravit.launcher.HWID; -import ru.gravit.launcher.OshiHWID; -import ru.gravit.utils.HTTPRequest; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; - import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.JsonElement; + +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.OshiHWID; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.utils.HTTPRequest; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public final class JsonHWIDHandler extends HWIDHandler { private static final Gson gson = new Gson(); 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 676b3aca..de335272 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 @@ -1,14 +1,5 @@ package ru.gravit.launchserver.auth.hwid; -import ru.gravit.launcher.HWID; -import ru.gravit.launcher.OshiHWID; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; -import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; -import ru.gravit.launchserver.auth.MySQLSourceConfig; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -16,7 +7,15 @@ import java.util.ArrayList; import java.util.List; +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.OshiHWID; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.launchserver.auth.MySQLSourceConfig; +import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public class MysqlHWIDHandler extends HWIDHandler { private final MySQLSourceConfig mySQLHolder; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java index ad957d51..649bc701 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.auth.provider; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; public final class AcceptAuthProvider extends AuthProvider { private final boolean isAdminAccess; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java index c7b1e357..3e7199c9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java @@ -5,12 +5,12 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.utils.helper.VerifyHelper; public abstract class AuthProvider extends ConfigObject implements AutoCloseable { private static final Map> AUTH_PROVIDERS = new ConcurrentHashMap<>(8); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/DigestAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/DigestAuthProvider.java index 4eb40f8a..3bd446c8 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/DigestAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/DigestAuthProvider.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; public abstract class DigestAuthProvider extends AuthProvider { private final DigestAlgorithm digest; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/FileAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/FileAuthProvider.java index 51c8325b..b2ddf936 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/FileAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/FileAuthProvider.java @@ -8,18 +8,18 @@ import java.util.Map; import java.util.Set; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.TextConfigReader; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.ConfigEntry; import ru.gravit.launcher.serialize.config.entry.ConfigEntry.Type; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class FileAuthProvider extends DigestAuthProvider { private static final class Entry extends ConfigObject { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java index 23fa2c2a..adcebad6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -5,13 +5,14 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; + +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.utils.HTTPRequest; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; public final class JsonAuthProvider extends AuthProvider { private final Gson gson = new Gson(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java index 1c48641b..c7a56de9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java @@ -8,9 +8,10 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.HTTPRequest; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; public final class MojangAuthProvider extends AuthProvider { private static final Pattern UUID_REGEX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java index ae7cf3ff..6a4dd9f7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java @@ -5,17 +5,17 @@ import java.sql.ResultSet; import java.sql.SQLException; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; +import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.ClientPermissions; +import ru.gravit.launchserver.auth.MySQLSourceConfig; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; -import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; -import ru.gravit.launchserver.auth.AuthException; -import ru.gravit.launchserver.auth.MySQLSourceConfig; public final class MySQLAuthProvider extends AuthProvider { private final MySQLSourceConfig mySQLHolder; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java index 946faf34..b523fdea 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java @@ -3,9 +3,9 @@ import java.io.IOException; import java.util.Objects; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; public final class NullAuthProvider extends AuthProvider { private volatile AuthProvider provider; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java index 001940e5..1a954195 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.utils.helper.VerifyHelper; public final class RejectAuthProvider extends AuthProvider { private final String message; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java index 6be9ea5d..2ca028ba 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java @@ -5,14 +5,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; -import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; public final class RequestAuthProvider extends AuthProvider { private final String url; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java index fe597fbb..49a9e669 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java @@ -1,21 +1,23 @@ package ru.gravit.launchserver.binary; -import ru.gravit.utils.helper.IOHelper; - import java.io.IOException; import java.io.InputStream; import java.util.Set; -import java.util.jar.JarInputStream; import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import ru.gravit.utils.helper.IOHelper; + public class BuildContext { public final ZipOutputStream output; public final JAConfigurator config; + public final JARLauncherBinary data; - public BuildContext(ZipOutputStream output, JAConfigurator config) { + public BuildContext(ZipOutputStream output, JAConfigurator config, JARLauncherBinary data) { this.output = output; this.config = config; + this.data = data; } public void pushFile(String filename, InputStream inputStream) throws IOException { @@ -24,7 +26,7 @@ public void pushFile(String filename, InputStream inputStream) throws IOExceptio IOHelper.transfer(inputStream, output); } - public void pushJarFile(JarInputStream input) throws IOException { + public void pushJarFile(ZipInputStream input) throws IOException { ZipEntry e = input.getNextEntry(); while (e != null) { output.putNextEntry(e); @@ -33,7 +35,7 @@ public void pushJarFile(JarInputStream input) throws IOException { } } - public void pushJarFile(JarInputStream input, Set blacklist) throws IOException { + public void pushJarFile(ZipInputStream input, Set blacklist) throws IOException { ZipEntry e = input.getNextEntry(); while (e != null) { if (blacklist.contains(e.getName())) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java index fe8091db..5d6c5c06 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java @@ -3,10 +3,6 @@ import java.io.IOException; import java.nio.file.Path; -import ru.gravit.launcher.Launcher; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.launchserver.LaunchServer; import net.sf.launch4j.Builder; import net.sf.launch4j.Log; import net.sf.launch4j.config.Config; @@ -14,6 +10,10 @@ import net.sf.launch4j.config.Jre; import net.sf.launch4j.config.LanguageID; import net.sf.launch4j.config.VersionInfo; +import ru.gravit.launcher.Launcher; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; public final class EXEL4JLauncherBinary extends LauncherBinary { private final static class Launch4JLog extends Log { @@ -32,8 +32,7 @@ public void clear() { // URL constants private static final String DOWNLOAD_URL = "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"; // Oracle - // JRE - // 8 + // JRE 8 // File constants private final Path faviconFile; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java index a98f014a..8b5b0520 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java @@ -3,9 +3,9 @@ import java.io.IOException; import java.nio.file.Files; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import ru.gravit.launchserver.LaunchServer; public class EXELauncherBinary extends LauncherBinary { 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 3a2b1f2d..b6d6182c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -1,21 +1,29 @@ -package ru.gravit.launchserver.binary; + package ru.gravit.launchserver.binary; import java.io.IOException; -import javassist.*; +import javassist.CannotCompileException; +import javassist.ClassPool; +import javassist.CtClass; +import javassist.CtConstructor; +import javassist.CtMethod; +import javassist.NotFoundException; public class JAConfigurator implements AutoCloseable { - ClassPool pool = ClassPool.getDefault(); - CtClass ctClass; - CtConstructor ctConstructor; - CtMethod initModuleMethod; + public ClassPool pool; + public CtClass ctClass; + public CtConstructor ctConstructor; + public CtMethod initModuleMethod; String classname; StringBuilder body; StringBuilder moduleBody; int autoincrement; - public JAConfigurator(Class configclass) throws NotFoundException { - classname = configclass.getName(); + public JAConfigurator(String configclass, JARLauncherBinary jarLauncherBinary) throws NotFoundException { + pool = new ClassPool(false); + pool.insertClassPath(jarLauncherBinary.cleanJar.toFile().getAbsolutePath()); + pool.appendSystemPath(); + classname = configclass; ctClass = pool.get(classname); ctConstructor = ctClass.getDeclaredConstructor(null); initModuleMethod = ctClass.getDeclaredMethod("initModules"); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index c971970d..8aef49b1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -5,13 +5,16 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.file.*; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipInputStream; @@ -19,310 +22,273 @@ import javassist.CannotCompileException; import javassist.NotFoundException; +import proguard.Configuration; +import proguard.ConfigurationParser; +import proguard.ParseException; +import proguard.ProGuard; import ru.gravit.launcher.AutogenConfig; import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.asm.ClassMetadataReader; +import ru.gravit.launchserver.manangers.BuildHookManager.ZipBuildHook; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launchserver.LaunchServer; -import proguard.Configuration; -import proguard.ConfigurationParser; -import proguard.ParseException; -import proguard.ProGuard; +import ru.gravit.utils.helper.UnpackHelper; public final class JARLauncherBinary extends LauncherBinary { - public static final String[] guardFileList = {"Avanguard64.dll", "Avanguard32.dll", "wrapper64.exe", "wrapper32.exe"}; + private final class RuntimeDirVisitor extends SimpleFileVisitor { + private final ZipOutputStream output; + private final Map runtime; - private final class RuntimeDirVisitor extends SimpleFileVisitor { - private final ZipOutputStream output; - private final Map runtime; + private RuntimeDirVisitor(ZipOutputStream output, Map runtime) { + this.output = output; + this.runtime = runtime; + } - private RuntimeDirVisitor(ZipOutputStream output, Map runtime) { - this.output = output; - this.runtime = runtime; - } + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + String dirName = IOHelper.toString(runtimeDir.relativize(dir)); + output.putNextEntry(newEntry(dirName + '/')); + return super.preVisitDirectory(dir, attrs); + } - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(runtimeDir.relativize(dir)); - output.putNextEntry(newEntry(dirName + '/')); - return super.preVisitDirectory(dir, attrs); - } + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + String fileName = IOHelper.toString(runtimeDir.relativize(file)); + runtime.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(runtimeDir.relativize(file)); - runtime.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); + // Create zip entry and transfer contents + output.putNextEntry(newEntry(fileName)); + IOHelper.transfer(file, output); - // Create zip entry and transfer contents - output.putNextEntry(newEntry(fileName)); - IOHelper.transfer(file, output); + // Return result + return super.visitFile(file, attrs); + } + } - // Return result - return super.visitFile(file, attrs); - } - } - - // TODO: new native security wrapper and library... - @SuppressWarnings("unused") + // TODO: new native security wrapper and library... + @SuppressWarnings("unused") private final class GuardDirVisitor extends SimpleFileVisitor { - private final ZipOutputStream output; - private final Map guard; + private final ZipOutputStream output; + private final Map guard; - private GuardDirVisitor(ZipOutputStream output, Map guard) { - this.output = output; - this.guard = guard; - } + private GuardDirVisitor(ZipOutputStream output, Map guard) { + this.output = output; + this.guard = guard; + } - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(guardDir.relativize(dir)); - output.putNextEntry(newGuardEntry(dirName + '/')); - return super.preVisitDirectory(dir, attrs); - } + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + String dirName = IOHelper.toString(guardDir.relativize(dir)); + output.putNextEntry(newGuardEntry(dirName + '/')); + return super.preVisitDirectory(dir, attrs); + } - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(guardDir.relativize(file)); - guard.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + String fileName = IOHelper.toString(guardDir.relativize(file)); + guard.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); - // Create zip entry and transfer contents - output.putNextEntry(newGuardEntry(fileName)); - IOHelper.transfer(file, output); + // Create zip entry and transfer contents + output.putNextEntry(newGuardEntry(fileName)); + IOHelper.transfer(file, output); - // Return result - return super.visitFile(file, attrs); - } - } + // Return result + return super.visitFile(file, attrs); + } + } - private static ZipEntry newEntry(String fileName) { - return newZipEntry(Launcher.RUNTIME_DIR + IOHelper.CROSS_SEPARATOR + fileName); - } + private static ZipEntry newEntry(String fileName) { + return newZipEntry(Launcher.RUNTIME_DIR + IOHelper.CROSS_SEPARATOR + fileName); + } - private static ZipEntry newGuardEntry(String fileName) { - return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName); - } + private static ZipEntry newGuardEntry(String fileName) { + return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName); + } + public final Path cleanJar; + public final Path runtimeDir; + public final Path guardDir; + public final Path initScriptFile; + public final Path obfJar; + public final Path obfOutJar; + public ClassMetadataReader reader; - public final Path runtimeDir; - public final Path guardDir; + public JARLauncherBinary(LaunchServer server) throws IOException { + super(server, server.dir.resolve(server.config.binaryName + "-nonObf.jar"), + server.dir.resolve(server.config.binaryName + ".jar")); + runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); + guardDir = server.dir.resolve(Launcher.GUARD_DIR); + initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE); + obfJar = server.dir.resolve(server.config.binaryName + "-obfed.jar"); + obfOutJar = server.config.buildPostTransform.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar") + : syncBinaryFile; + cleanJar = server.dir.resolve(server.config.binaryName + "-clean.jar"); + reader = new ClassMetadataReader(); + UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), cleanJar); + reader.getCp().add(new JarFile(cleanJar.toFile())); + tryUnpack(); + } + @Override + public void build() throws IOException { + tryUnpack(); - public final Path initScriptFile; + // Build launcher binary + LogHelper.info("Building launcher binary file"); + stdBuild(); + // ProGuard + Configuration proguard_cfg = new Configuration(); + ConfigurationParser parser = new ConfigurationParser(server.proguardConf.confStrs.toArray(new String[0]), + server.proguardConf.proguard.toFile(), System.getProperties()); + try { + parser.parse(proguard_cfg); + ProGuard proGuard = new ProGuard(proguard_cfg); + proGuard.execute(); + } catch (ParseException e1) { + e1.printStackTrace(); + } + for (Runnable r : server.buildHookManager.getPostProguardRunHooks()) + r.run(); + try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(obfJar)); + ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(obfOutJar))) { + ZipEntry e = input.getNextEntry(); + while (e != null) { + String filename = e.getName(); + output.putNextEntry(IOHelper.newZipEntry(e.getName())); + if (filename.endsWith(".class")) { + String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length()); + byte[] bytes; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { + IOHelper.transfer(input, outputStream); + bytes = outputStream.toByteArray(); + } + bytes = server.buildHookManager.proGuardClassTransform(bytes, classname, this); + try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { + IOHelper.transfer(inputStream, output); + } + } else + IOHelper.transfer(input, output); + e = input.getNextEntry(); + } + for (ZipBuildHook h : server.buildHookManager.getProguardBuildHooks()) + h.build(output); + } + if (server.config.buildPostTransform.enabled) + transformedBuild(); + } - public final Path obfJar; - - - public JARLauncherBinary(LaunchServer server) throws IOException { - super(server, server.dir.resolve(server.config.binaryName + ".jar"), - server.dir.resolve(server.config.binaryName + "-obf.jar")); - runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); - guardDir = server.dir.resolve("guard"); - initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE); - obfJar = syncBinaryFile; - tryUnpackRuntime(); - tryUnpackGuard(); - } - - @Override - public void build() throws IOException { - tryUnpackRuntime(); - tryUnpackGuard(); - - // Build launcher binary - LogHelper.info("Building launcher binary file"); - stdBuild(); - - // ProGuard - Configuration proguard_cfg = new Configuration(); - ConfigurationParser parser = new ConfigurationParser( - server.proguardConf.confStrs.toArray(new String[0]), - server.proguardConf.proguard.toFile(), System.getProperties()); - try { - parser.parse(proguard_cfg); - ProGuard proGuard = new ProGuard(proguard_cfg); - proGuard.execute(); - } catch (ParseException e1) { - e1.printStackTrace(); - } - if (server.buildHookManager.isNeedPostProguardHook()) { - Path obfPath = Paths.get(server.config.binaryName + "-obf.jar"); - Path tmpPath = Paths.get(server.config.binaryName + "-tmp.jar"); - IOHelper.move(obfPath, tmpPath); - try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(obfPath))) { - try (ZipInputStream input = new ZipInputStream( - IOHelper.newInput(tmpPath))) { - ZipEntry e = input.getNextEntry(); - while (e != null) { - String filename = e.getName(); - output.putNextEntry(e); - if (filename.endsWith(".class")) { - CharSequence classname = filename.replace('/', '.').subSequence(0, - filename.length() - ".class".length()); - byte[] bytes; - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { - IOHelper.transfer(input, outputStream); - bytes = outputStream.toByteArray(); - } - bytes = server.buildHookManager.proGuardClassTransform(bytes, classname); - try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { - IOHelper.transfer(inputStream, output); - } - } else - IOHelper.transfer(input, output); - e = input.getNextEntry(); - } - } - } - } - if (server.config.buildPostTransform.enabled) - transformedBuild(); - } - - private void transformedBuild() throws IOException { - List cmd = new ArrayList<>(1); - server.config.buildPostTransform.script.forEach(v -> CommonHelper.replace(v, "launcher-output", IOHelper.toAbsPathString(syncBinaryFile), "launcher-obf", IOHelper.toAbsPathString(obfJar), "launcher-nonObf", IOHelper.toAbsPathString(binaryFile))); - ProcessBuilder builder = new ProcessBuilder(); - builder.directory(IOHelper.toAbsPath(server.dir).toFile()); - builder.inheritIO(); - builder.command(cmd); - Process proc = builder.start(); - try { + private void transformedBuild() throws IOException { + List cmd = new ArrayList<>(1); + for (String v : server.config.buildPostTransform.script) + cmd.add(CommonHelper.replace(v, "launcher-output", IOHelper.toAbsPathString(syncBinaryFile), "launcher-obf", + IOHelper.toAbsPathString(obfJar), "launcher-nonObf", IOHelper.toAbsPathString(binaryFile))); + ProcessBuilder builder = new ProcessBuilder(); + builder.directory(IOHelper.toAbsPath(server.dir).toFile()); + builder.inheritIO(); + builder.command(cmd); + Process proc = builder.start(); + try { LogHelper.debug("Transformer process return code: " + proc.waitFor()); } catch (InterruptedException e) { LogHelper.error(e); } - } + } - private void stdBuild() throws IOException { - try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(binaryFile)); - JAConfigurator jaConfigurator = new JAConfigurator(AutogenConfig.class)) { - BuildContext context = new BuildContext(output, jaConfigurator); - server.buildHookManager.preHook(context); - jaConfigurator.setAddress(server.config.getAddress()); - jaConfigurator.setPort(server.config.port); - jaConfigurator.setProjectName(server.config.projectName); - jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); - jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); - jaConfigurator.setUsingWrapper(server.config.isUsingWrapper); - jaConfigurator.setDownloadJava(server.config.isDownloadJava); - server.buildHookManager.registerAllClientModuleClass(jaConfigurator); - try (ZipInputStream input = new ZipInputStream( - IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) { - ZipEntry e = input.getNextEntry(); - while (e != null) { - String filename = e.getName(); - if (server.buildHookManager.isContainsBlacklist(filename)) { - e = input.getNextEntry(); - continue; - } - try { - output.putNextEntry(e); - } catch (ZipException ex) { - LogHelper.error(ex); - e = input.getNextEntry(); - continue; - } - if (filename.endsWith(".class")) { - CharSequence classname = filename.replace('/', '.').subSequence(0, - filename.length() - ".class".length()); - byte[] bytes; - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { - IOHelper.transfer(input, outputStream); - bytes = outputStream.toByteArray(); - } - bytes = server.buildHookManager.classTransform(bytes, classname); - try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { - IOHelper.transfer(inputStream, output); - } - } else - IOHelper.transfer(input, output); - // } - e = input.getNextEntry(); - } - } - // write additional classes - for (Entry ent : server.buildHookManager.getIncludeClass().entrySet()) { - output.putNextEntry(newZipEntry(ent.getKey().replace('.', '/').concat(".class"))); - output.write(server.buildHookManager.classTransform(ent.getValue(), ent.getKey())); - } - // map for guard - Map runtime = new HashMap<>(256); - if (server.buildHookManager.buildRuntime()) { - // Verify has init script file - if (!IOHelper.isFile(initScriptFile)) - throw new IOException(String.format("Missing init script file ('%s')", Launcher.INIT_SCRIPT_FILE)); - // Write launcher guard dir - IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false); - //IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); - } - // Create launcher config file - byte[] launcherConfigBytes; - try (ByteArrayOutputStream configArray = IOHelper.newByteArrayOutput()) { - try (HOutput configOutput = new HOutput(configArray)) { - new LauncherConfig(server.config.getAddress(), server.config.port, server.publicKey, runtime) - .write(configOutput); - } - launcherConfigBytes = configArray.toByteArray(); - } + private void stdBuild() throws IOException { + try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(binaryFile)); + JAConfigurator jaConfigurator = new JAConfigurator(AutogenConfig.class.getName(), this)) { + jaConfigurator.pool.insertClassPath(cleanJar.toFile().getAbsolutePath()); + BuildContext context = new BuildContext(output, jaConfigurator, this); + server.buildHookManager.preHook(context); + jaConfigurator.setAddress(server.config.getAddress()); + jaConfigurator.setPort(server.config.port); + jaConfigurator.setProjectName(server.config.projectName); + jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); + jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); + jaConfigurator.setUsingWrapper(server.config.isUsingWrapper); + jaConfigurator.setDownloadJava(server.config.isDownloadJava); + server.buildHookManager.registerAllClientModuleClass(jaConfigurator); + try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(cleanJar))) { + ZipEntry e = input.getNextEntry(); + while (e != null) { + String filename = e.getName(); + if (server.buildHookManager.isContainsBlacklist(filename)) { + e = input.getNextEntry(); + continue; + } + try { + output.putNextEntry(IOHelper.newZipEntry(e.getName())); + } catch (ZipException ex) { + LogHelper.error(ex); + e = input.getNextEntry(); + continue; + } + if (filename.endsWith(".class")) { + String classname = filename.replace('/', '.').substring(0, + filename.length() - ".class".length()); + byte[] bytes; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { + IOHelper.transfer(input, outputStream); + bytes = outputStream.toByteArray(); + } + bytes = server.buildHookManager.classTransform(bytes, classname, this); + try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { + IOHelper.transfer(inputStream, output); + } + } else + IOHelper.transfer(input, output); + e = input.getNextEntry(); + } + } + // write additional classes + for (Entry ent : server.buildHookManager.getIncludeClass().entrySet()) { + output.putNextEntry(newZipEntry(ent.getKey().replace('.', '/').concat(".class"))); + output.write(server.buildHookManager.classTransform(ent.getValue(), ent.getKey(), this)); + } + // map for guard + Map runtime = new HashMap<>(256); + if (server.buildHookManager.buildRuntime()) { + // Verify has init script file + if (!IOHelper.isFile(initScriptFile)) + throw new IOException(String.format("Missing init script file ('%s')", Launcher.INIT_SCRIPT_FILE)); + // Write launcher guard dir + IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false); + // IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); + } + // Create launcher config file + byte[] launcherConfigBytes; + try (ByteArrayOutputStream configArray = IOHelper.newByteArrayOutput()) { + try (HOutput configOutput = new HOutput(configArray)) { + new LauncherConfig(server.config.getAddress(), server.config.port, server.publicKey, runtime) + .write(configOutput); + } + launcherConfigBytes = configArray.toByteArray(); + } - // Write launcher config file - output.putNextEntry(newZipEntry(Launcher.CONFIG_FILE)); - output.write(launcherConfigBytes); - ZipEntry e = newZipEntry(jaConfigurator.getZipEntryPath()); - output.putNextEntry(e); - jaConfigurator.compile(); - output.write(jaConfigurator.getBytecode()); - server.buildHookManager.postHook(context); - } catch (CannotCompileException | NotFoundException e) { - LogHelper.error(e); - } - } + // Write launcher config file + output.putNextEntry(newZipEntry(Launcher.CONFIG_FILE)); + output.write(launcherConfigBytes); + ZipEntry e = newZipEntry(jaConfigurator.getZipEntryPath()); + output.putNextEntry(e); + jaConfigurator.compile(); + output.write(jaConfigurator.getBytecode()); + server.buildHookManager.postHook(context); + } catch (CannotCompileException | NotFoundException e) { + LogHelper.error(e); + } + } - - public void tryUnpackRuntime() throws IOException { - // Verify is guard dir unpacked - if (IOHelper.isDir(runtimeDir)) - return; // Already unpacked - - // Unpack launcher guard files - Files.createDirectory(runtimeDir); - LogHelper.info("Unpacking launcher runtime files"); - if (Launcher.class.getResource("/runtime.zip") == null) return; - try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("runtime.zip"))) { - for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { - if (entry.isDirectory()) - continue; // Skip dirs - - // Unpack guard file - IOHelper.transfer(input, runtimeDir.resolve(IOHelper.toPath(entry.getName()))); - } - } - } - - public void tryUnpackGuard() throws IOException { - // Verify is guard dir unpacked - if (IOHelper.isDir(guardDir)) - return; // Already unpacked - - // Unpack launcher guard files - Files.createDirectory(guardDir); - LogHelper.info("Unpacking launcher native guard files"); - if (Launcher.class.getResource("/guard.zip") == null) return; - try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("guard.zip"))) { - for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { - if (entry.isDirectory()) - continue; // Skip dirs - - // Unpack guard file - IOHelper.transfer(input, guardDir.resolve(IOHelper.toPath(entry.getName()))); - } - } - } + public void tryUnpack() throws IOException { + LogHelper.info("Unpacking launcher native guard files and runtime"); + UnpackHelper.unpackZipNoCheck("guard.zip", guardDir); + UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir); + } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java index 508bfe8c..75429ba0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -4,16 +4,16 @@ import java.nio.file.Path; import ru.gravit.launcher.serialize.signed.DigestBytesHolder; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; public abstract class LauncherBinary { - protected final LaunchServer server; + public final LaunchServer server; - protected final Path binaryFile; - protected final Path syncBinaryFile; + public final Path binaryFile; + public final Path syncBinaryFile; private volatile DigestBytesHolder binary; private volatile byte[] sign; 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 8f0041a0..402444e5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java @@ -2,8 +2,8 @@ import java.util.UUID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.VerifyHelper; public abstract class Command { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java index 0ce87db7..c5048a5b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java @@ -2,11 +2,11 @@ import java.util.UUID; -import ru.gravit.launchserver.auth.provider.AuthProvider; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.AuthProviderResult; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class AuthCommand extends Command { public AuthCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java index 9ba187f2..3511028c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java @@ -2,8 +2,8 @@ import java.util.List; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.launcher.HWID; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; public class BanCommand extends Command { 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 7efdbf31..4fb600d8 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 @@ -3,10 +3,10 @@ import java.io.IOException; import java.util.UUID; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.helper.LogHelper; public final class UUIDToUsernameCommand extends Command { public UUIDToUsernameCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java index 66c3d80b..edfb3602 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java @@ -2,8 +2,8 @@ import java.util.List; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.launcher.HWID; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; public class UnbanCommand extends Command { 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 70652c54..bac45f34 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 @@ -3,10 +3,10 @@ import java.io.IOException; import java.util.UUID; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.helper.LogHelper; public final class UsernameToUUIDCommand extends Command { public UsernameToUUIDCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ClearCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ClearCommand.java index ff1bbee9..f6e62e8c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ClearCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ClearCommand.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class ClearCommand extends Command { public ClearCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java index 8edb2fc1..19adc8b6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class DebugCommand extends Command { public DebugCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/GCCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/GCCommand.java index 845eb06a..f81b36e5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/GCCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/GCCommand.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; public final class GCCommand extends Command { public GCCommand(LaunchServer server) { 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 8c1139a1..364de723 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 @@ -2,10 +2,10 @@ import java.util.Map.Entry; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.helper.LogHelper; public final class HelpCommand extends Command { private static void printCommand(String name, Command command) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/LogConnectionsCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/LogConnectionsCommand.java index 8c16fd2f..f3214401 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/LogConnectionsCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/LogConnectionsCommand.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class LogConnectionsCommand extends Command { public LogConnectionsCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java index cea9302e..ddb75200 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.utils.helper.JVMHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.JVMHelper; public final class StopCommand extends Command { public StopCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/VersionCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/VersionCommand.java index 40f60995..3a2c94d7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/VersionCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/VersionCommand.java @@ -1,9 +1,9 @@ package ru.gravit.launchserver.command.basic; import ru.gravit.launcher.Launcher; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class VersionCommand extends Command { public VersionCommand(LaunchServer server) { 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 e9f56be8..232e532f 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 @@ -11,9 +11,6 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.launchserver.command.basic.*; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; @@ -22,6 +19,19 @@ import ru.gravit.launchserver.command.auth.UUIDToUsernameCommand; import ru.gravit.launchserver.command.auth.UnbanCommand; import ru.gravit.launchserver.command.auth.UsernameToUUIDCommand; +import ru.gravit.launchserver.command.basic.BuildCommand; +import ru.gravit.launchserver.command.basic.ClearCommand; +import ru.gravit.launchserver.command.basic.DebugCommand; +import ru.gravit.launchserver.command.basic.GCCommand; +import ru.gravit.launchserver.command.basic.HelpCommand; +import ru.gravit.launchserver.command.basic.LogConnectionsCommand; +import ru.gravit.launchserver.command.basic.ProguardCleanCommand; +import ru.gravit.launchserver.command.basic.RebindCommand; +import ru.gravit.launchserver.command.basic.RegenProguardDictCommand; +import ru.gravit.launchserver.command.basic.RemoveMappingsProguardCommand; +import ru.gravit.launchserver.command.basic.StopCommand; +import ru.gravit.launchserver.command.basic.TestCommand; +import ru.gravit.launchserver.command.basic.VersionCommand; import ru.gravit.launchserver.command.hash.DownloadAssetCommand; import ru.gravit.launchserver.command.hash.DownloadClientCommand; import ru.gravit.launchserver.command.hash.IndexAssetCommand; @@ -31,6 +41,8 @@ import ru.gravit.launchserver.command.hash.UnindexAssetCommand; import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public abstract class CommandHandler implements Runnable { private static String[] parse(CharSequence line) throws CommandException { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java index 3b1bde83..8fdfef7e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java @@ -3,9 +3,9 @@ import java.io.IOException; import jline.console.ConsoleReader; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper.Output; -import ru.gravit.launchserver.LaunchServer; public final class JLineCommandHandler extends CommandHandler { private final class JLineOutput implements Output { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java index 9f291a86..9e7c6c15 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java @@ -3,8 +3,8 @@ import java.io.BufferedReader; import java.io.IOException; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; public final class StdCommandHandler extends CommandHandler { private final BufferedReader reader; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java index a1fb162d..49a3770a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java @@ -4,12 +4,12 @@ import java.nio.file.Path; import java.util.Collections; -import ru.gravit.utils.HttpDownloader; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.HttpDownloader; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; public final class DownloadAssetCommand extends Command { 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 f86ead41..ec7376aa 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 @@ -7,9 +7,6 @@ import java.nio.file.Path; import java.util.Collections; -import ru.gravit.utils.HttpDownloader; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launcher.serialize.config.TextConfigReader; @@ -18,6 +15,9 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.HttpDownloader; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; public final class DownloadClientCommand extends Command { 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 6af2b412..9a3a1e50 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 @@ -11,13 +11,14 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.launchserver.command.CommandException; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; public final class IndexAssetCommand extends Command { private static Gson gson = new Gson(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java index 2e8cf4c7..082c37ec 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java @@ -2,9 +2,9 @@ import java.io.IOException; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class SyncBinariesCommand extends Command { public SyncBinariesCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java index 27a53a79..423b3152 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java @@ -2,9 +2,9 @@ import java.io.IOException; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class SyncProfilesCommand extends Command { public SyncProfilesCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java index 3cddd0f3..e4dc8996 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java @@ -5,9 +5,9 @@ import java.util.HashSet; import java.util.Set; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public final class SyncUpdatesCommand extends Command { public SyncUpdatesCommand(LaunchServer server) { 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 5936a303..25fc3079 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 @@ -6,12 +6,15 @@ import java.util.Collections; import java.util.Map; -import com.google.gson.*; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +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.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; public final class UnindexAssetCommand extends Command { private static JsonParser parser = new JsonParser(); 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 2370dd98..c626b7fc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java @@ -1,5 +1,32 @@ package ru.gravit.launchserver.fileserver; +import static io.netty.handler.codec.http.HttpMethod.GET; +import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; +import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; +import static io.netty.handler.codec.http.HttpResponseStatus.FOUND; +import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR; +import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; +import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; +import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; +import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.RandomAccessFile; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.file.Path; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; +import java.util.regex.Pattern; + +import javax.activation.MimetypesFileTypeMap; + import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; @@ -15,34 +42,15 @@ import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpChunkedInput; import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpUtil; import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponse; 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; -import javax.activation.MimetypesFileTypeMap; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.nio.file.Path; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Locale; -import java.util.TimeZone; -import java.util.regex.Pattern; - -import static io.netty.handler.codec.http.HttpMethod.*; -import static io.netty.handler.codec.http.HttpResponseStatus.*; -import static io.netty.handler.codec.http.HttpVersion.*; - public class FileServerHandler extends SimpleChannelInboundHandler { public static final String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java index d693bd16..0a449d24 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java @@ -4,41 +4,49 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.zip.ZipOutputStream; import ru.gravit.launcher.AutogenConfig; import ru.gravit.launcher.modules.TestClientModule; import ru.gravit.launchserver.binary.BuildContext; import ru.gravit.launchserver.binary.JAConfigurator; +import ru.gravit.launchserver.binary.JARLauncherBinary; public class BuildHookManager { @FunctionalInterface - public interface PostBuildHook { + public static interface ZipBuildHook { + void build(ZipOutputStream context); + } + + @FunctionalInterface + public static interface BuildHook { void build(BuildContext context); } @FunctionalInterface - public interface PreBuildHook { - void build(BuildContext context); - } - - @FunctionalInterface - public interface Transformer { - byte[] transform(byte[] input, CharSequence classname); + public static interface Transformer { + byte[] transform(byte[] input, String classname, JARLauncherBinary data); } private boolean BUILDRUNTIME; - private final Set POST_HOOKS; + private final Set POST_HOOKS; + private final Set POST_PROGUARDRUN_HOOKS; private final Set POST_PROGUARD_HOOKS; - private final Set PRE_HOOKS; + private final Set PRE_HOOKS; + private final Set POST_PROGUARD_BUILDHOOKS; private final Set CLASS_TRANSFORMER; private final Set CLASS_BLACKLIST; private final Set MODULE_CLASS; private final Map INCLUDE_CLASS; + private final NodeTransformer noder; + private final NodeTransformer proguardNoder; public BuildHookManager() { POST_HOOKS = new HashSet<>(4); + POST_PROGUARDRUN_HOOKS = new HashSet<>(4); POST_PROGUARD_HOOKS = new HashSet<>(4); PRE_HOOKS = new HashSet<>(4); + POST_PROGUARD_BUILDHOOKS = new HashSet<>(4); CLASS_BLACKLIST = new HashSet<>(4); MODULE_CLASS = new HashSet<>(4); INCLUDE_CLASS = new HashMap<>(4); @@ -49,9 +57,37 @@ public BuildHookManager() { registerIgnoredClass("META-INF/LICENSE"); registerIgnoredClass("META-INF/NOTICE"); registerClientModuleClass(TestClientModule.class.getName()); + noder = new NodeTransformer(); + registerClassTransformer(noder); + proguardNoder = new NodeTransformer(); + registerProGuardHook(proguardNoder); } - public void autoRegisterIgnoredClass(String clazz) { + public NodeTransformer getProguardNoder() { + return proguardNoder; + } + + public NodeTransformer getNoder() { + return noder; + } + + public Set getProguardBuildHooks() { + return POST_PROGUARD_BUILDHOOKS; + } + + public Set getPostProguardRunHooks() { + return POST_PROGUARDRUN_HOOKS; + } + + public void addPostProguardRunHook(Runnable hook) { + POST_PROGUARDRUN_HOOKS.add(hook); + } + + public void addPostProguardRunHook(ZipBuildHook hook) { + POST_PROGUARD_BUILDHOOKS.add(hook); + } + + public void autoRegisterIgnoredClass(String clazz) { CLASS_BLACKLIST.add(clazz.replace('.', '/').concat(".class")); } @@ -59,15 +95,15 @@ public boolean buildRuntime() { return BUILDRUNTIME; } - public byte[] classTransform(byte[] clazz, CharSequence classname) { + public byte[] classTransform(byte[] clazz, String classname, JARLauncherBinary reader) { byte[] result = clazz; - for (Transformer transformer : CLASS_TRANSFORMER) result = transformer.transform(result, classname); + for (Transformer transformer : CLASS_TRANSFORMER) result = transformer.transform(result, classname, reader); return result; } - public byte[] proGuardClassTransform(byte[] clazz, CharSequence classname) { + public byte[] proGuardClassTransform(byte[] clazz, String classname, JARLauncherBinary reader) { byte[] result = clazz; - for (Transformer transformer : POST_PROGUARD_HOOKS) result = transformer.transform(result, classname); + for (Transformer transformer : POST_PROGUARD_HOOKS) result = transformer.transform(result, classname, reader); return result; } @@ -80,15 +116,18 @@ public Map getIncludeClass() { } public boolean isContainsBlacklist(String clazz) { - return CLASS_BLACKLIST.contains(clazz); + for (String classB : CLASS_BLACKLIST) { + if (clazz.startsWith(classB)) return true; + } + return false; } public void postHook(BuildContext context) { - for (PostBuildHook hook : POST_HOOKS) hook.build(context); + for (BuildHook hook : POST_HOOKS) hook.build(context); } public void preHook(BuildContext context) { - for (PreBuildHook hook : PRE_HOOKS) hook.build(context); + for (BuildHook hook : PRE_HOOKS) hook.build(context); } public void registerAllClientModuleClass(JAConfigurator cfg) { @@ -107,7 +146,7 @@ public void registerIgnoredClass(String clazz) { CLASS_BLACKLIST.add(clazz); } - public void registerPostHook(PostBuildHook hook) { + public void registerPostHook(BuildHook hook) { POST_HOOKS.add(hook); } @@ -116,10 +155,10 @@ public void registerProGuardHook(Transformer hook) { } public boolean isNeedPostProguardHook() { - return !POST_PROGUARD_HOOKS.isEmpty(); + return POST_PROGUARD_HOOKS.size() > 1 || !POST_PROGUARDRUN_HOOKS.isEmpty() || !POST_PROGUARD_BUILDHOOKS.isEmpty() || !proguardNoder.getTransLst().isEmpty(); } - public void registerPreHook(PreBuildHook hook) { + public void registerPreHook(BuildHook hook) { PRE_HOOKS.add(hook); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java index d9485f64..89633b36 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.manangers; -import ru.gravit.utils.helper.IOHelper; - import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import ru.gravit.utils.helper.IOHelper; + public class MirrorManager { public class Mirror { URL url; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java index c9571184..3364a488 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java @@ -3,11 +3,11 @@ import java.net.URL; import java.util.ArrayList; -import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.launcher.modules.SimpleModuleManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.modules.CoreModule; import ru.gravit.launchserver.modules.LaunchServerModuleContext; +import ru.gravit.utils.PublicURLClassLoader; public class ModulesManager extends SimpleModuleManager { public ModulesManager(LaunchServer lsrv) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java new file mode 100644 index 00000000..967aba62 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java @@ -0,0 +1,40 @@ +package ru.gravit.launchserver.manangers; + +import java.util.ArrayList; +import java.util.List; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.ClassNode; + +import ru.gravit.launchserver.asm.SafeClassWriter; +import ru.gravit.launchserver.binary.JARLauncherBinary; +import ru.gravit.launchserver.manangers.BuildHookManager.Transformer; + +public class NodeTransformer implements Transformer { + @FunctionalInterface + public static interface ClassNodeTransformer { + void transform(ClassNode node, String classname, JARLauncherBinary data); + } + + private final List transLst; + + public List getTransLst() { + return transLst; + } + + public NodeTransformer() { + transLst = new ArrayList<>(); + } + + @Override + public byte[] transform(byte[] input, String classname, JARLauncherBinary data) { + ClassReader cr = new ClassReader(input); + ClassNode cn = new ClassNode(); + cr.accept(cn, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); + for (ClassNodeTransformer tr : transLst) tr.transform(cn, classname, data); + ClassWriter cw = new SafeClassWriter(data.reader, ClassWriter.COMPUTE_MAXS); + cn.accept(cw); + return cw.toByteArray(); + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/CoreModule.java b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/CoreModule.java index d03074bc..35ee3c83 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/CoreModule.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/CoreModule.java @@ -1,9 +1,9 @@ package ru.gravit.launchserver.modules; import ru.gravit.launcher.Launcher; -import ru.gravit.utils.Version; import ru.gravit.launcher.modules.Module; import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.utils.Version; public class CoreModule implements Module { @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java index ac0bd104..30279000 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java @@ -1,9 +1,9 @@ package ru.gravit.launchserver.modules; -import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.launcher.modules.ModuleContext; import ru.gravit.launcher.modules.ModulesManagerInterface; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.PublicURLClassLoader; public class LaunchServerModuleContext implements ModuleContext { public final LaunchServer launchServer; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/SimpleModule.java b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/SimpleModule.java index 4169d38e..7937cafd 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/SimpleModule.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/SimpleModule.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver.modules; -import ru.gravit.utils.Version; import ru.gravit.launcher.modules.Module; import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.utils.Version; public class SimpleModule implements Module { @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java index b342229f..4abd5a2a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java @@ -4,17 +4,26 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.launchserver.response.auth.*; -import ru.gravit.launchserver.response.update.*; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.launchserver.response.auth.AuthServerResponse; +import ru.gravit.launchserver.response.auth.ChangeServerResponse; +import ru.gravit.launchserver.response.auth.CheckServerResponse; +import ru.gravit.launchserver.response.auth.JoinServerResponse; +import ru.gravit.launchserver.response.auth.SetProfileResponse; import ru.gravit.launchserver.response.profile.BatchProfileByUsernameResponse; import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse; import ru.gravit.launchserver.response.profile.ProfileByUsernameResponse; +import ru.gravit.launchserver.response.update.LauncherResponse; +import ru.gravit.launchserver.response.update.LegacyLauncherResponse; +import ru.gravit.launchserver.response.update.ProfilesResponse; +import ru.gravit.launchserver.response.update.UpdateListResponse; +import ru.gravit.launchserver.response.update.UpdateResponse; +import ru.gravit.utils.helper.LogHelper; public abstract class Response { @FunctionalInterface diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java index 093f9b26..b2d5ca21 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java @@ -8,11 +8,6 @@ import javax.crypto.IllegalBlockSizeException; import ru.gravit.launcher.OshiHWID; -import ru.gravit.launchserver.socket.Client; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -25,6 +20,11 @@ import ru.gravit.launchserver.auth.provider.AuthProviderResult; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class AuthResponse extends Response { private static String echo(int length) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java index 87b19a89..f32b914e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java @@ -1,5 +1,11 @@ package ru.gravit.launchserver.response.auth; +import java.util.Arrays; +import java.util.Collection; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -17,11 +23,6 @@ import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import java.util.Arrays; -import java.util.Collection; - public final class AuthServerResponse extends Response { private static String echo(int length) { char[] chars = new char[length]; 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 1026343e..81b8f6d8 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 @@ -3,8 +3,6 @@ import java.io.IOException; import java.util.UUID; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -12,6 +10,8 @@ import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class CheckServerResponse extends Response { 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 4036df6e..ced86c20 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 @@ -2,15 +2,15 @@ import java.io.IOException; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class JoinServerResponse extends Response { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java index 313eac85..25fcac10 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java @@ -1,5 +1,7 @@ package ru.gravit.launchserver.response.auth; +import java.util.Collection; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -9,8 +11,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.Client; -import java.util.Collection; - public class SetProfileResponse extends Response { public SetProfileResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { super(server, session, input, output, ip); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java index 3f2144ce..00966979 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java @@ -3,12 +3,12 @@ import java.io.IOException; import java.util.Arrays; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.VerifyHelper; public final class BatchProfileByUsernameResponse extends Response { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java index d58f7a46..f5ab6add 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.UUID; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.serialize.HInput; @@ -11,6 +10,7 @@ import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.LogHelper; public final class ProfileByUUIDResponse extends Response { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java index 793db407..213c8db4 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java @@ -3,12 +3,12 @@ import java.io.IOException; import java.util.UUID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.VerifyHelper; public final class ProfileByUsernameResponse extends Response { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java index 114a55d5..4edaadd5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.update; +import java.io.IOException; +import java.util.Arrays; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.signed.DigestBytesHolder; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.Client; -import java.io.IOException; -import java.util.Arrays; - public final class LauncherResponse extends Response { public LauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java index b3542dad..6af47d77 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java @@ -2,12 +2,12 @@ import java.io.IOException; -import ru.gravit.launchserver.binary.LauncherBinary; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.binary.LauncherBinary; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.SecurityHelper; public final class LegacyLauncherResponse extends Response { 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 d7cef899..45c11676 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 @@ -3,14 +3,14 @@ import java.io.IOException; import java.util.Collection; -import ru.gravit.launchserver.socket.Client; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.utils.helper.LogHelper; public final class ProfilesResponse extends Response { 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 4d001e22..676ea21c 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 @@ -12,8 +12,6 @@ import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedEntry.Type; import ru.gravit.launcher.profiles.ClientProfile; -import ru.gravit.launchserver.socket.Client; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launcher.request.UpdateAction; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -21,6 +19,8 @@ import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.utils.helper.IOHelper; public final class UpdateResponse extends Response { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java index 9d265cdf..2964aa65 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java @@ -1,5 +1,34 @@ package ru.gravit.launchserver.socket; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +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.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.TrustManager; + import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; @@ -24,26 +53,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.net.ssl.*; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.nio.channels.Selector; -import java.nio.channels.ServerSocketChannel; -import java.security.*; -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.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - @SuppressWarnings({"unused", "rawtypes"}) public final class NettyServerSocketHandler implements Runnable, AutoCloseable { private static final String WEBSOCKET_PATH = "/api"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java index 6a16acda..30691651 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java @@ -6,15 +6,15 @@ import java.net.SocketException; import ru.gravit.launcher.Launcher; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.manangers.SessionManager; import ru.gravit.launchserver.response.Response; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; public final class ResponseThread implements Runnable { class Handshake { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java index 46b25989..c7b50946 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java @@ -12,11 +12,11 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.manangers.SessionManager; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.LogHelper; public final class ServerSocketHandler implements Runnable, AutoCloseable { public interface Listener { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java index dc1bd5ee..7f548c8d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java @@ -1,6 +1,7 @@ package ru.gravit.launchserver.socket.websocket; import com.google.gson.GsonBuilder; + import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.group.DefaultChannelGroup; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java index 9fbc8e43..6e31a384 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java @@ -1,12 +1,5 @@ package ru.gravit.launchserver.socket.websocket; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.*; -import io.netty.handler.codec.http.*; -import io.netty.handler.ssl.SslHandler; -import io.netty.util.CharsetUtil; - import static io.netty.handler.codec.http.HttpMethod.GET; import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; @@ -14,6 +7,22 @@ import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import static io.netty.handler.codec.rtsp.RtspResponseStatuses.NOT_FOUND; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.handler.codec.http.HttpUtil; +import io.netty.handler.ssl.SslHandler; +import io.netty.util.CharsetUtil; + public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler { private final String websocketPath; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java index 2eb12279..a18ff095 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java @@ -1,17 +1,20 @@ package ru.gravit.launchserver.socket.websocket; +import java.util.HashMap; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; + import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.group.ChannelGroup; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; import ru.gravit.launcher.hasher.HashedEntry; +import ru.gravit.launcher.hasher.HashedEntryAdapter; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.websocket.json.EchoResponse; -import ru.gravit.launcher.hasher.HashedEntryAdapter; import ru.gravit.launchserver.socket.websocket.json.JsonResponseAdapter; import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.socket.websocket.json.auth.AuthResponse; @@ -21,8 +24,6 @@ import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; import ru.gravit.utils.helper.LogHelper; -import java.util.HashMap; - @SuppressWarnings({"unused", "rawtypes"}) public class WebSocketService { public final ChannelGroup channels; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java index f967c952..2358ad31 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java @@ -1,10 +1,18 @@ package ru.gravit.launchserver.socket.websocket.json; -import com.google.gson.*; -import ru.gravit.launchserver.socket.websocket.WebSocketService; - 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 ru.gravit.launchserver.socket.websocket.WebSocketService; + public class JsonResponseAdapter implements JsonSerializer, JsonDeserializer { private final WebSocketService service; private static final String PROP_NAME = "type"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java index 5da19986..dd4b6200 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java @@ -1,11 +1,13 @@ package ru.gravit.launchserver.socket.websocket.json.auth; +import java.util.Collection; + import io.netty.channel.ChannelHandlerContext; +import ru.gravit.launcher.HWID; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; -import ru.gravit.launcher.HWID; import ru.gravit.launchserver.auth.hwid.HWIDException; import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.AuthProviderResult; @@ -15,8 +17,6 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.util.Collection; - public class AuthResponse implements JsonResponseInterface { public String login; public String client; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java index 1a63af31..a3003988 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.socket.websocket.json.update; +import java.util.Arrays; +import java.util.Base64; + import io.netty.channel.ChannelHandlerContext; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; import ru.gravit.utils.Version; -import java.util.Arrays; -import java.util.Base64; - public class LauncherResponse implements JsonResponseInterface { public Version version; public String hash; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java index e6fb354e..2294351c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java @@ -4,9 +4,9 @@ import java.util.Objects; import java.util.UUID; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.utils.helper.VerifyHelper; public final class NullTextureProvider extends TextureProvider { private volatile TextureProvider provider; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java index face508f..4bb0b25a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java @@ -5,12 +5,12 @@ import java.util.UUID; import ru.gravit.launcher.Launcher; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; public final class RequestTextureProvider extends TextureProvider { private static final UUID ZERO_UUID = new UUID(0, 0); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java index 46ce431f..c15c2b21 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java @@ -6,10 +6,10 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.utils.helper.VerifyHelper; public abstract class TextureProvider extends ConfigObject implements AutoCloseable { private static final Map> TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2); diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg index fa9dba4d..954f8d01 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg @@ -55,12 +55,12 @@ binaryName: "Launcher"; launch4J: { enabled: true; productName: "sashok724's Launcher v3 mod by Gravit"; - productVer: "1.0.0.0"; + productVer: "4.1.0.0"; fileDesc: "sashok724's Launcher v3 mod by Gravit"; - fileVer: "1.0.0.0"; + fileVer: "1.1.0.0"; internalName: "Launcher"; copyright: "© sashok724 LLC"; - trademarks: "This product is licensed under MIT License"; + trademarks: "This product is licensed under GNU GPL v3.0 License"; # version and build number txtFileVersion: "%s, build %d"; txtProductVersion: "%s, build %d"; diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 1b5eef85..7252244e 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -1,11 +1,5 @@ package ru.gravit.launcher; -import ru.gravit.launcher.client.ClientLauncher; -import ru.gravit.utils.helper.EnvHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -13,6 +7,12 @@ import java.util.LinkedList; import java.util.List; +import ru.gravit.launcher.client.ClientLauncher; +import ru.gravit.utils.helper.EnvHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; + public class ClientLauncherWrapper { public static void main(String[] arguments) throws IOException, InterruptedException { LogHelper.printVersion("Launcher"); diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index af7d307f..e33c5eb9 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -5,7 +5,8 @@ import java.net.URL; import java.time.Duration; import java.time.Instant; -import java.util.*; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import javax.script.Bindings; @@ -14,7 +15,12 @@ import javax.script.ScriptEngine; import javax.script.ScriptException; -import ru.gravit.launcher.client.*; +import ru.gravit.launcher.client.ClientLauncher; +import ru.gravit.launcher.client.ClientModuleManager; +import ru.gravit.launcher.client.DirBridge; +import ru.gravit.launcher.client.FunctionalBridge; +import ru.gravit.launcher.client.LauncherSettings; +import ru.gravit.launcher.client.ServerPinger; import ru.gravit.launcher.gui.choosebox.CheckComboBox; import ru.gravit.launcher.gui.choosebox.CheckComboBoxSkin; import ru.gravit.launcher.gui.choosebox.CheckModel; @@ -25,17 +31,6 @@ import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedFile; -import ru.gravit.launcher.request.auth.SetProfileRequest; -import ru.gravit.launcher.request.update.LauncherRequest; -import ru.gravit.launcher.request.update.ProfilesRequest; -import ru.gravit.utils.HTTPRequest; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.EnvHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.Texture; @@ -47,6 +42,9 @@ import ru.gravit.launcher.request.auth.AuthRequest; import ru.gravit.launcher.request.auth.CheckServerRequest; import ru.gravit.launcher.request.auth.JoinServerRequest; +import ru.gravit.launcher.request.auth.SetProfileRequest; +import ru.gravit.launcher.request.update.LauncherRequest; +import ru.gravit.launcher.request.update.ProfilesRequest; import ru.gravit.launcher.request.update.UpdateRequest; import ru.gravit.launcher.request.uuid.BatchProfileByUsernameRequest; import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest; @@ -66,6 +64,14 @@ import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launcher.serialize.stream.EnumSerializer; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.HTTPRequest; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.EnvHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public class LauncherEngine { @LauncherAPI diff --git a/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java b/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java index b66d316a..7ece9196 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java +++ b/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java @@ -1,10 +1,10 @@ package ru.gravit.launcher; -import ru.gravit.utils.helper.LogHelper; - import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import ru.gravit.utils.helper.LogHelper; + public class RequestWorker implements Runnable { public RequestWorker() { diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 6a1ff33f..1eaba689 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -5,7 +5,10 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; -import java.net.*; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Path; import java.nio.file.Paths; @@ -13,16 +16,34 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.security.interfaces.RSAPublicKey; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import javax.swing.JOptionPane; import com.google.gson.Gson; import com.google.gson.JsonObject; -import ru.gravit.launcher.*; + +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.LauncherAgent; +import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.LauncherEngine; import ru.gravit.launcher.hasher.DirWatcher; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.profiles.PlayerProfile; +import ru.gravit.launcher.request.update.LegacyLauncherRequest; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launcher.serialize.signed.SignedObjectHolder; +import ru.gravit.launcher.serialize.stream.StreamObject; import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.EnvHelper; @@ -31,13 +52,6 @@ import ru.gravit.utils.helper.JVMHelper.OS; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.launcher.profiles.ClientProfile; -import ru.gravit.launcher.profiles.PlayerProfile; -import ru.gravit.launcher.request.update.LegacyLauncherRequest; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; -import ru.gravit.launcher.serialize.stream.StreamObject; public final class ClientLauncher { private static Gson gson = new Gson(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java index e7b4e35c..c105b10b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java @@ -1,11 +1,11 @@ package ru.gravit.launcher.client; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.IOHelper; - import java.io.IOException; import java.nio.file.Path; +import ru.gravit.launcher.LauncherAPI; +import ru.gravit.utils.helper.IOHelper; + public class DirBridge { @LauncherAPI public static Path dir; diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index 365a4414..16c8bd2f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -1,5 +1,9 @@ package ru.gravit.launcher.client; +import java.io.IOException; +import java.nio.file.Path; +import java.security.SignatureException; + import javafx.concurrent.Task; import ru.gravit.launcher.HWID; import ru.gravit.launcher.LauncherAPI; @@ -13,10 +17,6 @@ import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.nio.file.Path; -import java.security.SignatureException; - public class FunctionalBridge { @LauncherAPI public static LauncherSettings settings; @@ -55,8 +55,9 @@ public static void makeJsonRequest(RequestInterface request, Runnable callback) { } + @LauncherAPI - public static void startTask(Task task) + public static void startTask(@SuppressWarnings("rawtypes") Task task) { try { worker.queue.put(task); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java index 563a5c29..5e53b20a 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java @@ -1,17 +1,5 @@ package ru.gravit.launcher.client; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.client.DirBridge; -import ru.gravit.launcher.hasher.HashedDir; -import ru.gravit.launcher.profiles.ClientProfile; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; -import ru.gravit.utils.helper.*; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; import java.io.IOException; import java.nio.file.Path; import java.security.SignatureException; @@ -21,6 +9,22 @@ import java.util.List; import java.util.Map; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launcher.serialize.signed.SignedObjectHolder; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; + public class LauncherSettings { public static int settingsMagic = 0xc0de7; @LauncherAPI diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ServerPinger.java b/Launcher/src/main/java/ru/gravit/launcher/client/ServerPinger.java index a0b18c1e..3e9cad54 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ServerPinger.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ServerPinger.java @@ -12,13 +12,14 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.profiles.ClientProfile; public final class ServerPinger { private JsonParser parser = new JsonParser(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java index febe246a..b68d4f08 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java @@ -13,7 +13,6 @@ import javafx.collections.ObservableList; import javafx.scene.control.Skin; import javafx.util.StringConverter; - import ru.gravit.launcher.LauncherAPI; public class CheckComboBox extends ControlsFXControl { diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java index 7e3d63ff..f8ab6548 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java @@ -4,14 +4,14 @@ import java.util.Collections; import java.util.List; -import javafx.beans.property.*; +import com.sun.javafx.css.converters.SizeConverter; + +import javafx.beans.property.DoubleProperty; import javafx.css.CssMetaData; import javafx.css.Styleable; import javafx.css.StyleableDoubleProperty; import javafx.css.StyleableProperty; import javafx.scene.control.Control; - -import com.sun.javafx.css.converters.SizeConverter; import javafx.scene.control.ProgressIndicator; abstract class ProgressCircleIndicator extends ProgressIndicator { diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java index 887564ba..c102686b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java @@ -4,6 +4,8 @@ import java.util.Collections; import java.util.List; +import com.sun.javafx.css.converters.SizeConverter; + import javafx.beans.property.DoubleProperty; import javafx.css.CssMetaData; import javafx.css.Styleable; @@ -11,8 +13,6 @@ import javafx.css.StyleableProperty; import javafx.scene.control.Control; import javafx.scene.control.Skin; - -import com.sun.javafx.css.converters.SizeConverter; import ru.gravit.launcher.LauncherAPI; import ru.gravit.utils.helper.LogHelper; 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 99864ab8..7a6c6295 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -1,7 +1,11 @@ package ru.gravit.launcher.hwid; import oshi.SystemInfo; -import oshi.hardware.*; +import oshi.hardware.CentralProcessor; +import oshi.hardware.ComputerSystem; +import oshi.hardware.HWDiskStore; +import oshi.hardware.HardwareAbstractionLayer; +import oshi.hardware.UsbDevice; import ru.gravit.launcher.HWID; import ru.gravit.launcher.LauncherHWIDInterface; import ru.gravit.launcher.OshiHWID; diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java index 42be68d6..7a0e6cb7 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java @@ -3,7 +3,6 @@ import java.util.UUID; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.auth.CheckServerRequest; import ru.gravit.launcher.request.auth.JoinServerRequest; @@ -11,6 +10,7 @@ import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest; import ru.gravit.launcher.request.uuid.ProfileByUsernameRequest; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.LogHelper; // Used to bypass Launcher's class name obfuscation and access API @SuppressWarnings("unused") diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java index ec5a6ce9..aee84dcb 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java @@ -4,8 +4,8 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.profiles.PlayerProfile; +import ru.gravit.utils.helper.SecurityHelper; @SuppressWarnings("unused") @LauncherAPI diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java index 881ed1df..72a7b255 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java @@ -1,11 +1,11 @@ package com.mojang.authlib.yggdrasil; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.request.auth.CheckServerRequest; +import ru.gravit.launcher.request.auth.JoinServerRequest; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import ru.gravit.launcher.request.auth.CheckServerRequest; -import ru.gravit.launcher.request.auth.JoinServerRequest; // Used by 1.6.4 and below versions @LauncherAPI diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java index 2a507b9c..1ec1336c 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -8,11 +8,11 @@ import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.ProfileLookupCallback; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.uuid.BatchProfileByUsernameRequest; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class YggdrasilGameProfileRepository implements GameProfileRepository { private static final long BUSY_WAIT_MS = VerifyHelper.verifyLong( diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java index 4367d124..98808d4b 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.UUID; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.google.common.collect.Iterables; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -16,16 +15,18 @@ import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.exceptions.AuthenticationUnavailableException; import com.mojang.authlib.minecraft.BaseMinecraftSessionService; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; + import ru.gravit.launcher.Launcher; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.auth.CheckServerRequest; import ru.gravit.launcher.request.auth.JoinServerRequest; import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; public final class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService { public static final JsonParser JSON_PARSER = new JsonParser(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/CustomRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/CustomRequest.java index 7a9a11be..cb886b1a 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/CustomRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/CustomRequest.java @@ -2,9 +2,9 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.VerifyHelper; public abstract class CustomRequest extends Request { @LauncherAPI diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java index ba2af3e4..93e50fdf 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java @@ -7,10 +7,10 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.SecurityHelper; public abstract class Request { private static final long session = SecurityHelper.secureRandom.nextLong(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index b62e837e..47154e75 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -2,9 +2,10 @@ import java.io.IOException; -import ru.gravit.launcher.*; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; @@ -12,6 +13,8 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class AuthRequest extends Request { public static final class Result { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java index 7a83ab9a..259a8b7e 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java @@ -1,5 +1,7 @@ package ru.gravit.launcher.request.auth; +import java.io.IOException; + import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.profiles.PlayerProfile; @@ -11,8 +13,6 @@ import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; - public final class AuthServerRequest extends Request { public static final class Result { @LauncherAPI diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ChangeServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ChangeServerRequest.java index 0ea7877a..ddb4dc60 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ChangeServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ChangeServerRequest.java @@ -1,13 +1,13 @@ package ru.gravit.launcher.request.auth; +import java.net.InetSocketAddress; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; -import java.net.InetSocketAddress; - public class ChangeServerRequest extends Request { @Override public Integer getType() { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java index f018e901..181593d4 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java @@ -5,14 +5,14 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class CheckServerRequest extends Request { private final String username; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java index d9492b56..dd7fe6a8 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java @@ -4,13 +4,13 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class JoinServerRequest extends Request { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index d694773e..b4d428f6 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -1,5 +1,11 @@ package ru.gravit.launcher.request.update; +import java.io.IOException; +import java.nio.file.Path; +import java.security.SignatureException; +import java.util.ArrayList; +import java.util.List; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; @@ -12,12 +18,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; -import java.nio.file.Path; -import java.security.SignatureException; -import java.util.ArrayList; -import java.util.List; - public final class LauncherRequest extends Request { public static final class Result { private final byte[] binary; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java index 8a3109d2..3dc59f87 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java @@ -11,10 +11,6 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; @@ -22,6 +18,10 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; public final class LegacyLauncherRequest extends Request { public static final class Result { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java index a839b68f..bff78b4d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java @@ -7,11 +7,11 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.IOHelper; public final class UpdateListRequest extends Request> { @LauncherAPI diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index 7bf4fa10..c211c1ca 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -23,9 +23,6 @@ import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedFile; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.UpdateAction; @@ -34,6 +31,9 @@ import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; public final class UpdateRequest extends Request> { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index 250bd161..66de1570 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -4,14 +4,14 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class BatchProfileByUsernameRequest extends Request { private final String[] usernames; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java index dddc7aa0..69aa5f1d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java @@ -5,13 +5,13 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.VerifyHelper; public final class ProfileByUsernameRequest extends Request { private final String username; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 5ce34a4e..883be877 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -1,14 +1,15 @@ package ru.gravit.launcher.request.websockets; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import ru.gravit.launcher.hasher.HashedEntry; -import ru.gravit.launcher.hasher.HashedEntryAdapter; - import java.io.IOException; import java.io.Reader; import java.util.HashMap; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import ru.gravit.launcher.hasher.HashedEntry; +import ru.gravit.launcher.hasher.HashedEntryAdapter; + public class ClientWebSocketService { public final GsonBuilder gsonBuilder; public final Gson gson; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java index 72411843..7be04dc5 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java @@ -1,9 +1,16 @@ package ru.gravit.launcher.request.websockets; -import com.google.gson.*; - 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; + public class JsonRequestAdapter implements JsonSerializer, JsonDeserializer { private final ClientWebSocketService service; private static final String PROP_NAME = "type"; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java index 4754c3d3..cb878c36 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java @@ -10,13 +10,13 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Pattern; +import ru.gravit.launcher.modules.ModulesManagerInterface; import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.serialize.HInput; import ru.gravit.utils.Version; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.launcher.modules.ModulesManagerInterface; -import ru.gravit.launcher.serialize.HInput; public final class Launcher { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java index 3e0a5e13..ba4b128b 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -7,8 +7,8 @@ import java.util.jar.JarFile; import javassist.bytecode.ClassFile; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.transformers.SystemClassLoaderTransformer; +import ru.gravit.utils.helper.LogHelper; @LauncherAPI public class LauncherAgent { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index 7e781b44..6d220f64 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -10,12 +10,12 @@ import java.util.Objects; import java.util.Set; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class LauncherConfig extends StreamObject { @LauncherAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/ControlEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/ControlEvent.java index 86ba0920..29834e22 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/ControlEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/ControlEvent.java @@ -1,9 +1,9 @@ package ru.gravit.launcher.events; -import ru.gravit.utils.event.EventInterface; - import java.util.UUID; +import ru.gravit.utils.event.EventInterface; + //Набор стандартных событий public class ControlEvent implements EventInterface { private static final UUID uuid = UUID.fromString("f1051a64-0cd0-4ed8-8430-d856a196e91f"); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/PingEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/PingEvent.java index ac4112e4..f10806eb 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/PingEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/PingEvent.java @@ -1,9 +1,9 @@ package ru.gravit.launcher.events; -import ru.gravit.utils.event.EventInterface; - import java.util.UUID; +import ru.gravit.utils.event.EventInterface; + //Пустое событие //Все обработчики обязаны его игнорировать public final class PingEvent implements EventInterface { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/SignalEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/SignalEvent.java index 2e43aca3..afe1c9a5 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/SignalEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/SignalEvent.java @@ -1,9 +1,9 @@ package ru.gravit.launcher.events; -import ru.gravit.utils.event.EventInterface; - import java.util.UUID; +import ru.gravit.utils.event.EventInterface; + //Используется, что бы послать короткое сообщение, которое вмещается в int public class SignalEvent implements EventInterface { private static final UUID uuid = UUID.fromString("edc3afa1-2726-4da3-95c6-7e6994b981e1"); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java index 5e4793b4..71e5f4bc 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java @@ -5,16 +5,22 @@ import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -import java.util.*; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; +import java.util.StringTokenizer; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.EnumSerializer; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class HashedDir extends HashedEntry { public static final class Diff { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedEntryAdapter.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedEntryAdapter.java index d31fce3a..6577df95 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedEntryAdapter.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedEntryAdapter.java @@ -1,9 +1,16 @@ package ru.gravit.launcher.hasher; -import com.google.gson.*; - 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; + public class HashedEntryAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedFile.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedFile.java index 8a931ce2..b87fd6b7 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedFile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedFile.java @@ -5,12 +5,12 @@ import java.util.Arrays; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import ru.gravit.utils.helper.VerifyHelper; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; public final class HashedFile extends HashedEntry { public static final DigestAlgorithm DIGEST_ALGO = DigestAlgorithm.MD5; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java b/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java index 807e5e6b..a66faa36 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java @@ -1,18 +1,22 @@ package ru.gravit.launcher.modules; -import ru.gravit.utils.PublicURLClassLoader; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.*; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.jar.JarFile; import java.util.jar.Manifest; +import ru.gravit.utils.PublicURLClassLoader; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public class SimpleModuleManager implements ModulesManagerInterface, AutoCloseable { protected final class ModulesVisitor extends SimpleFileVisitor { private ModulesVisitor() { 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 09c805bb..927ed113 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -2,17 +2,27 @@ import java.io.IOException; import java.net.InetSocketAddress; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.config.ConfigObject; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; +import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; +import ru.gravit.launcher.serialize.config.entry.IntegerConfigEntry; +import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launcher.serialize.stream.StreamObject; -import ru.gravit.launcher.serialize.config.entry.*; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.VerifyHelper; @SuppressWarnings("ComparableImplementedButEqualsNotOverridden") public final class ClientProfile extends ConfigObject implements Comparable { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/PlayerProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/PlayerProfile.java index e5eb11f8..24cae176 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/PlayerProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/PlayerProfile.java @@ -5,11 +5,11 @@ import java.util.UUID; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class PlayerProfile extends StreamObject { @LauncherAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/Texture.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/Texture.java index afd40c58..30763d87 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/Texture.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/Texture.java @@ -7,11 +7,11 @@ import java.util.Objects; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.SecurityHelper; public final class Texture extends StreamObject { private static final SecurityHelper.DigestAlgorithm DIGEST_ALGO = SecurityHelper.DigestAlgorithm.SHA256; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/request/UpdateAction.java b/libLauncher/src/main/java/ru/gravit/launcher/request/UpdateAction.java index 148a0520..6b154f71 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/request/UpdateAction.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/request/UpdateAction.java @@ -3,11 +3,11 @@ import java.io.IOException; import ru.gravit.launcher.hasher.HashedEntry; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.EnumSerializer; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.helper.IOHelper; public final class UpdateAction extends StreamObject { public enum Type implements EnumSerializer.Itf { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/TextConfigReader.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/TextConfigReader.java index 85f7af8d..a7788095 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/TextConfigReader.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/TextConfigReader.java @@ -9,13 +9,13 @@ import java.util.Map; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; import ru.gravit.launcher.serialize.config.entry.ConfigEntry; import ru.gravit.launcher.serialize.config.entry.IntegerConfigEntry; import ru.gravit.launcher.serialize.config.entry.ListConfigEntry; import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; +import ru.gravit.utils.helper.VerifyHelper; public final class TextConfigReader { @LauncherAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/entry/BlockConfigEntry.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/entry/BlockConfigEntry.java index a147c45b..f0e11070 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/entry/BlockConfigEntry.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/config/entry/BlockConfigEntry.java @@ -9,9 +9,9 @@ import java.util.Set; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.VerifyHelper; public final class BlockConfigEntry extends ConfigEntry>> { private static Map> readMap(HInput input, boolean ro) throws IOException { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/DigestBytesHolder.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/DigestBytesHolder.java index e848db3b..40073ddf 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/DigestBytesHolder.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/DigestBytesHolder.java @@ -1,15 +1,15 @@ package ru.gravit.launcher.serialize.signed; +import java.io.IOException; +import java.security.SignatureException; +import java.util.Arrays; + import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; -import java.security.SignatureException; -import java.util.Arrays; - public class DigestBytesHolder extends StreamObject { protected final byte[] bytes; private final byte[] digest; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/SignedBytesHolder.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/SignedBytesHolder.java index 852463e8..6e9d9fb6 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/SignedBytesHolder.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/signed/SignedBytesHolder.java @@ -6,10 +6,10 @@ import java.security.interfaces.RSAPublicKey; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; +import ru.gravit.utils.helper.SecurityHelper; public class SignedBytesHolder extends StreamObject { protected final byte[] bytes; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/EnumSerializer.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/EnumSerializer.java index 4e7db136..0ee40927 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/EnumSerializer.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/EnumSerializer.java @@ -5,10 +5,10 @@ import java.util.Map; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.EnumSerializer.Itf; +import ru.gravit.utils.helper.VerifyHelper; public final class EnumSerializer & Itf> { @FunctionalInterface diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/StreamObject.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/StreamObject.java index 07cd6dd9..30df9e41 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/StreamObject.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/stream/StreamObject.java @@ -4,9 +4,9 @@ import java.io.IOException; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.IOHelper; public abstract class StreamObject { /* public StreamObject(HInput input) */ diff --git a/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java b/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java index bdc41b46..6b935b83 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/ssl/LauncherSSLContext.java @@ -1,7 +1,17 @@ package ru.gravit.launcher.ssl; -import javax.net.ssl.*; -import java.security.*; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.UnrecoverableKeyException; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; public class LauncherSSLContext { public SSLServerSocketFactory ssf; diff --git a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java index 812a0ad8..ec5e75d3 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java @@ -11,6 +11,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; + import ru.gravit.utils.helper.IOHelper; public class HTTPRequest { diff --git a/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java b/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java index a73bca13..1f7471a8 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java @@ -1,8 +1,5 @@ package ru.gravit.utils; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.BufferedInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -13,6 +10,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public class HttpDownloader extends Observable { public static final int BUFER_SIZE = 8192; public static final int INTERVAL = 300; diff --git a/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java b/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java index d592fd65..368cacdb 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java +++ b/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java @@ -1,8 +1,5 @@ package ru.gravit.utils.event; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.LogHelper; - import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; @@ -10,6 +7,9 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicBoolean; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.LogHelper; + public class EventManager { public static final int QUEUE_MAX_SIZE = 2048; public static final int INITIAL_HANDLERS_SIZE = 16; diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/UnpackHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/UnpackHelper.java index 62f0c45c..ca00a3a7 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/UnpackHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/UnpackHelper.java @@ -3,18 +3,22 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Arrays; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; public class UnpackHelper { public static boolean unpack(URL resource, Path target) throws IOException { - if (IOHelper.exists(target)) { + if (IOHelper.isFile(target)) { if (matches(target, resource)) return false; } - if (!IOHelper.exists(target)) - target.toFile().createNewFile(); + Files.deleteIfExists(target); + Files.createFile(target); try (InputStream in = IOHelper.newInput(resource)) { - IOHelper.transfer(in, target, false); + IOHelper.transfer(in, target); } return true; } @@ -27,4 +31,40 @@ private static boolean matches(Path target, URL in) { return false; } } + + public static boolean unpackZipNoCheck(URL resource, Path target) throws IOException { + if (Files.isDirectory(target)) + return false; + Files.deleteIfExists(target); + Files.createDirectory(target); + try (ZipInputStream input = IOHelper.newZipInput(resource)) { + for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { + if (entry.isDirectory()) + continue; // Skip dirs + // Unpack file + IOHelper.transfer(input, target.resolve(IOHelper.toPath(entry.getName()))); + } + } + return true; + } + + public static boolean unpackZipNoCheck(String resource, Path target) throws IOException { + try { + if (Files.isDirectory(target)) + return false; + Files.deleteIfExists(target); + Files.createDirectory(target); + try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL(resource))) { + for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { + if (entry.isDirectory()) + continue; // Skip dirs + // Unpack file + IOHelper.transfer(input, target.resolve(IOHelper.toPath(entry.getName()))); + } + } + return true; + } catch (NoSuchFileException e) { + return true; + } + } } diff --git a/modules b/modules index c671ec5f..79e24c86 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit c671ec5f9a3da8fb34d15dc9e88cca57c6e5be78 +Subproject commit 79e24c862b2324b7751f1520f9732eed31416c6d From e7846adaf2aafea9b75e6995683c0aa5352c3a5d Mon Sep 17 00:00:00 2001 From: Anatoliy Date: Wed, 5 Dec 2018 21:56:15 +0200 Subject: [PATCH 2/2] Update JVMHelper.java Optimized "for" loop --- .../src/main/java/ru/gravit/utils/helper/JVMHelper.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java index 6ec5ab62..1d6c5397 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java @@ -100,16 +100,15 @@ public static String[] getClassPath() { public static URL[] getClassPathURL() { String[] cp = System.getProperty("java.class.path").split(File.pathSeparator); URL[] list = new URL[cp.length]; - int it = 0; - for (String s : cp) { + + for(int i = 0; i < cp.length; i++) { URL url = null; try { - url = new URL(s); + url = new URL(cp[i]); } catch (MalformedURLException e) { e.printStackTrace(); } - list[it] = url; - it++; + list[i] = url; } return list; }