From 8a51c98df80ebaff71f49130e9bec8cbd5c4ac24 Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 11 Apr 2022 19:28:47 +0700 Subject: [PATCH] [ANY] Remove deprecated --- .../pro/gravit/launchserver/LaunchServer.java | 5 - .../command/handler/CommandHandler.java | 1 - .../command/service/ClientsCommand.java | 4 +- .../command/service/PingServersCommand.java | 38 ------- .../launchserver/manangers/AuthManager.java | 19 ++-- .../manangers/PingServerManager.java | 61 ----------- .../gravit/launchserver/socket/Client.java | 15 +-- .../launchserver/socket/WebSocketService.java | 5 - .../handlers/WebSocketFrameHandler.java | 4 +- .../response/auth/AdditionalDataResponse.java | 4 +- .../socket/response/auth/AuthResponse.java | 7 -- .../socket/response/auth/ExitResponse.java | 36 +------ .../response/auth/RestoreSessionResponse.java | 2 - .../management/PingServerReportResponse.java | 28 ----- .../management/PingServerResponse.java | 43 -------- .../client/ClientLauncherProcess.java | 22 +--- .../gravit/launcher/ClientPermissions.java | 101 +----------------- .../launcher/events/ExceptionEvent.java | 21 ---- .../pro/gravit/launcher/events/PingEvent.java | 7 -- .../gravit/launcher/events/SignalEvent.java | 20 ---- .../launcher/events/request/LogEvent.java | 19 ---- .../request/PingServerReportRequestEvent.java | 11 -- .../request/PingServerRequestEvent.java | 23 ---- .../events/request/RegisterRequestEvent.java | 11 -- .../request/RestoreSessionRequestEvent.java | 20 ---- .../pro/gravit/launcher/request/Request.java | 2 - .../request/auth/RestoreSessionRequest.java | 29 ----- .../management/PingServerReportRequest.java | 44 -------- .../request/management/PingServerRequest.java | 28 ----- .../websockets/ClientWebSocketService.java | 9 -- .../websockets/StdWebSocketService.java | 4 - .../pro/gravit/utils/helper/JVMHelper.java | 1 - modules | 2 +- 33 files changed, 22 insertions(+), 624 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerResponse.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/ExceptionEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerReportRequestEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerRequestEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RestoreSessionRequestEvent.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerReportRequest.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerRequest.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 902c846e..968ffaee 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -100,8 +100,6 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab public final AuthManager authManager; public final ReconfigurableManager reconfigurableManager; public final ConfigManager configManager; - @Deprecated - public final PingServerManager pingServerManager; public final FeaturesManager featuresManager; public final KeyAgreementManager keyAgreementManager; public final UpdatesManager updatesManager; @@ -153,7 +151,6 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La reconfigurableManager = new ReconfigurableManager(); authHookManager = new AuthHookManager(); configManager = new ConfigManager(); - pingServerManager = new PingServerManager(this); featuresManager = new FeaturesManager(this); authManager = new AuthManager(this); updatesManager = new UpdatesManager(this); @@ -377,8 +374,6 @@ public void syncProfilesDir() throws IOException { // Sort and set new profiles newProfies.sort(Comparator.comparing(a -> a)); profilesList = Set.copyOf(newProfies); - if (pingServerManager != null) - pingServerManager.syncServers(); } public void syncUpdatesDir(Collection dirs) throws IOException { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index e794977d..99e1add5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -57,7 +57,6 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand service.registerCommand("clients", new ClientsCommand(server)); service.registerCommand("signJar", new SignJarCommand(server)); service.registerCommand("signDir", new SignDirCommand(server)); - service.registerCommand("pingServers", new PingServersCommand(server)); service.registerCommand("securitycheck", new SecurityCheckCommand(server)); service.registerCommand("token", new TokenCommand(server)); Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java index 74a32934..13374574 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java @@ -43,8 +43,8 @@ public void invoke(String... args) { logger.info("Channel {} | connectUUID {} | checkSign {}", ip, frameHandler.getConnectUUID(), client.checkSign ? "true" : "false"); else { logger.info("Client name {} | ip {} | connectUUID {}", client.username == null ? "null" : client.username, ip, frameHandler.getConnectUUID()); - logger.info("userUUID: {} | session {}", client.uuid == null ? "null" : client.uuid.toString(), client.session == null ? "null" : client.session); - logger.info("OAuth {} | session {}", client.useOAuth, client.sessionObject == null ? "null" : client.sessionObject); + logger.info("userUUID: {}", client.uuid == null ? "null" : client.uuid.toString()); + logger.info("OAuth session {}", client.sessionObject == null ? "null" : client.sessionObject); logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false", client.auth_id); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java deleted file mode 100644 index 368c71de..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import pro.gravit.launcher.request.management.PingServerReportRequest; -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; - -@Deprecated -public class PingServersCommand extends Command { - private transient final Logger logger = LogManager.getLogger(); - - public PingServersCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return "[]"; - } - - @Override - public String getUsageDescription() { - return "show modern pings status"; - } - - @Override - public void invoke(String... args) { - server.pingServerManager.map.forEach((name, data) -> { - logger.info("[{}] online {} / {}", name, data.lastReport == null ? -1 : data.lastReport.playersOnline, data.lastReport == null ? -1 : data.lastReport.maxPlayers); - if (data.lastReport != null && data.lastReport.users != null) { - for (PingServerReportRequest.PingServerReport.UsernameInfo user : data.lastReport.users) { - logger.info("User {}", user.username == null ? "null" : user.username); - } - } - }); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java index a419b494..e751e2d4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java @@ -179,7 +179,6 @@ public void internalAuth(Client client, AuthResponse.ConnectTypes authType, Auth client.username = username; client.type = authType; client.uuid = uuid; - client.useOAuth = true; } public CheckServerReport checkServer(Client client, String username, String serverID) throws IOException { @@ -197,19 +196,17 @@ public boolean joinServer(Client client, String username, String accessToken, St public PlayerProfile getPlayerProfile(Client client) { if (client.auth == null) return null; PlayerProfile playerProfile; - if (client.useOAuth) { - User user = client.getUser(); - if (user == null) { - return null; - } - playerProfile = getPlayerProfile(client.auth, user); - if (playerProfile != null) return playerProfile; + User user = client.getUser(); + if (user == null) { + return null; } + playerProfile = getPlayerProfile(client.auth, user); + if (playerProfile != null) return playerProfile; if (client.auth.textureProvider != null) { return getPlayerProfile(client.uuid, client.username, client.profile == null ? null : client.profile.getTitle(), client.auth.textureProvider, new HashMap<>()); } // Return combined profile - return new PlayerProfile(client.uuid, client.username, null, null, new HashMap<>()); + return new PlayerProfile(client.uuid, client.username, new HashMap<>(), new HashMap<>()); } public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username) { @@ -231,7 +228,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username, Cl if (pair.textureProvider != null) { return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>()); } - return new PlayerProfile(uuid, username, null, null, new HashMap<>()); + return new PlayerProfile(uuid, username, new HashMap<>(), new HashMap<>()); } public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid) { @@ -253,7 +250,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr if (pair.textureProvider != null) { return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>()); } - return new PlayerProfile(uuid, username, null, null, new HashMap<>()); + return new PlayerProfile(uuid, username, new HashMap<>(), new HashMap<>()); } public PlayerProfile getPlayerProfile(AuthProviderPair pair, User user) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java deleted file mode 100644 index 624d40e0..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java +++ /dev/null @@ -1,61 +0,0 @@ -package pro.gravit.launchserver.manangers; - -import pro.gravit.launcher.profiles.ClientProfile; -import pro.gravit.launcher.request.management.PingServerReportRequest; -import pro.gravit.launchserver.LaunchServer; - -import java.util.HashMap; -import java.util.Map; - -@Deprecated -public class PingServerManager { - public static final long REPORT_EXPIRED_TIME = 20 * 1000; - public final Map map = new HashMap<>(); - private final LaunchServer server; - - public PingServerManager(LaunchServer server) { - this.server = server; - } - - public void syncServers() { - server.getProfiles().forEach((p) -> { - for (ClientProfile.ServerProfile sp : p.getServers()) { - ServerInfoEntry entry = map.get(sp.name); - if (entry == null) { - map.put(sp.name, new ServerInfoEntry(p)); - } - } - }); - } - - public boolean updateServer(String name, PingServerReportRequest.PingServerReport report) { - ServerInfoEntry entry = map.get(name); - if (entry == null) - return false; - else { - entry.lastReportTime = System.currentTimeMillis(); - entry.lastReport = report; - return true; - } - } - - public static class ServerInfoEntry { - public final ClientProfile profile; - public PingServerReportRequest.PingServerReport lastReport; - public long lastReportTime; - - public ServerInfoEntry(ClientProfile profile, PingServerReportRequest.PingServerReport lastReport) { - this.lastReport = lastReport; - this.profile = profile; - this.lastReportTime = System.currentTimeMillis(); - } - - public ServerInfoEntry(ClientProfile profile) { - this.profile = profile; - } - - public boolean isExpired() { - return System.currentTimeMillis() - lastReportTime > REPORT_EXPIRED_TIME; - } - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java index b15a6c43..191baa52 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java @@ -13,10 +13,6 @@ import java.util.concurrent.atomic.AtomicInteger; public class Client { - @Deprecated - public UUID session; - @Deprecated - public boolean useOAuth; // Always true public String auth_id; public long timestamp; public AuthResponse.ConnectTypes type; @@ -38,16 +34,7 @@ public class Client { public Map serializableProperties; - @Deprecated - public transient AtomicInteger refCount; - - public Client(UUID session) { - this(session, 1); - } - - public Client(UUID session, int initialRefCount) { - refCount = new AtomicInteger(initialRefCount); - this.session = session; + public Client() { timestamp = System.currentTimeMillis(); type = null; isAuth = false; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 32d252e9..113d02bb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -10,7 +10,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import pro.gravit.launcher.Launcher; -import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.ExitRequestEvent; @@ -21,8 +20,6 @@ import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.launchserver.socket.response.auth.*; import pro.gravit.launchserver.socket.response.management.FeaturesResponse; -import pro.gravit.launchserver.socket.response.management.PingServerReportResponse; -import pro.gravit.launchserver.socket.response.management.PingServerResponse; import pro.gravit.launchserver.socket.response.management.ServerStatusResponse; import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; @@ -86,8 +83,6 @@ public static void registerResponses() { providers.register("securityReport", SecurityReportResponse.class); providers.register("hardwareReport", HardwareReportResponse.class); providers.register("serverStatus", ServerStatusResponse.class); - providers.register("pingServerReport", PingServerReportResponse.class); - providers.register("pingServer", PingServerResponse.class); providers.register("currentUser", CurrentUserResponse.class); providers.register("features", FeaturesResponse.class); providers.register("refreshToken", RefreshTokenResponse.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java index 17d4e723..ea9eb7b0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java @@ -39,9 +39,7 @@ public Client getClient() { } public void setClient(Client client) { - if (this.client != null) this.client.refCount.decrementAndGet(); this.client = client; - if (client != null) client.refCount.incrementAndGet(); } public final UUID getConnectUUID() { @@ -51,7 +49,7 @@ public final UUID getConnectUUID() { @Override public void channelActive(ChannelHandlerContext ctx) { logger.trace("New client {}", IOHelper.getIP(ctx.channel().remoteAddress())); - client = new Client(null); + client = new Client(); Channel ch = ctx.channel(); service.registerClient(ch); future = ctx.executor().scheduleAtFixedRate(() -> ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()), 30L, 30L, TimeUnit.SECONDS); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AdditionalDataResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AdditionalDataResponse.java index 874e031c..03be4b45 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AdditionalDataResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AdditionalDataResponse.java @@ -33,7 +33,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { Map properties; User user = client.getUser(); if (user instanceof UserSupportAdditionalData userSupport) { - if (user.getPermissions().isPermission(ClientPermissions.PermissionConsts.ADMIN)) { + if (client.permissions.hasPerm("launchserver.request.addionaldata.privileged")) { properties = userSupport.getPropertiesMap(); } else { properties = userSupport.getPropertiesMapUnprivilegedSelf(); @@ -55,7 +55,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { return; } Map properties; - if (client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) { + if (client.permissions.hasPerm("launchserver.request.addionaldata.privileged")) { properties = userSupport.getPropertiesMap(); } else { properties = userSupport.getPropertiesMapUnprivileged(); 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 4e66c5da..7b30f651 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 @@ -18,7 +18,6 @@ public class AuthResponse extends SimpleResponse { private transient final Logger logger = LogManager.getLogger(); public String login; public String client; - public boolean getSession; public AuthRequest.AuthPasswordInterface password; @@ -49,12 +48,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti server.authHookManager.postHook.hook(context, clientData); if (context.report.isUsingOAuth()) { result.oauth = new AuthRequestEvent.OAuthRequestEvent(context.report.oauthAccessToken(), context.report.oauthRefreshToken(), context.report.oauthExpire()); - } else if (getSession) { - if (clientData.session == null) { - clientData.session = UUID.randomUUID(); - //server.sessionManager.addClient(clientData); - } - result.session = clientData.session; } if (context.report.minecraftAccessToken() != null) { result.accessToken = context.report.minecraftAccessToken(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ExitResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ExitResponse.java index 3ee1e1ed..3e7bc176 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ExitResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/ExitResponse.java @@ -18,12 +18,9 @@ public class ExitResponse extends SimpleResponse { public static void exit(LaunchServer server, WebSocketFrameHandler wsHandler, Channel channel, ExitRequestEvent.ExitReason reason) { Client chClient = wsHandler.getClient(); - Client newCusClient = new Client(null); + Client newCusClient = new Client(); newCusClient.checkSign = chClient.checkSign; wsHandler.setClient(newCusClient); - if (chClient.session != null) { - throw new UnsupportedOperationException("Legacy session system removed"); - } ExitRequestEvent event = new ExitRequestEvent(reason); event.requestUUID = RequestEvent.eventUUID; wsHandler.service.sendObject(channel, event); @@ -41,13 +38,13 @@ public void execute(ChannelHandlerContext ctx, Client client) { return; } if (username == null) { - if (client.useOAuth) { + { WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class); if (handler == null) { sendError("Exit internal error"); return; } - Client newClient = new Client(null, 0); + Client newClient = new Client(); newClient.checkSign = client.checkSign; handler.setClient(newClient); AuthSupportExit supportExit = client.auth.core.isSupport(AuthSupportExit.class); @@ -62,33 +59,6 @@ public void execute(ChannelHandlerContext ctx, Client client) { } } sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT)); - } else { - if (client.session == null && exitAll) { - sendError("Session invalid"); - return; - } - WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class); - if (handler == null) { - sendError("Exit internal error"); - return; - } - Client newClient = new Client(null); - newClient.checkSign = client.checkSign; - handler.setClient(newClient); - if (client.session != null) { - throw new UnsupportedOperationException("Legacy session system removed"); - } - if (exitAll) { - service.forEachActiveChannels(((channel, webSocketFrameHandler) -> { - Client client1 = webSocketFrameHandler.getClient(); - if (client.isAuth && client.username != null) { - if (!client1.isAuth || !client.username.equals(client1.username)) return; - } else { - if (client1.session != client.session) return; - } - exit(server, webSocketFrameHandler, channel, ExitRequestEvent.ExitReason.SERVER); - })); - } } sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT)); } else { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java index d7978c2d..ca314187 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java @@ -2,9 +2,7 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler; import pro.gravit.launchserver.socket.response.SimpleResponse; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java deleted file mode 100644 index 60ab706c..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -package pro.gravit.launchserver.socket.response.management; - -import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.events.request.PingServerReportRequestEvent; -import pro.gravit.launcher.request.management.PingServerReportRequest; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.SimpleResponse; - -@Deprecated -public class PingServerReportResponse extends SimpleResponse { - public PingServerReportRequest.PingServerReport data; - public String name; - - @Override - public String getType() { - return "pingServerReport"; - } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) { - if (!client.isAuth || client.permissions == null || !client.permissions.hasPerm("launchserver\\.management\\.pingserver")) { - sendError("Access denied"); - return; - } - server.pingServerManager.updateServer(name, data); - sendResult(new PingServerReportRequestEvent()); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerResponse.java deleted file mode 100644 index dfac108a..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -package pro.gravit.launchserver.socket.response.management; - -import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.events.request.PingServerRequestEvent; -import pro.gravit.launcher.request.management.PingServerReportRequest; -import pro.gravit.launchserver.auth.protect.interfaces.ProfilesProtectHandler; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.SimpleResponse; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Deprecated -public class PingServerResponse extends SimpleResponse { - public List serverNames; //May be null - - @Override - public String getType() { - return "pingServer"; - } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) { - Map map = new HashMap<>(); - if (serverNames == null) { - server.pingServerManager.map.forEach((name, entity) -> { - if (server.config.protectHandler instanceof ProfilesProtectHandler) { - if (!((ProfilesProtectHandler) server.config.protectHandler).canGetProfile(entity.profile, client)) { - return; - } - } - if (!entity.isExpired()) { - map.put(name, entity.lastReport); - } - }); - } else { - sendError("Not implemented"); - return; - } - sendResult(new PingServerRequestEvent(map)); - } -} diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index ecd35d1f..06aa81af 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -328,16 +328,7 @@ private void addModernClientArgs(Collection args) { if (version.compareTo(ClientProfile.Version.MC1710) >= 0) { // Add user properties Collections.addAll(args, "--userType", "mojang"); - ClientUserProperties properties = new ClientUserProperties(); - if (playerProfile.skin != null) { - properties.skinURL = new String[]{playerProfile.skin.url}; - properties.skinDigest = new String[]{SecurityHelper.toHex(playerProfile.skin.digest)}; - } - if (playerProfile.cloak != null) { - properties.cloakURL = new String[]{playerProfile.cloak.url}; - properties.cloakDigest = new String[]{SecurityHelper.toHex(playerProfile.cloak.digest)}; - } - Collections.addAll(args, "--userProperties", Launcher.gsonManager.gson.toJson(properties)); + Collections.addAll(args, "--userProperties", "{}"); // Add asset index Collections.addAll(args, "--assetIndex", profile.getAssetIndex()); @@ -371,16 +362,5 @@ private void addModernClientArgs(Collection args) { Collections.addAll(args, "--height", Integer.toString(height)); } } - - public static class ClientUserProperties { - @LauncherNetworkAPI - public String[] skinURL; - @LauncherNetworkAPI - public String[] skinDigest; - @LauncherNetworkAPI - public String[] cloakURL; - @LauncherNetworkAPI - public String[] cloakDigest; - } } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java index d590ffb6..a080c8ad 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java @@ -8,46 +8,27 @@ public class ClientPermissions { public static final ClientPermissions DEFAULT = new ClientPermissions(); @LauncherNetworkAPI - @Deprecated - public long permissions; - @LauncherNetworkAPI - @Deprecated - public long flags; - @LauncherNetworkAPI private List roles; @LauncherNetworkAPI private List perms; private transient List available; - public ClientPermissions(HInput input) throws IOException { - this(input.readLong()); - } - public ClientPermissions() { } - public ClientPermissions(long permissions) { - this.permissions = permissions; - } - - public ClientPermissions(long permissions, long flags) { - this.permissions = permissions; - this.flags = flags; + public ClientPermissions(List roles, List permissions) { + this.roles = new ArrayList<>(roles); + this.perms = new ArrayList<>(permissions); } public static ClientPermissions getSuperuserAccount() { ClientPermissions perm = new ClientPermissions(); - perm.setPermission(PermissionConsts.ADMIN, true); perm.addPerm("*"); return perm; } - public long toLong() { - return permissions; - } - public boolean hasRole(String role) { return roles != null && roles.contains(role); } @@ -64,12 +45,6 @@ public synchronized void compile() { for (String a : perms) { available.add(new PermissionPattern(a)); } - if (permissions != 0) { - if (isPermission(PermissionConsts.ADMIN)) { - roles.add("ADMIN"); - available.add(new PermissionPattern("*")); - } - } } public boolean hasPerm(String action) { @@ -121,52 +96,6 @@ public List getPerms() { return perms; } - //Read methods - @Deprecated - public final boolean isPermission(PermissionConsts con) { - return (permissions & con.mask) != 0; - } - - @Deprecated - public final boolean isPermission(long mask) { - return (permissions & mask) != 0; - } - - @Deprecated - public final boolean isFlag(FlagConsts con) { - return (flags & con.mask) != 0; - } - - @Deprecated - public final boolean isFlag(long mask) { - return (flags & mask) != 0; - } - - //Write methods - @Deprecated - public final void setPermission(PermissionConsts con, boolean value) { - if (value) this.permissions |= con.mask; - else this.permissions &= ~con.mask; - } - - @Deprecated - public final void setPermission(long mask, boolean value) { - if (value) this.permissions |= mask; - else this.permissions &= ~mask; - } - - @Deprecated - public final void setFlag(FlagConsts con, boolean value) { - if (value) this.flags |= con.mask; - else this.flags &= ~con.mask; - } - - @Deprecated - public final void setFlag(long mask, boolean value) { - if (value) this.flags |= mask; - else this.flags &= ~mask; - } - @Override public String toString() { return "ClientPermissions{" + @@ -175,30 +104,6 @@ public String toString() { '}'; } - @Deprecated - public enum PermissionConsts { - ADMIN(0x01), - MANAGEMENT(0x02); - public final long mask; - - PermissionConsts(long mask) { - this.mask = mask; - } - } - - @Deprecated - public enum FlagConsts { - SYSTEM(0x01), - BANNED(0x02), - UNTRUSTED(0x04), - HIDDEN(0x08); - public final long mask; - - FlagConsts(long mask) { - this.mask = mask; - } - } - public static class PermissionPattern { private final String[] parts; private final int priority; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ExceptionEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/ExceptionEvent.java deleted file mode 100644 index f91a01e7..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ExceptionEvent.java +++ /dev/null @@ -1,21 +0,0 @@ -package pro.gravit.launcher.events; - -import pro.gravit.launcher.LauncherNetworkAPI; - -@Deprecated -public class ExceptionEvent extends RequestEvent { - @LauncherNetworkAPI - public final String message; - @LauncherNetworkAPI - public final String clazz; - - public ExceptionEvent(Exception e) { - this.message = e.getMessage(); - this.clazz = e.getClass().getName(); - } - - @Override - public String getType() { - return "exception"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java deleted file mode 100644 index 8921d2ed..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/PingEvent.java +++ /dev/null @@ -1,7 +0,0 @@ -package pro.gravit.launcher.events; - -//Пустое событие -//Все обработчики обязаны его игнорировать -@Deprecated -public final class PingEvent { -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java deleted file mode 100644 index 98a21d24..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package pro.gravit.launcher.events; - -import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.request.WebSocketEvent; - -//Используется, что бы послать короткое сообщение, которое вмещается в int -@Deprecated -public class SignalEvent implements WebSocketEvent { - @LauncherNetworkAPI - public final int signal; - - public SignalEvent(int signal) { - this.signal = signal; - } - - @Override - public String getType() { - return "signal"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java deleted file mode 100644 index 6f3e4b49..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.request.WebSocketEvent; - -@Deprecated -public class LogEvent implements WebSocketEvent { - @LauncherNetworkAPI - public final String string; - - public LogEvent(String string) { - this.string = string; - } - - @Override - public String getType() { - return "log"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerReportRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerReportRequestEvent.java deleted file mode 100644 index 395dbe32..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerReportRequestEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.events.RequestEvent; - -@Deprecated -public class PingServerReportRequestEvent extends RequestEvent { - @Override - public String getType() { - return "pingServerReport"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerRequestEvent.java deleted file mode 100644 index 2f8277d3..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/PingServerRequestEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.launcher.request.management.PingServerReportRequest; - -import java.util.Map; - -@Deprecated -public class PingServerRequestEvent extends RequestEvent { - public Map serverMap; - - public PingServerRequestEvent() { - } - - public PingServerRequestEvent(Map serverMap) { - this.serverMap = serverMap; - } - - @Override - public String getType() { - return "pingServer"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java deleted file mode 100644 index 1d98c4de..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RegisterRequestEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.events.RequestEvent; - -@Deprecated -public class RegisterRequestEvent extends RequestEvent { - @Override - public String getType() { - return "register"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RestoreSessionRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RestoreSessionRequestEvent.java deleted file mode 100644 index 70016c56..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/RestoreSessionRequestEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.events.RequestEvent; - -@Deprecated -public class RestoreSessionRequestEvent extends RequestEvent { - public CurrentUserRequestEvent.UserInfo userInfo; - - public RestoreSessionRequestEvent() { - } - - public RestoreSessionRequestEvent(CurrentUserRequestEvent.UserInfo userInfo) { - this.userInfo = userInfo; - } - - @Override - public String getType() { - return "restoreSession"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java index 91d60a1e..53a5b1c8 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java @@ -1,13 +1,11 @@ package pro.gravit.launcher.request; -import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.events.request.RefreshTokenRequestEvent; import pro.gravit.launcher.events.request.RestoreRequestEvent; import pro.gravit.launcher.request.auth.RefreshTokenRequest; import pro.gravit.launcher.request.auth.RestoreRequest; -import pro.gravit.launcher.request.auth.RestoreSessionRequest; import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.utils.helper.LogHelper; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java deleted file mode 100644 index 4e256b6e..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -package pro.gravit.launcher.request.auth; - -import pro.gravit.launcher.LauncherNetworkAPI; -import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; -import pro.gravit.launcher.request.Request; -import pro.gravit.launcher.request.websockets.WebSocketRequest; - -import java.util.UUID; - -@Deprecated -public class RestoreSessionRequest extends Request implements WebSocketRequest { - @LauncherNetworkAPI - public final UUID session; - public boolean needUserInfo; - - public RestoreSessionRequest(UUID session) { - this.session = session; - } - - public RestoreSessionRequest(UUID session, boolean needUserInfo) { - this.session = session; - this.needUserInfo = needUserInfo; - } - - @Override - public String getType() { - return "restoreSession"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerReportRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerReportRequest.java deleted file mode 100644 index 05e10aa2..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerReportRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package pro.gravit.launcher.request.management; - -import pro.gravit.launcher.events.request.PingServerReportRequestEvent; -import pro.gravit.launcher.request.Request; - -import java.util.List; - -public class PingServerReportRequest extends Request { - public final String name; - public final PingServerReport data; - - public PingServerReportRequest(String name, PingServerReport data) { - this.name = name; - this.data = data; - } - - @Override - public String getType() { - return "pingServerReport"; - } - - public static class PingServerReport { - public final String name; - public final int maxPlayers; // player slots - public final int playersOnline; - //Server addional info - public double tps; //Server tps - public List users; - - public PingServerReport(String name, int maxPlayers, int playersOnline) { - this.name = name; - this.maxPlayers = maxPlayers; - this.playersOnline = playersOnline; - } - - public static class UsernameInfo { - public final String username; - - public UsernameInfo(String username) { - this.username = username; - } - } - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerRequest.java deleted file mode 100644 index 635caf41..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/management/PingServerRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package pro.gravit.launcher.request.management; - -import pro.gravit.launcher.events.request.PingServerRequestEvent; -import pro.gravit.launcher.request.Request; - -import java.util.ArrayList; -import java.util.List; - -public class PingServerRequest extends Request { - public List serverNames; //May be null - - public PingServerRequest() { - } - - public PingServerRequest(List serverNames) { - this.serverNames = serverNames; - } - - public PingServerRequest(String serverName) { - this.serverNames = new ArrayList<>(); - serverNames.add(serverName); - } - - @Override - public String getType() { - return "pingServer"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index 7768daea..d9571c2d 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -3,9 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import pro.gravit.launcher.Launcher; -import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.NotificationEvent; -import pro.gravit.launcher.events.SignalEvent; import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; @@ -97,21 +95,14 @@ public void registerResults() { results.register("updateList", UpdateListRequestEvent.class); results.register("error", ErrorRequestEvent.class); results.register("update", UpdateRequestEvent.class); - results.register("restoreSession", RestoreSessionRequestEvent.class); - results.register("log", LogEvent.class); results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); - results.register("exception", ExceptionEvent.class); - results.register("register", RegisterRequestEvent.class); results.register("notification", NotificationEvent.class); - results.register("signal", SignalEvent.class); results.register("exit", ExitRequestEvent.class); results.register("getSecureLevelInfo", GetSecureLevelInfoRequestEvent.class); results.register("verifySecureLevelKey", VerifySecureLevelKeyRequestEvent.class); results.register("securityReport", SecurityReportRequestEvent.class); results.register("hardwareReport", HardwareReportRequestEvent.class); results.register("serverStatus", ServerStatusRequestEvent.class); - results.register("pingServerReport", PingServerReportRequestEvent.class); - results.register("pingServer", PingServerRequestEvent.class); results.register("currentUser", CurrentUserRequestEvent.class); results.register("features", FeaturesRequestEvent.class); results.register("refreshToken", RefreshTokenRequestEvent.class); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java index 2c0664ee..9e395db9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java @@ -1,6 +1,5 @@ package pro.gravit.launcher.request.websockets; -import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.request.Request; @@ -93,9 +92,6 @@ public void eventHandle(T webSocketEvent) { if (future != null) { if (event instanceof ErrorRequestEvent) { future.completeExceptionally(new RequestException(((ErrorRequestEvent) event).error)); - } else if (event instanceof ExceptionEvent) { - future.completeExceptionally(new RequestException( - String.format("LaunchServer internal error: %s %s", ((ExceptionEvent) event).clazz, ((ExceptionEvent) event).message))); } else future.complete(event); futureMap.remove(event.requestUUID); diff --git a/LauncherCore/src/main/java11/pro/gravit/utils/helper/JVMHelper.java b/LauncherCore/src/main/java11/pro/gravit/utils/helper/JVMHelper.java index e5df50f0..78001387 100644 --- a/LauncherCore/src/main/java11/pro/gravit/utils/helper/JVMHelper.java +++ b/LauncherCore/src/main/java11/pro/gravit/utils/helper/JVMHelper.java @@ -24,7 +24,6 @@ public final class JVMHelper { public static final String OS_VERSION = OPERATING_SYSTEM_MXBEAN.getVersion(); public static final int OS_BITS = getCorrectOSArch(); public static final int JVM_BITS = Integer.parseInt(System.getProperty("sun.arch.data.model")); - public static final SecurityManager SECURITY_MANAGER = System.getSecurityManager(); // Public static fields public static final Runtime RUNTIME = Runtime.getRuntime(); public static final ClassLoader LOADER = ClassLoader.getSystemClassLoader(); diff --git a/modules b/modules index 4319cabb..56ad1f1d 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 4319cabbeb0abbb1c6bc76f23c16b7902b2be500 +Subproject commit 56ad1f1d6a9d72e17f8283b077a9b4b53bfc5eb0