diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/CheckServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/CheckServerResponse.java index c615542d..b9c2e051 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/CheckServerResponse.java @@ -1,7 +1,7 @@ package ru.gravit.launchserver.socket.websocket.json.auth; import io.netty.channel.ChannelHandlerContext; -import ru.gravit.launcher.events.request.CheckServerEvent; +import ru.gravit.launcher.events.request.CheckServerRequestEvent; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse; @@ -22,7 +22,7 @@ public String getType() { @Override public void execute(WebSocketService service, ChannelHandlerContext ctx, Client pClient) { - CheckServerEvent result = new CheckServerEvent(); + CheckServerRequestEvent result = new CheckServerRequestEvent(); try { result.uuid = LaunchServer.server.config.authHandler.checkServer(username, serverID); if(result.uuid != null) @@ -35,7 +35,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client service.sendObject(ctx, new WebSocketService.ErrorResult("Internal authHandler error")); return; } - service.sendObject(ctx, new CheckServerEvent()); + service.sendObject(ctx, new CheckServerRequestEvent()); } } diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg index 3c081430..9d82a488 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg @@ -31,6 +31,11 @@ ; } +-keepclassmembers @ru.gravit.launcher.LauncherNetworkAPI class ** { + ; + ; +} + -keepclassmembers class ** { @ru.gravit.launcher.LauncherAPI ; @@ -38,6 +43,13 @@ ; } +-keepclassmembers class ** { + @ru.gravit.launcher.LauncherNetworkAPI + ; + @ru.gravit.launcher.LauncherNetworkAPI + ; +} + -keepclassmembers public class ** { public static void main(java.lang.String[]); public static void premain(java.lang.String, java.lang.instrument.Instrumentation); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java index 80b214ba..fe6ed565 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java @@ -3,7 +3,7 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.events.request.CheckServerEvent; +import ru.gravit.launcher.events.request.CheckServerRequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; @@ -15,7 +15,7 @@ import java.io.IOException; -public final class CheckServerRequest extends Request { +public final class CheckServerRequest extends Request { private final String username; private final String serverID; @@ -37,7 +37,7 @@ public Integer getType() { } @Override - protected CheckServerEvent requestDo(HInput input, HOutput output) throws IOException { + protected CheckServerRequestEvent requestDo(HInput input, HOutput output) throws IOException { output.writeString(username, SerializeLimits.MAX_LOGIN); output.writeASCII(serverID, SerializeLimits.MAX_SERVERID); // 1 char for minus sign if (Launcher.profile == null) { @@ -49,6 +49,6 @@ protected CheckServerEvent requestDo(HInput input, HOutput output) throws IOExce // Read response readError(input); - return input.readBoolean() ? new CheckServerEvent(new PlayerProfile(input)) : null; + return input.readBoolean() ? new CheckServerRequestEvent(new PlayerProfile(input)) : null; } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 35c66cb3..8c90bd2b 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -6,13 +6,11 @@ import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedEntryAdapter; import ru.gravit.launcher.request.ResultInterface; -import ru.gravit.launcher.request.auth.JoinServerRequest; import ru.gravit.utils.helper.LogHelper; import java.io.IOException; import java.lang.reflect.Type; import java.net.URI; -import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -80,7 +78,7 @@ public void registerResult(String key, Class clazz) { public void registerResults() { registerResult("echo", EchoRequestEvent.class); registerResult("auth", AuthRequestEvent.class); - registerResult("checkServer", CheckServerEvent.class); + registerResult("checkServer", CheckServerRequestEvent.class); registerResult("joinServer", JoinServerRequestEvent.class); registerResult("launcher", LauncherRequestEvent.class); registerResult("profileByUsername", ProfileByUsernameRequestEvent.class); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherNetworkAPI.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherNetworkAPI.java new file mode 100644 index 00000000..52eacc8a --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherNetworkAPI.java @@ -0,0 +1,11 @@ +package ru.gravit.launcher; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD}) +public @interface LauncherNetworkAPI { +} 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 c8c05a2e..a61a0a18 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 @@ -1,6 +1,7 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.ClientPermissions; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -11,10 +12,13 @@ public class AuthRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74"); public AuthRequestEvent() { } - + @LauncherNetworkAPI public String error; + @LauncherNetworkAPI public ClientPermissions permissions; + @LauncherNetworkAPI public PlayerProfile playerProfile; + @LauncherNetworkAPI public String accessToken; public AuthRequestEvent(PlayerProfile pp, String accessToken, ClientPermissions permissions) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java index 0b105b20..5ea87990 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -9,7 +10,9 @@ public class BatchProfileByUsernameRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3"); + @LauncherNetworkAPI public String error; + @LauncherNetworkAPI public PlayerProfile[] playerProfiles; public BatchProfileByUsernameRequestEvent(PlayerProfile[] profiles) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java similarity index 67% rename from libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerEvent.java rename to libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java index e35b2467..cbe1bd21 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java @@ -1,22 +1,24 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class CheckServerEvent implements EventInterface, ResultInterface { +public class CheckServerRequestEvent implements EventInterface, ResultInterface { private static final UUID _uuid = UUID.fromString("8801d07c-51ba-4059-b61d-fe1f1510b28a"); - public String type = "success"; + @LauncherNetworkAPI public UUID uuid; + @LauncherNetworkAPI public PlayerProfile playerProfile; - public CheckServerEvent(PlayerProfile playerProfile) { + public CheckServerRequestEvent(PlayerProfile playerProfile) { this.playerProfile = playerProfile; } - public CheckServerEvent() { + public CheckServerRequestEvent() { } @Override diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java index fecca598..3395d32a 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -7,6 +8,7 @@ public class EchoRequestEvent implements ResultInterface, EventInterface { private static final UUID uuid = UUID.fromString("0a1f820f-7cd5-47a5-ae0e-17492e0e1fe1"); + @LauncherNetworkAPI public String echo; public EchoRequestEvent(String echo) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java index 3a76863c..ae3948d2 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java @@ -7,7 +7,6 @@ public class JoinServerRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("2a12e7b5-3f4a-4891-a2f9-ea141c8e1995"); - public String type = "success"; public JoinServerRequestEvent(boolean allow) { this.allow = allow; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java index 55f37ed2..440a636c 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -7,7 +8,7 @@ public class LauncherRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("d54cc12a-4f59-4f23-9b10-f527fdd2e38f"); - public String type = "success"; + @LauncherNetworkAPI public String url; public LauncherRequestEvent(boolean needUpdate, String url) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java index b726696f..c68a0bc5 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -9,7 +10,9 @@ public class ProfileByUUIDRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0"); + @LauncherNetworkAPI public String error; + @LauncherNetworkAPI public PlayerProfile playerProfile; public ProfileByUUIDRequestEvent(PlayerProfile playerProfile) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java index a3906825..bda26360 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -9,7 +10,9 @@ public class ProfileByUsernameRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1"); + @LauncherNetworkAPI public String error; + @LauncherNetworkAPI public PlayerProfile playerProfile; public ProfileByUsernameRequestEvent(PlayerProfile playerProfile) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java index 21936936..6ce432b1 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -10,6 +11,7 @@ public class ProfilesRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1"); + @LauncherNetworkAPI public List profiles; public ProfilesRequestEvent(List profiles) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java index 73136430..fa51be8b 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -8,7 +9,9 @@ public class UpdateListRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b"); + @LauncherNetworkAPI public final String type; + @LauncherNetworkAPI public final HashedDir dir; public UpdateListRequestEvent(HashedDir dir) {