From e95557c6fd1f87ee85ace3c17d34b7a0d061700a Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 13 Mar 2019 16:13:21 +0700 Subject: [PATCH 01/28] =?UTF-8?q?[FEATURE]=20=D0=9A=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 3 ++ .../launchserver/components/Component.java | 35 ++++++++++++++++++ .../config/AuthHandlerAdapter.java | 6 +++ .../config/AuthProviderAdapter.java | 6 +++ .../launchserver/config/ComponentAdapter.java | 37 +++++++++++++++++++ .../config/HWIDHandlerAdapter.java | 6 +++ .../config/PermissionsHandlerAdapter.java | 6 +++ .../config/TextureProviderAdapter.java | 6 +++ 8 files changed, 105 insertions(+) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index c12dbc13..2e65c755 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -18,6 +18,7 @@ import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.RejectAuthProvider; import ru.gravit.launchserver.binary.*; +import ru.gravit.launchserver.components.Component; import ru.gravit.utils.command.CommandHandler; import ru.gravit.utils.command.JLineCommandHandler; import ru.gravit.utils.command.StdCommandHandler; @@ -532,6 +533,7 @@ public static void initGson() { Launcher.gsonBuilder.registerTypeAdapter(AuthHandler.class, new AuthHandlerAdapter()); Launcher.gsonBuilder.registerTypeAdapter(PermissionsHandler.class, new PermissionsHandlerAdapter()); Launcher.gsonBuilder.registerTypeAdapter(HWIDHandler.class, new HWIDHandlerAdapter()); + Launcher.gsonBuilder.registerTypeAdapter(Component.class, new ComponentAdapter()); Launcher.gson = Launcher.gsonBuilder.create(); //Human readable @@ -542,6 +544,7 @@ public static void initGson() { LaunchServer.gsonBuilder.registerTypeAdapter(AuthHandler.class, new AuthHandlerAdapter()); LaunchServer.gsonBuilder.registerTypeAdapter(PermissionsHandler.class, new PermissionsHandlerAdapter()); LaunchServer.gsonBuilder.registerTypeAdapter(HWIDHandler.class, new HWIDHandlerAdapter()); + LaunchServer.gsonBuilder.registerTypeAdapter(Component.class, new ComponentAdapter()); LaunchServer.gson = LaunchServer.gsonBuilder.create(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java new file mode 100644 index 00000000..a29aa529 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java @@ -0,0 +1,35 @@ +package ru.gravit.launchserver.components; + +import ru.gravit.utils.helper.VerifyHelper; + +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +public class Component { + private static final Map> COMPONENTS = new ConcurrentHashMap<>(4); + private static boolean registredComp = false; + + public static void registerHandler(String name, Class adapter) { + VerifyHelper.verifyIDName(name); + VerifyHelper.putIfAbsent(COMPONENTS, name, Objects.requireNonNull(adapter, "adapter"), + String.format("Auth handler has been already registered: '%s'", name)); + } + + public static Class getHandlerClass(String name) { + return COMPONENTS.get(name); + } + + public static String getHandlerName(Class clazz) { + for (Map.Entry> e : COMPONENTS.entrySet()) { + if (e.getValue().equals(clazz)) return e.getKey(); + } + return null; + } + + public static void registerComponents() { + if (!registredComp) { + registredComp = true; + } + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java index 608b36ae..f796e921 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java @@ -2,6 +2,7 @@ import com.google.gson.*; import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; @@ -12,6 +13,11 @@ public class AuthHandlerAdapter implements JsonSerializer, JsonDese public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); Class cls = AuthHandler.getHandlerClass(typename); + if(cls == null) + { + LogHelper.error("AuthHandler %s not found", typename); + return null; + } return (AuthHandler) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java index a45c6e92..f4e74c95 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java @@ -2,6 +2,7 @@ import com.google.gson.*; import ru.gravit.launchserver.auth.provider.AuthProvider; +import ru.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; @@ -12,6 +13,11 @@ public class AuthProviderAdapter implements JsonSerializer, JsonDe public AuthProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); Class cls = AuthProvider.getProviderClass(typename); + if(cls == null) + { + LogHelper.error("AuthProvider %s not found", typename); + return null; + } return (AuthProvider) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java new file mode 100644 index 00000000..f33d44ad --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java @@ -0,0 +1,37 @@ +package ru.gravit.launchserver.config; + +import com.google.gson.*; +import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.launchserver.components.Component; +import ru.gravit.utils.helper.LogHelper; + +import java.lang.reflect.Type; + +public class ComponentAdapter implements JsonSerializer, JsonDeserializer { + private static final String PROP_NAME = "component"; + + @Override + public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); + Class cls = Component.getHandlerClass(typename); + if(cls == null) + { + LogHelper.error("Component %s not found", typename); + return null; + } + + + return (Component) context.deserialize(json, cls); + } + + @Override + public JsonElement serialize(Component src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject jo = context.serialize(src).getAsJsonObject(); + + @SuppressWarnings("unchecked") + String classPath = Component.getHandlerName((Class) src.getClass()); + jo.add(PROP_NAME, new JsonPrimitive(classPath)); + + return jo; + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java index bcc887b7..3a2d994c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java @@ -2,6 +2,7 @@ import com.google.gson.*; import ru.gravit.launchserver.auth.hwid.HWIDHandler; +import ru.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; @@ -12,6 +13,11 @@ public class HWIDHandlerAdapter implements JsonSerializer, JsonDese public HWIDHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); Class cls = HWIDHandler.getHandlerClass(typename); + if(cls == null) + { + LogHelper.error("HWIDHandler %s not found", typename); + return null; + } return (HWIDHandler) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java index 83dd21e9..bc2e21ae 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java @@ -2,6 +2,7 @@ import com.google.gson.*; import ru.gravit.launchserver.auth.permissions.PermissionsHandler; +import ru.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; @@ -12,6 +13,11 @@ public class PermissionsHandlerAdapter implements JsonSerializer cls = PermissionsHandler.getHandlerClass(typename); + if(cls == null) + { + LogHelper.error("PermissionsHandler %s not found", typename); + return null; + } return (PermissionsHandler) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java index e79041c8..75aba651 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java @@ -2,6 +2,7 @@ import com.google.gson.*; import ru.gravit.launchserver.texture.TextureProvider; +import ru.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; @@ -12,6 +13,11 @@ public class TextureProviderAdapter implements JsonSerializer, public TextureProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); Class cls = TextureProvider.getProviderClass(typename); + if(cls == null) + { + LogHelper.error("TextureProvider %s not found", typename); + return null; + } return (TextureProvider) context.deserialize(json, cls); From 3eabd1e38e2172f0c5ab1717297104042d21dc6c Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 13 Mar 2019 16:24:28 +0700 Subject: [PATCH 02/28] =?UTF-8?q?[FEATURE]=20=D0=9A=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D1=8B=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B2=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 30 +++++++++++++++++++ .../launchserver/components/Component.java | 12 +++++--- .../launchserver/config/ComponentAdapter.java | 5 ++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 2e65c755..9ae79bd7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -33,6 +33,7 @@ import ru.gravit.launchserver.texture.RequestTextureProvider; import ru.gravit.launchserver.texture.TextureProvider; import ru.gravit.utils.helper.*; +import sun.nio.cs.ext.COMPOUND_TEXT; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -97,6 +98,8 @@ public static final class Config { public HWIDHandler hwidHandler; + public HashMap components; + // Misc options public int threadCount; @@ -448,6 +451,15 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE provider.init(); } config.authHandler.init(); + if(config.components != null) + { + LogHelper.debug("PreInit components"); + config.components.forEach((k,v) -> { + LogHelper.subDebug("PreInit component %s", k); + v.preInit(this); + }); + LogHelper.debug("PreInit components successful"); + } // build hooks, anti-brutforce and other buildHookManager = new BuildHookManager(); @@ -492,6 +504,15 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE // init modules modulesManager.initModules(); + if(config.components != null) + { + LogHelper.debug("Init components"); + config.components.forEach((k,v) -> { + LogHelper.subDebug("Init component %s", k); + v.init(this); + }); + LogHelper.debug("Init components successful"); + } // Set launcher EXE binary launcherBinary = new JARLauncherBinary(this); @@ -517,6 +538,15 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE // post init modules modulesManager.postInitModules(); + if(config.components != null) + { + LogHelper.debug("PostInit components"); + config.components.forEach((k,v) -> { + LogHelper.subDebug("PostInit component %s", k); + v.postInit(this); + }); + LogHelper.debug("PostInit components successful"); + } // start updater this.updater = new Updater(this); if(config.netty != null) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java index a29aa529..c74704cb 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java @@ -1,26 +1,27 @@ package ru.gravit.launchserver.components; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.VerifyHelper; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -public class Component { +public abstract class Component { private static final Map> COMPONENTS = new ConcurrentHashMap<>(4); private static boolean registredComp = false; - public static void registerHandler(String name, Class adapter) { + public static void registerComponent(String name, Class adapter) { VerifyHelper.verifyIDName(name); VerifyHelper.putIfAbsent(COMPONENTS, name, Objects.requireNonNull(adapter, "adapter"), String.format("Auth handler has been already registered: '%s'", name)); } - public static Class getHandlerClass(String name) { + public static Class getComponentClass(String name) { return COMPONENTS.get(name); } - public static String getHandlerName(Class clazz) { + public static String getComponentName(Class clazz) { for (Map.Entry> e : COMPONENTS.entrySet()) { if (e.getValue().equals(clazz)) return e.getKey(); } @@ -32,4 +33,7 @@ public static void registerComponents() { registredComp = true; } } + public abstract void preInit(LaunchServer launchServer); + public abstract void init(LaunchServer launchServer); + public abstract void postInit(LaunchServer launchServer); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java index f33d44ad..65c8f7da 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ComponentAdapter.java @@ -1,7 +1,6 @@ package ru.gravit.launchserver.config; import com.google.gson.*; -import ru.gravit.launchserver.auth.handler.AuthHandler; import ru.gravit.launchserver.components.Component; import ru.gravit.utils.helper.LogHelper; @@ -13,7 +12,7 @@ public class ComponentAdapter implements JsonSerializer, JsonDeserial @Override public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = Component.getHandlerClass(typename); + Class cls = Component.getComponentClass(typename); if(cls == null) { LogHelper.error("Component %s not found", typename); @@ -29,7 +28,7 @@ public JsonElement serialize(Component src, Type typeOfSrc, JsonSerializationCon JsonObject jo = context.serialize(src).getAsJsonObject(); @SuppressWarnings("unchecked") - String classPath = Component.getHandlerName((Class) src.getClass()); + String classPath = Component.getComponentName((Class) src.getClass()); jo.add(PROP_NAME, new JsonPrimitive(classPath)); return jo; From 694c994807f752d0f5f4d508cfd3123e1118bdfe Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 13 Mar 2019 16:49:28 +0700 Subject: [PATCH 03/28] =?UTF-8?q?[FEATURE]=20AuthLimiter=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 25 +++------- .../AuthLimiterComponent.java} | 50 +++++++++++++------ .../launchserver/components/Component.java | 1 + .../manangers/hook/AuthHookManager.java | 18 ++++--- .../response/auth/AuthResponse.java | 10 ++-- .../response/auth/AuthServerResponse.java | 4 -- .../websocket/json/auth/AuthResponse.java | 6 +-- 7 files changed, 59 insertions(+), 55 deletions(-) rename LaunchServer/src/main/java/ru/gravit/launchserver/{auth/AuthLimiter.java => components/AuthLimiterComponent.java} (66%) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 9ae79bd7..95bb6f39 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -8,7 +8,7 @@ import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; -import ru.gravit.launchserver.auth.AuthLimiter; +import ru.gravit.launchserver.components.AuthLimiterComponent; import ru.gravit.launchserver.auth.handler.AuthHandler; import ru.gravit.launchserver.auth.handler.MemoryAuthHandler; import ru.gravit.launchserver.auth.hwid.AcceptHWIDHandler; @@ -33,7 +33,6 @@ import ru.gravit.launchserver.texture.RequestTextureProvider; import ru.gravit.launchserver.texture.TextureProvider; import ru.gravit.utils.helper.*; -import sun.nio.cs.ext.COMPOUND_TEXT; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -48,8 +47,6 @@ import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; -import java.time.Duration; -import java.time.Instant; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; @@ -111,14 +108,6 @@ public static final class Config { public boolean compress; - public int authRateLimit; - - public int authRateLimitMilis; - - public String[] authLimitExclusions; - - public String authRejectString; - public String whitelistRejectString; public boolean genMappings; @@ -329,8 +318,6 @@ public static void main(String... args) throws Throwable { public final LauncherBinary launcherEXEBinary; // HWID ban + anti-brutforce - public final AuthLimiter limiter; - public final SessionManager sessionManager; public final SocketHookManager socketHookManager; @@ -463,7 +450,6 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE // build hooks, anti-brutforce and other buildHookManager = new BuildHookManager(); - limiter = new AuthLimiter(this); proguardConf = new ProguardConf(this); sessionManager = new SessionManager(); mirrorManager = new MirrorManager(); @@ -472,7 +458,6 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE socketHookManager = new SocketHookManager(); authHookManager = new AuthHookManager(); GarbageManager.registerNeedGC(sessionManager); - GarbageManager.registerNeedGC(limiter); reloadManager.registerReloadable("launchServer", this); if (config.permissionsHandler instanceof Reloadable) reloadManager.registerReloadable("permissionsHandler", (Reloadable) config.permissionsHandler); @@ -632,7 +617,6 @@ private void generateConfigIfNotExists() throws IOException { newConfig.permissionsHandler = new JsonFilePermissionsHandler(); newConfig.port = 7240; newConfig.bindAddress = "0.0.0.0"; - newConfig.authRejectString = "Превышен лимит авторизаций"; newConfig.binaryName = "Launcher"; newConfig.whitelistRejectString = "Вас нет в белом списке"; @@ -649,6 +633,13 @@ private void generateConfigIfNotExists() throws IOException { newConfig.deleteTempFiles = true; newConfig.isWarningMissArchJava = true; + newConfig.components = new HashMap<>(); + AuthLimiterComponent authLimiterComponent = new AuthLimiterComponent(); + authLimiterComponent.rateLimit = 3; + authLimiterComponent.rateLimitMilis = 8000; + authLimiterComponent.message = "Превышен лимит авторизаций"; + newConfig.components.put("authLimiter", authLimiterComponent); + // Set server address System.out.println("LaunchServer address: "); newConfig.setAddress(commandHandler.readLine()); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java similarity index 66% rename from LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java rename to LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java index 40122c15..7c5a9bb9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java @@ -1,14 +1,42 @@ -package ru.gravit.launchserver.auth; +package ru.gravit.launchserver.components; import ru.gravit.launcher.NeedGarbageCollection; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.launchserver.auth.provider.AuthProvider; +import ru.gravit.launchserver.components.Component; +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.launchserver.socket.Client; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; -public class AuthLimiter implements NeedGarbageCollection { +public class AuthLimiterComponent extends Component implements NeedGarbageCollection { + private LaunchServer server; + @Override + public void preInit(LaunchServer launchServer) { + + } + + @Override + public void init(LaunchServer launchServer) { + server = launchServer; + launchServer.authHookManager.registerPreHook(this::preAuthHook); + } + + @Override + public void postInit(LaunchServer launchServer) { + + } + public void preAuthHook(AuthResponse.AuthContext context, Client client) throws AuthException { + if(isLimit(context.ip)) + { + AuthProvider.authError(message); + } + } + static class AuthEntry { public int value; @@ -50,20 +78,12 @@ public String toString() { public static final long TIMEOUT = 10 * 60 * 1000; //10 минут - public final int rateLimit; - public final int rateLimitMilis; + public int rateLimit; + public int rateLimitMilis; + public String message; - private final HashMap map; - private final List excludeIps; - - public AuthLimiter(LaunchServer srv) { - map = new HashMap<>(); - excludeIps = new ArrayList<>(); - if (srv.config.authLimitExclusions != null) - excludeIps.addAll(Arrays.asList(srv.config.authLimitExclusions)); - rateLimit = srv.config.authRateLimit; - rateLimitMilis = srv.config.authRateLimitMilis; - } + public transient HashMap map; + public List excludeIps; @Override public void garbageCollection() { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java index c74704cb..4cd718ac 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/components/Component.java @@ -30,6 +30,7 @@ public static String getComponentName(Class clazz) { public static void registerComponents() { if (!registredComp) { + registerComponent("authLimiter", AuthLimiterComponent.class); registredComp = true; } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java index f60b9f78..2f3a4ed2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java @@ -1,5 +1,7 @@ package ru.gravit.launchserver.manangers.hook; +import ru.gravit.launcher.request.RequestException; +import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.response.auth.AuthResponse; import ru.gravit.launchserver.socket.Client; @@ -14,22 +16,22 @@ public class AuthHookManager { @FunctionalInterface public interface AuthPreHook { - void preAuthHook(AuthResponse.AuthContext context, Client client); + void preAuthHook(AuthResponse.AuthContext context, Client client) throws AuthException; } @FunctionalInterface public interface AuthPostHook { - void postAuthHook(AuthResponse.AuthContext context, Client client); + void postAuthHook(AuthResponse.AuthContext context, Client client) throws AuthException; } @FunctionalInterface public interface CheckServerHook { - void checkServerHook(String username, String serverID); + void checkServerHook(String username, String serverID) throws AuthException; } @FunctionalInterface public interface JoinServerHook { - void joinServerHook(String username, String accessToken, String serverID); + void joinServerHook(String username, String accessToken, String serverID) throws AuthException; } public void registerPostHook(AuthPostHook hook) { @@ -48,25 +50,25 @@ public void registerPreHook(AuthPreHook hook) { PRE_HOOKS.add(hook); } - public void preHook(AuthResponse.AuthContext context, Client client) { + public void preHook(AuthResponse.AuthContext context, Client client) throws AuthException { for (AuthPreHook preHook : PRE_HOOKS) { preHook.preAuthHook(context, client); } } - public void checkServerHook(String username, String serverID) { + public void checkServerHook(String username, String serverID) throws AuthException { for (CheckServerHook hook : CHECKSERVER_HOOKS) { hook.checkServerHook(username, serverID); } } - public void joinServerHook(String username, String accessToken, String serverID) { + public void joinServerHook(String username, String accessToken, String serverID) throws AuthException { for (JoinServerHook hook : JOINSERVER_HOOKS) { hook.joinServerHook(username, accessToken, serverID); } } - public void postHook(AuthResponse.AuthContext context, Client client) { + public void postHook(AuthResponse.AuthContext context, Client client) throws AuthException { for (AuthPostHook postHook : POST_HOOKS) { postHook.postAuthHook(context, client); } 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 20a6ff60..6e4574b6 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 @@ -36,13 +36,14 @@ public AuthResponse(LaunchServer server, long session, HInput input, HOutput out } public static class AuthContext { - public AuthContext(long session, String login, int password_lenght, String customText, String client, String hwid, boolean isServerAuth) { + public AuthContext(long session, String login, int password_lenght, String customText, String client, String hwid, String ip, boolean isServerAuth) { this.session = session; this.login = login; this.password_lenght = password_lenght; this.customText = customText; this.client = client; this.hwid = hwid; + this.ip = ip; this.isServerAuth = isServerAuth; } @@ -52,6 +53,7 @@ public AuthContext(long session, String login, int password_lenght, String custo public String client; public String hwid; public String customText; + public String ip; public boolean isServerAuth; } @@ -82,13 +84,9 @@ public void reply() throws Exception { AuthProviderResult result; AuthProvider provider = server.config.authProvider[auth_id]; clientData.type = Client.Type.USER; - AuthContext context = new AuthContext(session, login, password.length(), customText, client, hwid_str, false); + AuthContext context = new AuthContext(session, login, password.length(), customText, client, hwid_str, ip, false); try { server.authHookManager.preHook(context, clientData); - if (server.limiter.isLimit(ip)) { - AuthProvider.authError(server.config.authRejectString); - return; - } if (!clientData.checkSign) { throw new AuthException("You must using checkLauncher"); } 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 66ce8cce..7c75842c 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 @@ -53,10 +53,6 @@ public void reply() throws Exception { AuthProviderResult result; AuthProvider provider = server.config.authProvider[auth_id]; try { - if (server.limiter.isLimit(ip)) { - AuthProvider.authError(server.config.authRejectString); - return; - } result = provider.auth(login, password, ip); if (!VerifyHelper.isValidUsername(result.username)) { AuthProvider.authError(String.format("Illegal result: '%s'", result.username)); 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 65aae7e9..486a104e 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 @@ -56,10 +56,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client try { AuthRequestEvent result = new AuthRequestEvent(); String ip = IOHelper.getIP(ctx.channel().remoteAddress()); - if (LaunchServer.server.limiter.isLimit(ip)) { - AuthProvider.authError(LaunchServer.server.config.authRejectString); - return; - } if ((authType == null || authType == ConnectTypes.CLIENT) &&!clientData.checkSign) { AuthProvider.authError("Don't skip Launcher Update"); return; @@ -82,7 +78,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client { AuthProvider.authError("authType: SERVER not allowed for this account"); } - ru.gravit.launchserver.response.auth.AuthResponse.AuthContext context = new ru.gravit.launchserver.response.auth.AuthResponse.AuthContext(0, login, password.length(),customText, client, null, false); + ru.gravit.launchserver.response.auth.AuthResponse.AuthContext context = new ru.gravit.launchserver.response.auth.AuthResponse.AuthContext(0, login, password.length(),customText, client, ip, null, false); AuthProvider provider = LaunchServer.server.config.authProvider[authid]; LaunchServer.server.authHookManager.preHook(context, clientData); provider.preAuth(login,password,customText,ip); From 64f865fa47725eb964978ea6275d9c83b0fa04a9 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 13 Mar 2019 17:09:27 +0700 Subject: [PATCH 04/28] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20Updater=20=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 1 - .../ru/gravit/launchserver/LaunchServer.java | 3 +- .../java/ru/gravit/launchserver/Updater.java | 92 ------------------- 3 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 0f2209c1..9f58b2b9 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -48,7 +48,6 @@ pack project(':libLauncher') bundle 'commons-codec:commons-codec:1.11' bundle 'org.javassist:javassist:3.24.1-GA' bundle 'io.netty:netty-all:4.1.32.Final' - bundle 'org.kohsuke:github-api:1.95' bundle 'org.slf4j:slf4j-simple:1.7.25' bundle 'org.slf4j:slf4j-api:1.7.25' diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 95bb6f39..dc630df0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -352,7 +352,6 @@ public static void main(String... args) throws Throwable { public volatile Map> updatesDirMap; public final Timer taskPool; - public final Updater updater; public static Gson gson; public static GsonBuilder gsonBuilder; @@ -379,6 +378,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE HWIDHandler.registerHandlers(); PermissionsHandler.registerHandlers(); Response.registerResponses(); + Component.registerComponents(); LaunchServer.server = this; // Set command handler @@ -533,7 +533,6 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE LogHelper.debug("PostInit components successful"); } // start updater - this.updater = new Updater(this); if(config.netty != null) nettyServerSocketHandler = new NettyServerSocketHandler(this); else diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java deleted file mode 100644 index a6d57254..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java +++ /dev/null @@ -1,92 +0,0 @@ -package ru.gravit.launchserver; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.Locale; -import java.util.TimerTask; -import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.kohsuke.github.GHRelease; -import org.kohsuke.github.GHRepository; -import org.kohsuke.github.GitHub; - -import ru.gravit.launcher.Launcher; -import ru.gravit.utils.Version; -import ru.gravit.utils.Version.Type; -import ru.gravit.utils.helper.LogHelper; - -public class Updater extends TimerTask { - private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss", Locale.US); - private static final long period = 1000*3600; - private static final Version VERSION = Launcher.getVersion(); - private final GHRepository gravitLauncher; - private Version parent = VERSION; - - public Updater(LaunchServer srv) { - - GHRepository gravitLauncherTmp = null; - try { - gravitLauncherTmp = GitHub.connectAnonymously().getOrganization("GravitLauncher").getRepository("Launcher"); - } catch (Throwable e) { - LogHelper.error(e); - } - this.gravitLauncher = gravitLauncherTmp; - run(); - if (srv.config.updatesNotify) srv.taskPool.schedule(this, new Date(System.currentTimeMillis()+period), period); - } - - @Override - public void run() { - try { - GHRelease rel = gravitLauncher.getLatestRelease(); - Version relV = parseVer(rel.getTagName()); - if (relV == null) { - LogHelper.debug("Updater: parsing version error."); - return; - } - if (!parent.equals(relV)) parent = relV; - if (VERSION.major >= relV.major && VERSION.minor >= relV.minor - && VERSION.patch >= relV.patch && VERSION.build >= relV.build) return; - if (relV.release.equals(Type.STABLE) || relV.release.equals(Type.LTS)) { - LogHelper.warning("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString()); - LogHelper.warning("You can download it: " + rel.getHtmlUrl().toString()); - LogHelper.warning("It`s published at: " + DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(rel.getPublished_at().getTime()), ZoneId.systemDefault()))); - } else { - LogHelper.debug("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString()); - LogHelper.debug("You can download it: " + rel.getHtmlUrl()); - LogHelper.debug("It`s published at: " + DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(rel.getPublished_at().getTime()), ZoneId.systemDefault()))); - } - } catch (Throwable e) { - LogHelper.error(e); - } - } - - private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+\\.?\\d*"); - private static final Pattern pointPatternSpltitter = Pattern.compile("\\."); - - private static Version parseVer(String relS) { - Matcher verMatcher = startingVerPattern.matcher(relS); - if (!verMatcher.find()) return VERSION; - String[] ver = pointPatternSpltitter.split(relS.substring(verMatcher.start(), verMatcher.end())); - if (ver.length < 3) return VERSION; - return new Version(Integer.parseInt(ver[0]), Integer.parseInt(ver[1]), - Integer.parseInt(ver[2]), ver.length > 3 ? Integer.parseInt(ver[3]) : 0, findRelType(relS.substring(verMatcher.end()))); - } - - private static Type findRelType(String substring) { - if (substring.isEmpty()) return Type.UNKNOWN; - String tS = substring; - if (tS.startsWith("-")) tS = tS.substring(1); - final String wrk = tS.toLowerCase(Locale.ENGLISH); - final AtomicReference t = new AtomicReference(Type.UNKNOWN); - Type.unModTypes.forEach((s, type) -> { - if (wrk.startsWith(s)) t.set(type); - }); - return t.get(); - } -} From 3f887ef6199d96628673625b95a9286bfcdb2f04 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 14 Mar 2019 00:06:28 +0700 Subject: [PATCH 05/28] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20upd?= =?UTF-8?q?atesNotify=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=B6=D0=B8=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA=20ClientLau?= =?UTF-8?q?ncher.launch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 2 -- .../main/java/ru/gravit/launcher/client/ClientLauncher.java | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index dc630df0..1a01c2c9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -122,8 +122,6 @@ public static final class Config { public String startScript; - public boolean updatesNotify = true; // Defaultly to true - public String getAddress() { return address; } 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 7c1dfcbe..0bd6595c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -302,7 +302,7 @@ public static Process launch( // Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars) LogHelper.debug("Writing ClientLauncher params"); ClientLauncherContext context = new ClientLauncherContext(); - CommonHelper.newThread("Client params writter", false, () -> + CommonHelper.newThread("Client params writter", true, () -> { try { try (ServerSocket socket = new ServerSocket()) { @@ -388,6 +388,7 @@ public static Process launch( } // Let's rock! process = builder.start(); + if(!LogHelper.isDebugEnabled()) Thread.sleep(1000); //даем время потоку записи return process; } From d0d5eb69d70038e43b2b1e4b92ad4984704a900e Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 13 Mar 2019 20:34:24 +0300 Subject: [PATCH 06/28] =?UTF-8?q?[FEATURE]=20=D0=9D=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B8=D0=BB=D0=B8=D1=82=D1=8C=20Radon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ LaunchServer/build.gradle | 6 ++++-- Radon | 1 + settings.gradle | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) create mode 160000 Radon diff --git a/.gitmodules b/.gitmodules index f70ed106..8d20570a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "modules"] path = modules url = git@github.com:GravitLauncher/LauncherModules.git +[submodule "Radon"] + path = Radon + url = git@github.com:GravitLauncher/Radon.git diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 9f58b2b9..5ca9ff1b 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -8,6 +8,9 @@ maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { + url 'http://oss.sonatype.org/content/groups/public' + } } sourceCompatibility = '1.8' @@ -38,8 +41,7 @@ dependencies { pack project(':libLauncher') - bundle 'org.ow2.asm:asm-commons:7.0' - bundle 'org.ow2.asm:asm-util:7.0' + bundle project(':Radon') bundle 'mysql:mysql-connector-java:8.0.13' bundle 'jline:jline:2.14.6' bundle 'net.sf.proguard:proguard-base:6.0.3' diff --git a/Radon b/Radon new file mode 160000 index 00000000..d8ec3cca --- /dev/null +++ b/Radon @@ -0,0 +1 @@ +Subproject commit d8ec3cca611b3daf69e209f05fd97c703ffb530c diff --git a/settings.gradle b/settings.gradle index 3fc709d9..234a8355 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,7 @@ rootProject.name = 'GravitLauncher' include 'Launcher' +include 'Radon' include 'libLauncher' include 'LauncherAPI' include 'ServerWrapper' From e0eb90ec37e85623da134ca7e9dea39ff87a7acc Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 13 Mar 2019 21:02:41 +0300 Subject: [PATCH 07/28] =?UTF-8?q?[FIX]=20=D0=9F=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20gradle=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=BE?= =?UTF-8?q?=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 5 +---- build.gradle | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 5ca9ff1b..20cab57e 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -2,14 +2,11 @@ def mainAgentName = "ru.gravit.launchserver.StarterAgent" repositories { - maven { - url "http://maven.geomajas.org/" - } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { - url 'http://oss.sonatype.org/content/groups/public' + url "http://maven.geomajas.org/" } } diff --git a/build.gradle b/build.gradle index 3d42a735..02d6daae 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ -configure(subprojects.findAll {it.name != 'modules'}) { +configure(subprojects.findAll { it.name != 'modules' && it.name != 'Radon' }) { apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'java' repositories { mavenCentral() + maven { url 'http://oss.sonatype.org/content/groups/public' } maven { url "http://clojars.org/repo/" } From a2784aaa459e55b99180c66d5e62d83cca8e316a Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 13 Mar 2019 21:46:08 +0300 Subject: [PATCH 08/28] [FEATURE] RadonBuildTask. TODO: Integrate it and create default config. --- .../launchserver/binary/ProguardConf.java | 5 +- .../binary/tasks/RadonBuildTask.java | 47 +++++++++++++++++++ .../ru/gravit/launchserver/defaults/radon.cfg | 0 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java create mode 100644 LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java index 6853ee48..389fa0a5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java @@ -4,6 +4,7 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.UnpackHelper; import java.io.*; import java.nio.file.Files; @@ -58,9 +59,7 @@ public String[] buildConfig(Path inputJar, Path outputJar) { private void genConfig(boolean force) throws IOException { if (IOHelper.exists(config) && !force) return; Files.deleteIfExists(config); - try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) { - IOHelper.transfer(in, out); - } + UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config); } public void genWords(boolean force) throws IOException { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java new file mode 100644 index 00000000..505ed17f --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -0,0 +1,47 @@ +package ru.gravit.launchserver.binary.tasks; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.UnpackHelper; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.stream.Collectors; + +import me.itzsomebody.radon.Radon; +import me.itzsomebody.radon.SessionInfo; +import me.itzsomebody.radon.config.ConfigurationParser; + +public class RadonBuildTask implements LauncherBuildTask { + private final LaunchServer srv; + public final Path config; + + public RadonBuildTask(LaunchServer srv) { + this.srv = srv; + config = this.srv.dir.resolve("radon.yml"); + } + + @Override + public String getName() { + return "Radon"; + } + + @Override + public Path process(Path inputFile) throws IOException { + if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); + Path outputFile = srv.launcherBinary.nextLowerPath(this); + ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); + SessionInfo info = p.createSessionFromConfig(); + info.setInput(inputFile.toFile()); + info.setOutput(outputFile.toFile()); + info.setLibraries(srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + Radon r = new Radon(info); + r.run(); + return outputFile; + } + + @Override + public boolean allowDelete() { + return true; + } +} diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg new file mode 100644 index 00000000..e69de29b From e37bda896201b969caa6f44760a570491a244066 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 13 Mar 2019 22:13:39 +0300 Subject: [PATCH 09/28] =?UTF-8?q?[FEATURE]=20Radon=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=B5=D1=82.=20=D0=A2=D1=80=D0=B5=D0=B1?= =?UTF-8?q?=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D1=82=D0=B5=D1=81=D1=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/JARLauncherBinary.java | 1 + .../ru/gravit/launchserver/defaults/radon.cfg | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) 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 5a113e71..08a2198d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -42,6 +42,7 @@ public void init() { tasks.add(new PrepareBuildTask(server)); tasks.add(new MainBuildTask(server)); tasks.add(new ProGuardBuildTask(server)); + tasks.add(new RadonBuildTask(server)); tasks.add(new AttachJarsTask(server)); tasks.add(new AdditionalFixesApplyTask(server)); } diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index e69de29b..a72a1ac6 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -0,0 +1,38 @@ +StringEncryption: + Enabled: true + Mode: Heavy + StringPool: false +InvokeDynamic: Heavy +NumberObfuscation: Heavy +FlowObfuscation: Heavy +LocalVariables: + Enabled: false + Remove: true +LineNumbers: + Enabled: false + Remove: true +SourceName: + Enabled: false + Remove: true +SourceDebug: + Enabled: false + Remove: true +HideCode: true +Shuffler: false +Crasher: false +Optimizer: + Enabled: true + InlineGotoGoto: true + InlineGotoReturn: true + RemoveNopInstructions: true +Watermarker: + Enabled: false + Message: "This copy belongs to ItzSomebody" + Key: "SuperSecureKey" +Expiration: + Enabled: false + InjectJOptionPane: true + Message: "Sorry, but your software trial has passed the expiration date. Please pay the ItzSomebody Corporation 1 USD to the paypal address non-existant@troll.email to receive the full version." + Expires: "12/31/2018" +Dictionary: Spaces +TrashClasses: 200 \ No newline at end of file From 7e5fafa159854ab0b9a99a8f5d9b149e0d24bfe4 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 14 Mar 2019 02:26:20 +0700 Subject: [PATCH 10/28] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BE=D1=82=D0=B2=D0=B0=D0=BB=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D1=8E=D1=89=D0=B8=D0=BC=D1=81=D1=8F=20=D1=81=D0=BE=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=82=D0=B0=D0=B9=D0=BC=D0=B0=D1=83=D1=82=D1=83=20=D0=B2?= =?UTF-8?q?=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D1=85=D0=B5=D1=88?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/request/update/UpdateRequest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 80352243..96c01bc4 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 @@ -303,9 +303,16 @@ public Integer getLegacyType() { } @Override - protected UpdateRequestEvent requestDo(HInput input, HOutput output) throws IOException, SignatureException { + public UpdateRequestEvent request() throws Exception { Files.createDirectories(dir); localDir = new HashedDir(dir, matcher, false, digest); + + // Start request + return super.request(); + } + + @Override + protected UpdateRequestEvent requestDo(HInput input, HOutput output) throws IOException, SignatureException { // Write update dir name output.writeString(dirName, 255); output.flush(); From 3dfdb88e997df4368b8f0eab0c54acb787400e7c Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Thu, 14 Mar 2019 15:40:32 +0300 Subject: [PATCH 11/28] =?UTF-8?q?[FIX]=20=D0=94=D0=B5=D1=84=D0=BE=D0=BB?= =?UTF-8?q?=D1=82=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3?= =?UTF-8?q?=20Radon...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/tasks/RadonBuildTask.java | 1 + .../ru/gravit/launchserver/defaults/radon.cfg | 21 ++----------------- Radon | 2 +- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java index 505ed17f..5c1265de 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -19,6 +19,7 @@ public class RadonBuildTask implements LauncherBuildTask { public RadonBuildTask(LaunchServer srv) { this.srv = srv; config = this.srv.dir.resolve("radon.yml"); + System.setProperty("radon.useJVMCP", "true"); } @Override diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index a72a1ac6..58af0e3b 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -5,20 +5,8 @@ StringEncryption: InvokeDynamic: Heavy NumberObfuscation: Heavy FlowObfuscation: Heavy -LocalVariables: - Enabled: false - Remove: true -LineNumbers: - Enabled: false - Remove: true -SourceName: - Enabled: false - Remove: true -SourceDebug: - Enabled: false - Remove: true HideCode: true -Shuffler: false +Shuffler: true Crasher: false Optimizer: Enabled: true @@ -27,12 +15,7 @@ Optimizer: RemoveNopInstructions: true Watermarker: Enabled: false - Message: "This copy belongs to ItzSomebody" + Message: "This copy belongs to GravitLauncher" Key: "SuperSecureKey" -Expiration: - Enabled: false - InjectJOptionPane: true - Message: "Sorry, but your software trial has passed the expiration date. Please pay the ItzSomebody Corporation 1 USD to the paypal address non-existant@troll.email to receive the full version." - Expires: "12/31/2018" Dictionary: Spaces TrashClasses: 200 \ No newline at end of file diff --git a/Radon b/Radon index d8ec3cca..161d3940 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit d8ec3cca611b3daf69e209f05fd97c703ffb530c +Subproject commit 161d394074f7e51e994215def64b25a8fe46edef From 37be6b86c3ce48b578fc57d050de416644e1fda2 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 14 Mar 2019 23:54:08 +0700 Subject: [PATCH 12/28] [FEATURE] ProtectHandler --- .../ru/gravit/launchserver/LaunchServer.java | 16 +++++++ .../auth/protect/NoProtectHandler.java | 16 +++++++ .../auth/protect/ProtectHandler.java | 46 +++++++++++++++++++ .../config/ProtectHandlerAdapter.java | 37 +++++++++++++++ .../response/auth/AuthResponse.java | 2 + Launcher/runtime/dialog/dialog.js | 1 + .../launcher/client/FunctionalBridge.java | 7 +++ .../guard/LauncherGuardInterface.java | 1 + .../launcher/guard/LauncherJavaGuard.java | 5 ++ .../launcher/guard/LauncherNoGuard.java | 5 ++ .../launcher/guard/LauncherWrapperGuard.java | 5 ++ .../launcher/request/auth/AuthRequest.java | 3 +- .../events/request/AuthRequestEvent.java | 9 ++++ 13 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/NoProtectHandler.java create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/config/ProtectHandlerAdapter.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 1a01c2c9..4784317a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -8,6 +8,8 @@ import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; +import ru.gravit.launchserver.auth.protect.NoProtectHandler; +import ru.gravit.launchserver.auth.protect.ProtectHandler; import ru.gravit.launchserver.components.AuthLimiterComponent; import ru.gravit.launchserver.auth.handler.AuthHandler; import ru.gravit.launchserver.auth.handler.MemoryAuthHandler; @@ -89,6 +91,8 @@ public static final class Config { public AuthHandler authHandler; + public ProtectHandler protectHandler; + public PermissionsHandler permissionsHandler; public TextureProvider textureProvider; @@ -159,6 +163,10 @@ public void verify() { if (authHandler == null) { throw new NullPointerException("AuthHandler must not be null"); } + if(protectHandler == null) + { + throw new NullPointerException("ProtectHandler must not be null"); + } if (authProvider == null || authProvider[0] == null) { throw new NullPointerException("AuthProvider must not be null"); } @@ -377,6 +385,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE PermissionsHandler.registerHandlers(); Response.registerResponses(); Component.registerComponents(); + ProtectHandler.registerHandlers(); LaunchServer.server = this; // Set command handler @@ -435,6 +444,10 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE for (AuthProvider provider : config.authProvider) { provider.init(); } + if(config.protectHandler != null) + { + config.protectHandler.checkLaunchServerLicense(); + } config.authHandler.init(); if(config.components != null) { @@ -546,6 +559,7 @@ public static void initGson() { Launcher.gsonBuilder.registerTypeAdapter(PermissionsHandler.class, new PermissionsHandlerAdapter()); Launcher.gsonBuilder.registerTypeAdapter(HWIDHandler.class, new HWIDHandlerAdapter()); Launcher.gsonBuilder.registerTypeAdapter(Component.class, new ComponentAdapter()); + Launcher.gsonBuilder.registerTypeAdapter(ProtectHandler.class, new ProtectHandlerAdapter()); Launcher.gson = Launcher.gsonBuilder.create(); //Human readable @@ -557,6 +571,7 @@ public static void initGson() { LaunchServer.gsonBuilder.registerTypeAdapter(PermissionsHandler.class, new PermissionsHandlerAdapter()); LaunchServer.gsonBuilder.registerTypeAdapter(HWIDHandler.class, new HWIDHandlerAdapter()); LaunchServer.gsonBuilder.registerTypeAdapter(Component.class, new ComponentAdapter()); + LaunchServer.gsonBuilder.registerTypeAdapter(ProtectHandler.class, new ProtectHandlerAdapter()); LaunchServer.gson = LaunchServer.gsonBuilder.create(); } @@ -608,6 +623,7 @@ private void generateConfigIfNotExists() throws IOException { newConfig.startScript = JVMHelper.OS_TYPE.equals(JVMHelper.OS.MUSTDIE) ? "." + File.separator + "start.bat" : "." + File.separator + "start.sh"; newConfig.authHandler = new MemoryAuthHandler(); newConfig.hwidHandler = new AcceptHWIDHandler(); + newConfig.protectHandler = new NoProtectHandler(); newConfig.authProvider = new AuthProvider[]{new RejectAuthProvider("Настройте authProvider")}; newConfig.textureProvider = new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png"); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/NoProtectHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/NoProtectHandler.java new file mode 100644 index 00000000..400c9a3e --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/NoProtectHandler.java @@ -0,0 +1,16 @@ +package ru.gravit.launchserver.auth.protect; + +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.utils.helper.SecurityHelper; + +public class NoProtectHandler extends ProtectHandler { + @Override + public String generateSecureToken(AuthResponse.AuthContext context) { + return SecurityHelper.randomStringToken(); + } + + @Override + public void checkLaunchServerLicense() { + // None + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java new file mode 100644 index 00000000..9145df79 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java @@ -0,0 +1,46 @@ +package ru.gravit.launchserver.auth.protect; + +import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.utils.helper.VerifyHelper; + +import java.util.Map; +import java.util.Objects; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +public abstract class ProtectHandler { + private static final Map> PROTECT_HANDLERS = new ConcurrentHashMap<>(4); + private static boolean registredHandl = false; + + + public static void registerHandler(String name, Class adapter) { + VerifyHelper.verifyIDName(name); + VerifyHelper.putIfAbsent(PROTECT_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"), + String.format("Protect handler has been already registered: '%s'", name)); + } + + public static Class getHandlerClass(String name) { + return PROTECT_HANDLERS.get(name); + } + + public static String getHandlerName(Class clazz) { + for (Map.Entry> e : PROTECT_HANDLERS.entrySet()) { + if (e.getValue().equals(clazz)) return e.getKey(); + } + return null; + } + + public static void registerHandlers() { + if (!registredHandl) { + registerHandler("none", NoProtectHandler.class); + registredHandl = true; + } + } + + public abstract String generateSecureToken(AuthResponse.AuthContext context); //Генерация токена для передачи его в LauncherGuardInterface + + public abstract void checkLaunchServerLicense(); //Выдает SecurityException при ошибке проверки лицензии + //public abstract +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/ProtectHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ProtectHandlerAdapter.java new file mode 100644 index 00000000..6e6fcd19 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/ProtectHandlerAdapter.java @@ -0,0 +1,37 @@ +package ru.gravit.launchserver.config; + +import com.google.gson.*; +import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.launchserver.auth.protect.ProtectHandler; +import ru.gravit.utils.helper.LogHelper; + +import java.lang.reflect.Type; + +public class ProtectHandlerAdapter implements JsonSerializer, JsonDeserializer { + private static final String PROP_NAME = "type"; + + @Override + public ProtectHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); + Class cls = ProtectHandler.getHandlerClass(typename); + if(cls == null) + { + LogHelper.error("ProtectHandler %s not found", typename); + return null; + } + + + return (ProtectHandler) context.deserialize(json, cls); + } + + @Override + public JsonElement serialize(ProtectHandler src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject jo = context.serialize(src).getAsJsonObject(); + + @SuppressWarnings("unchecked") + String classPath = ProtectHandler.getHandlerName((Class) src.getClass()); + jo.add(PROP_NAME, new JsonPrimitive(classPath)); + + return jo; + } +} 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 6e4574b6..1b29cedc 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 @@ -137,10 +137,12 @@ public void reply() throws Exception { requestError("Internal auth handler error"); return; } + String protectToken = server.config.protectHandler.generateSecureToken(context); writeNoError(output); // Write profile and UUID ProfileByUUIDResponse.getProfile(server, uuid, result.username, client).write(output); output.writeASCII(result.accessToken, -SecurityHelper.TOKEN_STRING_LENGTH); clientData.permissions.write(output); + output.writeString(protectToken, SerializeLimits.MAX_CUSTOM_TEXT); } } diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index dfa26435..712b3fcb 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -215,6 +215,7 @@ function doAuth(login, rsaPassword) { overlay.show(processing.overlay, function (event) { FunctionalBridge.getHWID.join(); makeAuthRequest(login, rsaPassword, function (result) { + FunctionalBridge.setAuthParams(result); loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions}; overlay.hide(0, function () { 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 f055ebda..d001f8da 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -3,6 +3,7 @@ import javafx.concurrent.Task; import ru.gravit.launcher.HWID; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.events.request.AuthRequestEvent; import ru.gravit.launcher.guard.LauncherGuardManager; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; @@ -103,6 +104,12 @@ public static HasherStore getDefaultHasherStore() { return HasherManager.getDefaultStore(); } + @LauncherAPI + public static void setAuthParams(AuthRequestEvent event) + { + LauncherGuardManager.guard.setProtectToken(event.protectToken); + } + @FunctionalInterface public interface HashedDirRunnable { SignedObjectHolder run() throws Exception; diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java index fb6e8fdd..be71089c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java @@ -11,4 +11,5 @@ public interface LauncherGuardInterface { void init(boolean clientInstance); void addCustomParams(ClientLauncherContext context); void addCustomEnv(ClientLauncherContext context); + void setProtectToken(String token); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java index 77c4606a..31ef0941 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java @@ -43,4 +43,9 @@ public void addCustomParams(ClientLauncherContext context) { public void addCustomEnv(ClientLauncherContext context) { } + + @Override + public void setProtectToken(String token) { + + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java index 9bd1923c..2fbc872b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java @@ -40,4 +40,9 @@ public void addCustomParams(ClientLauncherContext context) { public void addCustomEnv(ClientLauncherContext context) { } + + @Override + public void setProtectToken(String token) { + + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java index bd97ebbb..44c60875 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -69,4 +69,9 @@ public void addCustomEnv(ClientLauncherContext context) { env.put("GUARD_LICENSE_KEY", config.guardLicenseKey); } } + + @Override + public void setProtectToken(String token) { + + } } 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 f9e2e7f5..0302dfd5 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 @@ -118,7 +118,8 @@ protected AuthRequestEvent requestDo(HInput input, HOutput output) throws IOExce PlayerProfile pp = new PlayerProfile(input); String accessToken = input.readASCII(-SecurityHelper.TOKEN_STRING_LENGTH); ClientPermissions permissions = new ClientPermissions(input); - return new AuthRequestEvent(pp, accessToken, permissions); + String protectToken = input.readString(SerializeLimits.MAX_CUSTOM_TEXT); + return new AuthRequestEvent(permissions, pp, accessToken, protectToken); } @Override diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java index a61a0a18..aab137be 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java @@ -20,6 +20,8 @@ public AuthRequestEvent() { public PlayerProfile playerProfile; @LauncherNetworkAPI public String accessToken; + @LauncherNetworkAPI + public String protectToken; public AuthRequestEvent(PlayerProfile pp, String accessToken, ClientPermissions permissions) { this.playerProfile = pp; @@ -27,6 +29,13 @@ public AuthRequestEvent(PlayerProfile pp, String accessToken, ClientPermissions this.permissions = permissions; } + public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfile, String accessToken, String protectToken) { + this.permissions = permissions; + this.playerProfile = playerProfile; + this.accessToken = accessToken; + this.protectToken = protectToken; + } + @Override public UUID getUUID() { return uuid; From dc2a9787160e2b4c604a9e1ed979651d4c0fdc61 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 14 Mar 2019 23:56:43 +0700 Subject: [PATCH 13/28] =?UTF-8?q?[FEATURE]=20=D0=97=D0=B0=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D1=8C=20protectToken=20d=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D1=8B=20wrapper'=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launcher/guard/LauncherJavaGuard.java | 2 +- .../main/java/ru/gravit/launcher/guard/LauncherNoGuard.java | 2 +- .../java/ru/gravit/launcher/guard/LauncherWrapperGuard.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java index 31ef0941..3d637628 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java @@ -46,6 +46,6 @@ public void addCustomEnv(ClientLauncherContext context) { @Override public void setProtectToken(String token) { - + //Skip } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java index 2fbc872b..4ae7b35e 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java @@ -43,6 +43,6 @@ public void addCustomEnv(ClientLauncherContext context) { @Override public void setProtectToken(String token) { - + //Skip } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java index 44c60875..91df7434 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -13,6 +13,9 @@ import java.util.Map; public class LauncherWrapperGuard implements LauncherGuardInterface { + + public String protectToken; + @Override public String getName() { return "wrapper"; @@ -62,6 +65,7 @@ public void addCustomEnv(ClientLauncherContext context) { env.put("GUARD_USERNAME", context.playerProfile.username); env.put("GUARD_PUBLICKEY", config.publicKey.getModulus().toString(16)); env.put("GUARD_PROJECTNAME", config.projectname); + env.put("GUARD_TOKEN", protectToken); if(config.guardLicenseName != null) env.put("GUARD_LICENSE_NAME", config.guardLicenseName); if(config.guardLicenseKey != null) @@ -72,6 +76,6 @@ public void addCustomEnv(ClientLauncherContext context) { @Override public void setProtectToken(String token) { - + protectToken = token; } } From 8bea8f3ce9fef7dc40d85604aaa0764c18e50d64 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Thu, 14 Mar 2019 22:01:32 +0300 Subject: [PATCH 14/28] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D1=91=D0=BD=20Radon.=20PR=20=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Radon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Radon b/Radon index 161d3940..a9ae5db2 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit 161d394074f7e51e994215def64b25a8fe46edef +Subproject commit a9ae5db27c3f4d31e225eb79b26aae3b85713504 From 7107b6e593e6329b1074c86e3e198d6d37e21f14 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 16:59:23 +0300 Subject: [PATCH 15/28] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BE=D1=81=D1=82=D0=B0=D1=82=D0=BA=D0=B8=20Ava?= =?UTF-8?q?nguard.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/client/ClientLauncher.java | 2 -- 1 file changed, 2 deletions(-) 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 0bd6595c..79455c5e 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -356,8 +356,6 @@ public static Process launch( context.args.add(JVMHelper.jvmProperty("os.name", "Windows 10")); context.args.add(JVMHelper.jvmProperty("os.version", "10.0")); } - context.args.add(JVMHelper.systemToJvmProperty("avn32")); - context.args.add(JVMHelper.systemToJvmProperty("avn64")); } // Add classpath and main class String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); From e94908d08f28bd40d611a4641c00aef8d1c137f2 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 17:19:21 +0300 Subject: [PATCH 16/28] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D1=91=D0=BD=20Radon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Radon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Radon b/Radon index a9ae5db2..8b323623 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit a9ae5db27c3f4d31e225eb79b26aae3b85713504 +Subproject commit 8b323623f885ea4959e8b5f0e00dc4ca1b5285d6 From f739cff28cf68fb6099b2812889a7d84f50c1c6d Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 17:32:01 +0300 Subject: [PATCH 17/28] =?UTF-8?q?[FIX]=20=D0=A0=D0=B0=D0=B4=D0=BE=D0=BD=20?= =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 8 ++++++++ .../main/java/ru/gravit/launchserver/LaunchServer.java | 10 +++++----- Radon | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 20cab57e..31439382 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -14,6 +14,7 @@ targetCompatibility = '1.8' configurations { + compileOnlyA bundleOnly bundle hikari @@ -69,6 +70,8 @@ bundle project(':Radon') launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-linux') { exclude group: '*' } + + compileOnlyA 'com.google.guava:guava:26.0-jre' } task hikari(type: Copy) { @@ -112,6 +115,11 @@ task dumpLibs(type: Copy) { from configurations.bundleOnly } +task dumpCompileOnlyLibs(type: Copy) { + into "$buildDir/libs/launcher-libraries-compile" + from configurations.compileOnlyA +} + task bundle(type: Zip) { dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.jar archiveName 'LaunchServer.zip' diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 4784317a..5cfec95d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -277,7 +277,8 @@ public static void main(String... args) throws Throwable { // Start LaunchServer long startTime = System.currentTimeMillis(); try { - LaunchServer launchserver = new LaunchServer(IOHelper.WORKING_DIR, args); + @SuppressWarnings("resource") + LaunchServer launchserver = new LaunchServer(IOHelper.WORKING_DIR, args); if(args.length == 0) launchserver.run(); else { //Обработка команды launchserver.commandHandler.eval(args,false); @@ -296,6 +297,8 @@ public static void main(String... args) throws Throwable { public final Path launcherLibraries; + public final Path launcherLibrariesCompile; + public final List args; public final Path configFile; @@ -366,10 +369,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE this.dir = dir; taskPool = new Timer("Timered task worker thread", true); launcherLibraries = dir.resolve("launcher-libraries"); - if (!Files.isDirectory(launcherLibraries)) { - Files.deleteIfExists(launcherLibraries); - Files.createDirectory(launcherLibraries); - } + launcherLibrariesCompile = dir.resolve("launcher-libraries-compile"); this.args = Arrays.asList(args); configFile = dir.resolve("LaunchServer.conf"); publicKeyFile = dir.resolve("public.key"); diff --git a/Radon b/Radon index 8b323623..9ad5210d 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit 8b323623f885ea4959e8b5f0e00dc4ca1b5285d6 +Subproject commit 9ad5210d821a5fcc072dae9f8e24ef37c8544757 From 62af331966d84239c806ac4768c308fc892e3b25 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 17:34:49 +0300 Subject: [PATCH 18/28] [FIX] Gradle scripts. --- LaunchServer/build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 31439382..0d419c1a 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -121,12 +121,13 @@ task dumpCompileOnlyLibs(type: Copy) { } task bundle(type: Zip) { - dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.jar + dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.jar archiveName 'LaunchServer.zip' destinationDir file("$buildDir") from(tasks.dumpLibs.destinationDir) { into 'libraries' } + from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' } from tasks.jar.archivePath from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' } } -build.dependsOn tasks.dumpLibs, tasks.bundle +build.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.bundle From 9122a700e08d001e20e3af58684b3adf2af01bca Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 17:40:48 +0300 Subject: [PATCH 19/28] =?UTF-8?q?[FIX]=20ClassPath=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?Radon=20=D0=B8=20Proguard.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/binary/JARLauncherBinary.java | 2 ++ .../java/ru/gravit/launchserver/binary/ProguardConf.java | 4 +++- .../gravit/launchserver/binary/tasks/PrepareBuildTask.java | 2 ++ .../ru/gravit/launchserver/binary/tasks/RadonBuildTask.java | 6 +++++- 4 files changed, 12 insertions(+), 2 deletions(-) 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 08a2198d..25205ea0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -21,6 +21,7 @@ public final class JARLauncherBinary extends LauncherBinary { public final Path buildDir; public List tasks; public List coreLibs; + public List addonLibs; public JARLauncherBinary(LaunchServer server) throws IOException { super(server); @@ -31,6 +32,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException { buildDir = server.dir.resolve("build"); tasks = new ArrayList<>(); coreLibs = new ArrayList<>(); + addonLibs = new ArrayList<>(); if (!Files.isDirectory(buildDir)) { Files.deleteIfExists(buildDir); Files.createDirectory(buildDir); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java index 389fa0a5..365f55a4 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java @@ -14,7 +14,6 @@ import java.util.List; public class ProguardConf { - private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; private static String generateString(SecureRandom rand, String lowString, String upString, int il) { @@ -51,6 +50,9 @@ public String[] buildConfig(Path inputJar, Path outputJar) { srv.launcherBinary.coreLibs.stream() .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .forEach(confStrs::add); + srv.launcherBinary.addonLibs.stream() + .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") + .forEach(confStrs::add); confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add(readConf()); return confStrs.toArray(new String[0]); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/PrepareBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/PrepareBuildTask.java index dc08fe0b..6e9cb621 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/PrepareBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/PrepareBuildTask.java @@ -30,7 +30,9 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { server.launcherBinary.coreLibs.clear(); + server.launcherBinary.addonLibs.clear(); IOHelper.walk(server.launcherLibraries, new ListFileVisitor(server.launcherBinary.coreLibs), true); + IOHelper.walk(server.launcherLibrariesCompile, new ListFileVisitor(server.launcherBinary.addonLibs), true); UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), result); tryUnpack(); return result; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java index 5c1265de..ddba3c90 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -4,8 +4,10 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.UnpackHelper; +import java.io.File; import java.io.IOException; import java.nio.file.Path; +import java.util.List; import java.util.stream.Collectors; import me.itzsomebody.radon.Radon; @@ -35,7 +37,9 @@ public Path process(Path inputFile) throws IOException { SessionInfo info = p.createSessionFromConfig(); info.setInput(inputFile.toFile()); info.setOutput(outputFile.toFile()); - info.setLibraries(srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + List libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()); + libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + info.setLibraries(libs); Radon r = new Radon(info); r.run(); return outputFile; From 39cbfb0e331161ec5fd0b7c4ff11b767a5d953e3 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 20:04:26 +0300 Subject: [PATCH 20/28] =?UTF-8?q?[FIX]=20=D0=A0=D0=B0=D0=B1=D0=BE=D1=87?= =?UTF-8?q?=D0=B8=D0=B9=20=D1=80=D0=B0=D0=B4=D0=BE=D0=BD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 3 ++- .../java/ru/gravit/launchserver/binary/JARLauncherBinary.java | 2 +- .../main/resources/ru/gravit/launchserver/defaults/radon.cfg | 2 +- Radon | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 0d419c1a..48d79a43 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -72,6 +72,7 @@ bundle project(':Radon') } compileOnlyA 'com.google.guava:guava:26.0-jre' + compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2' } task hikari(type: Copy) { @@ -106,7 +107,7 @@ task launch4jA(type: Copy) { } else { fcp.exclude() } - } + } } task dumpLibs(type: Copy) { 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 25205ea0..b5c79351 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -44,9 +44,9 @@ public void init() { tasks.add(new PrepareBuildTask(server)); tasks.add(new MainBuildTask(server)); tasks.add(new ProGuardBuildTask(server)); + tasks.add(new AdditionalFixesApplyTask(server)); tasks.add(new RadonBuildTask(server)); tasks.add(new AttachJarsTask(server)); - tasks.add(new AdditionalFixesApplyTask(server)); } @Override diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index 58af0e3b..ba6db149 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -2,7 +2,7 @@ StringEncryption: Enabled: true Mode: Heavy StringPool: false -InvokeDynamic: Heavy +InvokeDynamic: Normal NumberObfuscation: Heavy FlowObfuscation: Heavy HideCode: true diff --git a/Radon b/Radon index 9ad5210d..b48dd653 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit 9ad5210d821a5fcc072dae9f8e24ef37c8544757 +Subproject commit b48dd653f2930da7575cffe5fdd2516c9fea4353 From 4e26d85fe54e84b6b7ca5d946f03cfab769519fb Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 20:07:50 +0300 Subject: [PATCH 21/28] =?UTF-8?q?[FIX]=20=D0=A1=D0=BA=D1=80=D0=B8=D0=BF?= =?UTF-8?q?=D1=82=D1=8B=20gradle.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 8 +++++++- .../resources/ru/gravit/launchserver/defaults/radon.cfg | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 48d79a43..b9527cca 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -131,4 +131,10 @@ destinationDir file("$buildDir") from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' } } -build.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.bundle +task dumpClientLibs(type: Copy) { + dependsOn parent.childProjects.Launcher.tasks.build + into "$buildDir/libs/launcher-libraries" + from parent.childProjects.Launcher.tasks.dumpLibs.destinationDir +} + +build.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.dumpClientLibs, tasks.bundle diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index ba6db149..6bbc4674 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -18,4 +18,4 @@ Watermarker: Message: "This copy belongs to GravitLauncher" Key: "SuperSecureKey" Dictionary: Spaces -TrashClasses: 200 \ No newline at end of file +TrashClasses: 20000 \ No newline at end of file From f20816b9a2e7e9d1bb64e2044c8aa3f553217ec7 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 20:13:49 +0300 Subject: [PATCH 22/28] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/ru/gravit/launchserver/defaults/radon.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index 6bbc4674..d8d6b9ab 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -18,4 +18,4 @@ Watermarker: Message: "This copy belongs to GravitLauncher" Key: "SuperSecureKey" Dictionary: Spaces -TrashClasses: 20000 \ No newline at end of file +TrashClasses: 1000 \ No newline at end of file From 8ed337d70945578c5d5126fbef70278c35669e5a Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 20:55:34 +0300 Subject: [PATCH 23/28] =?UTF-8?q?[FIX]=20=D0=92=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B8=D1=82=D1=8C=20Radon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 2 ++ .../binary/tasks/RadonBuildTask.java | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 5cfec95d..82dedaea 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -120,6 +120,7 @@ public static final class Config { public boolean isWarningMissArchJava; public boolean enabledProGuard; + public boolean enabledRadon; public boolean stripLineNumbers; public boolean deleteTempFiles; public boolean enableRcon; @@ -641,6 +642,7 @@ private void generateConfigIfNotExists() throws IOException { newConfig.threadCoreCount = 0; // on your own newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); + newConfig.enabledRadon = true; newConfig.enabledProGuard = true; newConfig.stripLineNumbers = true; newConfig.deleteTempFiles = true; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java index ddba3c90..c7ab1468 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -31,17 +31,20 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { - if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); - Path outputFile = srv.launcherBinary.nextLowerPath(this); - ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); - SessionInfo info = p.createSessionFromConfig(); - info.setInput(inputFile.toFile()); - info.setOutput(outputFile.toFile()); - List libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()); - libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); - info.setLibraries(libs); - Radon r = new Radon(info); - r.run(); + Path outputFile = srv.launcherBinary.nextLowerPath(this); + if (srv.config.enabledRadon) { + if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); + ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); + SessionInfo info = p.createSessionFromConfig(); + info.setInput(inputFile.toFile()); + info.setOutput(outputFile.toFile()); + List libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()); + libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + info.setLibraries(libs); + Radon r = new Radon(info); + r.run(); + } else + IOHelper.copy(inputFile, outputFile); return outputFile; } From 0268a48fe6e1fae982652000e29e04237884083e Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 16 Mar 2019 00:59:17 +0700 Subject: [PATCH 24/28] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B5=20=D1=81=D0=BE=D0=B5=D0=B4=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/handler/MySQLAuthHandler.java | 13 +++++---- .../auth/hwid/MysqlHWIDHandler.java | 29 +++++++++---------- .../auth/provider/MySQLAuthProvider.java | 21 +++++++++----- 3 files changed, 33 insertions(+), 30 deletions(-) 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 a98811e3..345bd489 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 @@ -4,6 +4,7 @@ import ru.gravit.utils.helper.LogHelper; import java.io.IOException; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -64,8 +65,8 @@ protected Entry fetchEntry(UUID uuid) throws IOException { } private Entry query(String sql, String value) throws IOException { - try { - PreparedStatement s = mySQLHolder.getConnection().prepareStatement(sql); + try(Connection c = mySQLHolder.getConnection()) { + PreparedStatement s = c.prepareStatement(sql); s.setString(1, value); s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); try (ResultSet set = s.executeQuery()) { @@ -78,8 +79,8 @@ private Entry query(String sql, String value) throws IOException { @Override protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException { - try { - PreparedStatement s = mySQLHolder.getConnection().prepareStatement(updateAuthSQL); + try(Connection c = mySQLHolder.getConnection()) { + PreparedStatement s = c.prepareStatement(updateAuthSQL); s.setString(1, username); // Username case s.setString(2, accessToken); s.setString(3, uuid.toString()); @@ -92,8 +93,8 @@ protected boolean updateAuth(UUID uuid, String username, String accessToken) thr @Override protected boolean updateServerID(UUID uuid, String serverID) throws IOException { - try { - PreparedStatement s = mySQLHolder.getConnection().prepareStatement(updateServerIDSQL); + try(Connection c = mySQLHolder.getConnection()) { + PreparedStatement s = c.prepareStatement(updateServerIDSQL); s.setString(1, serverID); s.setString(2, uuid.toString()); s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); 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 8eb46a41..1201815b 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 @@ -63,8 +63,7 @@ public class MysqlHWIDHandler extends HWIDHandler { public void check0(HWID hwid, String username) throws HWIDException { if (hwid instanceof OshiHWID) { OshiHWID oshiHWID = (OshiHWID) hwid; - try { - Connection c = mySQLHolder.getConnection(); + try(Connection c = mySQLHolder.getConnection()) { PreparedStatement s = c.prepareStatement(String.format("SELECT %s, %s FROM `%s` WHERE `%s` = ? LIMIT 1", userFieldHwid, userFieldLogin, tableUsers, userFieldLogin)); @@ -178,22 +177,21 @@ public void setIsBanned(HWID hwid, boolean isBanned) { LogHelper.debug("%s Request HWID: %s", isBanned ? "Ban" : "UnBan", hwid.toString()); if (hwid instanceof OshiHWID) { OshiHWID oshiHWID = (OshiHWID) hwid; - Connection c = null; - try { - c = mySQLHolder.getConnection(); - } catch (SQLException e) { - e.printStackTrace(); - } - try (PreparedStatement a = c.prepareStatement(queryBan)) { - String[] replaceParamsUpd = {"totalMemory", String.valueOf(oshiHWID.totalMemory), "serialNumber", oshiHWID.serialNumber, "HWDiskSerial", oshiHWID.HWDiskSerial, "processorID", oshiHWID.processorID, "isBanned", isBanned ? "1" : "0"}; - for (int i = 0; i < paramsBan.length; i++) { - a.setString(i + 1, CommonHelper.replace(paramsBan[i], replaceParamsUpd)); + try(Connection c = mySQLHolder.getConnection()) { + try (PreparedStatement a = c.prepareStatement(queryBan)) { + String[] replaceParamsUpd = {"totalMemory", String.valueOf(oshiHWID.totalMemory), "serialNumber", oshiHWID.serialNumber, "HWDiskSerial", oshiHWID.HWDiskSerial, "processorID", oshiHWID.processorID, "isBanned", isBanned ? "1" : "0"}; + for (int i = 0; i < paramsBan.length; i++) { + a.setString(i + 1, CommonHelper.replace(paramsBan[i], replaceParamsUpd)); + } + a.setQueryTimeout(MySQLSourceConfig.TIMEOUT); + a.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); } - a.setQueryTimeout(MySQLSourceConfig.TIMEOUT); - a.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } + } } @@ -214,9 +212,8 @@ public void unban(List list) { @Override public List getHwid(String username) { ArrayList list = new ArrayList<>(); - try { + try(Connection c = mySQLHolder.getConnection()) { LogHelper.debug("Try find HWID from username %s", username); - Connection c = mySQLHolder.getConnection(); PreparedStatement s = c.prepareStatement(String.format("SELECT %s, %s FROM `%s` WHERE `%s` = ? LIMIT 1", userFieldHwid, userFieldLogin, tableUsers, userFieldLogin)); s.setString(1, username); 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 3a3c5cfa..0f578583 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 @@ -8,6 +8,7 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -28,16 +29,20 @@ public void init() { @Override public AuthProviderResult auth(String login, String password, String ip) throws SQLException, AuthException { - PreparedStatement s = mySQLHolder.getConnection().prepareStatement(query); - String[] replaceParams = {"login", login, "password", password, "ip", ip}; - for (int i = 0; i < queryParams.length; i++) - s.setString(i + 1, CommonHelper.replace(queryParams[i], replaceParams)); + try(Connection c = mySQLHolder.getConnection()) + { + PreparedStatement s = c.prepareStatement(query); + String[] replaceParams = {"login", login, "password", password, "ip", ip}; + for (int i = 0; i < queryParams.length; i++) + s.setString(i + 1, CommonHelper.replace(queryParams[i], replaceParams)); - // Execute SQL query - s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); - try (ResultSet set = s.executeQuery()) { - return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : LaunchServer.server.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message); + // Execute SQL query + s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); + try (ResultSet set = s.executeQuery()) { + return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : LaunchServer.server.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message); + } } + } @Override From 3a6e6f32d8ab84d50c90966d49b1a82079005045 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 16 Mar 2019 01:47:47 +0700 Subject: [PATCH 25/28] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20NPE=20?= =?UTF-8?q?=D0=B2=20AuthLimiter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/components/AuthLimiterComponent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java b/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java index 7c5a9bb9..907817e3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/components/AuthLimiterComponent.java @@ -82,8 +82,8 @@ public String toString() { public int rateLimitMilis; public String message; - public transient HashMap map; - public List excludeIps; + public transient HashMap map = new HashMap<>(); + public List excludeIps = new ArrayList<>(); @Override public void garbageCollection() { From bacf51b4436d1f94868337ceda392b3ac5a4807c Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Fri, 15 Mar 2019 21:54:31 +0300 Subject: [PATCH 26/28] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=B0=D0=B2=D1=82=D0=BE=D1=81=D0=B3=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/ru/gravit/launchserver/defaults/radon.cfg | 2 +- Radon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index d8d6b9ab..4c681165 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -2,7 +2,7 @@ StringEncryption: Enabled: true Mode: Heavy StringPool: false -InvokeDynamic: Normal +InvokeDynamic: None NumberObfuscation: Heavy FlowObfuscation: Heavy HideCode: true diff --git a/Radon b/Radon index b48dd653..e1f7548f 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit b48dd653f2930da7575cffe5fdd2516c9fea4353 +Subproject commit e1f7548f97132fa29b01f68bd57ffab32de7b6e7 From f522f5014cb71f6277f113e1d1a79b73cd3211ae Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Mar 2019 14:34:29 +0300 Subject: [PATCH 27/28] =?UTF-8?q?[FIX]=20Radon=20=D1=83=D1=81=D0=BF=D0=B5?= =?UTF-8?q?=D1=88=D0=BD=D0=BE=20=D0=BE=D0=B1=D1=84=D1=83=D1=81=D1=86=D0=B8?= =?UTF-8?q?=D1=80=D1=83=D0=B5=D1=82=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87=D0=B5?= =?UTF-8?q?=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/defaults/radon.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg index 4c681165..539eb775 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg @@ -1,11 +1,11 @@ StringEncryption: Enabled: true - Mode: Heavy + Mode: Normal StringPool: false InvokeDynamic: None -NumberObfuscation: Heavy -FlowObfuscation: Heavy -HideCode: true +NumberObfuscation: Normal +FlowObfuscation: Normal +HideCode: false Shuffler: true Crasher: false Optimizer: @@ -18,4 +18,4 @@ Watermarker: Message: "This copy belongs to GravitLauncher" Key: "SuperSecureKey" Dictionary: Spaces -TrashClasses: 1000 \ No newline at end of file +TrashClasses: 500 \ No newline at end of file From 64942b985244cb0ede59ea0576c5a9fdceae4574 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Mar 2019 14:41:43 +0300 Subject: [PATCH 28/28] =?UTF-8?q?[FIX]=20=D0=9E=D0=BF=D0=B5=D1=87=D0=B0?= =?UTF-8?q?=D1=82=D0=BA=D0=B8=20=D0=B2=20ProGuardBuildTask.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/binary/tasks/ProGuardBuildTask.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java index ce086579..efeae198 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java @@ -25,8 +25,8 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { + Path outputJar = server.launcherBinary.nextLowerPath(this); if (server.config.enabledProGuard) { - Path outputJar = server.launcherBinary.nextLowerPath(this); Configuration proguard_cfg = new Configuration(); ConfigurationParser parser = new ConfigurationParser(server.proguardConf.buildConfig(inputFile, outputJar), server.proguardConf.proguard.toFile(), System.getProperties()); @@ -37,12 +37,9 @@ public Path process(Path inputFile) throws IOException { } catch (ParseException e) { LogHelper.error(e); } - return outputJar; - } else { - Path outputJar = server.launcherBinary.nextPath("non-obf"); + } else IOHelper.copy(inputFile, outputJar); - return outputJar; - } + return outputJar; } @Override