From ef1f7b0e76c31a7fb8cc9886fc951e06eafab1c9 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 17 Feb 2019 15:30:03 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20AddLog?= =?UTF-8?q?Listener/ExecCommand/Auth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket/websocket/WebSocketService.java | 13 ++----------- .../json/admin/AddLogListenerResponse.java | 2 +- .../websocket/json/admin/ExecCommandResponse.java | 3 ++- .../socket/websocket/json/auth/AuthResponse.java | 2 +- .../events/request/ExecCommandRequestEvent.java | 15 +++++++++++++++ 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java index 3d1150e7..ffebe4cc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java @@ -17,6 +17,7 @@ import ru.gravit.launchserver.socket.websocket.json.JsonResponseAdapter; import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.socket.websocket.json.admin.AddLogListenerResponse; +import ru.gravit.launchserver.socket.websocket.json.admin.ExecCommandResponse; import ru.gravit.launchserver.socket.websocket.json.auth.*; import ru.gravit.launchserver.socket.websocket.json.update.LauncherResponse; import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; @@ -75,7 +76,7 @@ public void registerResponses() { registerResponse("profiles", ProfilesResponse.class); registerResponse("launcher", LauncherResponse.class); registerResponse("updateList", UpdateListResponse.class); - registerResponse("cmdExec", UpdateListResponse.class); + registerResponse("cmdExec", ExecCommandResponse.class); registerResponse("setProfile", SetProfileResponse.class); registerResponse("addLogListener", AddLogListenerResponse.class); } @@ -99,16 +100,6 @@ public void sendEvent(EventResult obj) { channels.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj))); } - public static class SuccessResult { - public SuccessResult(String requesttype) { - this.requesttype = requesttype; - this.type = "success"; - } - - public final String requesttype; - public final String type; - } - public static class EventResult implements ResultInterface { public EventResult() { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/AddLogListenerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/AddLogListenerResponse.java index 48b30c7b..9576f484 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/AddLogListenerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/AddLogListenerResponse.java @@ -38,8 +38,8 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client service.sendObject(ctx,new LogEvent(str)); } else { - LogHelper.info("Client %s remove log listener", client.username); LogHelper.removeOutput(client.logOutput); + LogHelper.info("Client %s remove log listener", client.username); } }; client.logOutput = output; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/ExecCommandResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/ExecCommandResponse.java index 457f3860..c7c0fd9d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/ExecCommandResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/admin/ExecCommandResponse.java @@ -2,6 +2,7 @@ import io.netty.channel.ChannelHandlerContext; import ru.gravit.launcher.events.request.ErrorRequestEvent; +import ru.gravit.launcher.events.request.ExecCommandRequestEvent; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.websocket.WebSocketService; @@ -26,6 +27,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client return; } LaunchServer.server.commandHandler.eval(cmd, false); - service.sendObject(ctx, new WebSocketService.SuccessResult("cmdExec")); + service.sendObject(ctx, new ExecCommandRequestEvent(true)); } } 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 2c650135..65aae7e9 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 @@ -60,7 +60,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client AuthProvider.authError(LaunchServer.server.config.authRejectString); return; } - if (authType != ConnectTypes.CLIENT &&!clientData.checkSign) { + if ((authType == null || authType == ConnectTypes.CLIENT) &&!clientData.checkSign) { AuthProvider.authError("Don't skip Launcher Update"); return; } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java new file mode 100644 index 00000000..d1eafbf7 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java @@ -0,0 +1,15 @@ +package ru.gravit.launcher.events.request; + +import ru.gravit.launcher.request.ResultInterface; + +public class ExecCommandRequestEvent implements ResultInterface { + @Override + public String getType() { + return "execCmd"; + } + boolean success; + + public ExecCommandRequestEvent(boolean success) { + this.success = success; + } +}