From a3800958dbc1ef334c73bf8741a093f2095d9b57 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 17 Feb 2020 08:51:59 +0700 Subject: [PATCH] [FIX] ConnectionTypes.SERVER deprecated --- .../gravit/launchserver/manangers/SessionManager.java | 3 +-- .../launchserver/socket/response/auth/AuthResponse.java | 9 ++++----- .../socket/response/auth/CheckServerResponse.java | 5 +++++ .../socket/response/auth/JoinServerResponse.java | 5 +++++ .../pro/gravit/launcher/request/auth/AuthRequest.java | 5 ++--- .../java/pro/gravit/launcher/server/ServerWrapper.java | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java index 55b860f1..2601c110 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java @@ -14,7 +14,6 @@ public class SessionManager implements NeedGarbageCollection { public static final long SESSION_TIMEOUT = 3 * 60 * 60 * 1000; // 3 часа - public static final boolean GARBAGE_SERVER = Boolean.parseBoolean(System.getProperty("launcher.garbageSessionsServer", "false")); private final Map clientSet = new HashMap<>(128); @@ -28,7 +27,7 @@ public void garbageCollection() { long time = System.currentTimeMillis(); clientSet.entrySet().removeIf(entry -> { Client c = entry.getValue(); - return (c.timestamp + SESSION_TIMEOUT < time) && ((c.type == AuthResponse.ConnectTypes.CLIENT) || ((c.type == AuthResponse.ConnectTypes.SERVER) && GARBAGE_SERVER)); + return (c.timestamp + SESSION_TIMEOUT < time); }); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index 31832e91..0b454744 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -42,7 +42,10 @@ public class AuthResponse extends SimpleResponse { public HWID hwid; public enum ConnectTypes { - SERVER, CLIENT, API + @Deprecated + SERVER, + CLIENT, + API } @Override @@ -109,10 +112,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti clientData.username = login; result.accessToken = aresult.accessToken; result.permissions = clientData.permissions; - if (authType == ConnectTypes.SERVER && !clientData.permissions.canServer) { - AuthProvider.authError("authType: SERVER not allowed for this account"); - return; - } if (getSession) { if (clientData.session == 0) { clientData.session = random.nextLong(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java index bd49d359..a7b1baee 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java @@ -21,6 +21,11 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client pClient) { + if(!pClient.isAuth || pClient.type == AuthResponse.ConnectTypes.CLIENT) + { + sendError("Permissions denied"); + return; + } CheckServerRequestEvent result = new CheckServerRequestEvent(); try { server.authHookManager.checkServerHook.hook(this, pClient); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java index 685e3c66..a577c3b0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java @@ -20,6 +20,11 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) { + if(!client.isAuth || client.type != AuthResponse.ConnectTypes.CLIENT) + { + sendError("Permissions denied"); + return; + } boolean success; try { server.authHookManager.joinServerHook.hook(this, client); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index 2d311294..5ce3bc78 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -35,14 +35,13 @@ public interface AuthPasswordInterface { public boolean initProxy; public enum ConnectTypes { + @Deprecated @LauncherNetworkAPI SERVER, @LauncherNetworkAPI CLIENT, @LauncherNetworkAPI - BOT, - @LauncherNetworkAPI - PROXY + API } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 6093920d..59a37e42 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -53,7 +53,7 @@ public ServerWrapper(Type type, Path configPath) { public boolean auth() { try { Launcher.getConfig(); - AuthRequest request = new AuthRequest(config.login, config.password, config.auth_id, AuthRequest.ConnectTypes.SERVER); + AuthRequest request = new AuthRequest(config.login, config.password, config.auth_id, AuthRequest.ConnectTypes.API); permissions = request.request().permissions; ProfilesRequestEvent result = new ProfilesRequest().request(); for (ClientProfile p : result.profiles) {